Merge branch 'develop' of https://github.com/lammps/lammps into kk_update_3.7

This commit is contained in:
Stan Moore
2022-10-10 13:44:02 -07:00
133 changed files with 6313 additions and 1175 deletions

View File

@ -105,7 +105,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4)
set(CMAKE_TUNE_DEFAULT "-xCOMMON-AVX512")
else()
set(CMAKE_TUNE_DEFAULT "-xHost")
set(CMAKE_TUNE_DEFAULT "-xHost -fp-model fast=2 -no-prec-div -qoverride-limits -diag-disable=10441 -diag-disable=2196")
endif()
endif()
endif()
@ -854,8 +854,11 @@ if(BUILD_SHARED_LIBS OR PKG_PYTHON)
find_package(Python COMPONENTS Interpreter)
endif()
if(Python_EXECUTABLE)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python)
install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python/lib)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python/src)
file(COPY ${LAMMPS_SOURCE_DIR}/version.h DESTINATION ${CMAKE_BINARY_DIR}/python/src)
file(COPY ${LAMMPS_PYTHON_DIR}/README ${LAMMPS_PYTHON_DIR}/pyproject.toml ${LAMMPS_PYTHON_DIR}/setup.py ${LAMMPS_PYTHON_DIR}/lammps DESTINATION ${CMAKE_BINARY_DIR}/python/lib)
install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\")\n execute_process(COMMAND ${Python_EXECUTABLE} -m pip install -v ${CMAKE_BINARY_DIR}/python/lib --prefix=${CMAKE_INSTALL_PREFIX})\n else()\n execute_process(COMMAND ${Python_EXECUTABLE} -m pip install -v ${CMAKE_BINARY_DIR}/python/lib --prefix=${CMAKE_INSTALL_PREFIX} --root=\$ENV{DESTDIR})\n endif()")
endif()
endif()

View File

@ -1,6 +1,6 @@
set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2021.10.25.fix2.tar.gz" CACHE STRING "URL for PACE evaluator library sources")
set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2022.09.27.fix10Oct.tar.gz" CACHE STRING "URL for PACE evaluator library sources")
set(PACELIB_MD5 "32394d799bc282bb57696c78c456e64f" CACHE STRING "MD5 checksum of PACE evaluator library tarball")
set(PACELIB_MD5 "766cebcc0e5c4b8430c2f3cd202d9905" CACHE STRING "MD5 checksum of PACE evaluator library tarball")
mark_as_advanced(PACELIB_URL)
mark_as_advanced(PACELIB_MD5)
@ -15,23 +15,9 @@ execute_process(
)
get_newest_file(${CMAKE_BINARY_DIR}/lammps-user-pace-* lib-pace)
# enforce building libyaml-cpp as static library and turn off optional features
set(YAML_BUILD_SHARED_LIBS OFF)
set(YAML_CPP_BUILD_CONTRIB OFF)
set(YAML_CPP_BUILD_TOOLS OFF)
add_subdirectory(${lib-pace}/yaml-cpp build-yaml-cpp)
set(YAML_CPP_INCLUDE_DIR ${lib-pace}/yaml-cpp/include)
file(GLOB PACE_EVALUATOR_INCLUDE_DIR ${lib-pace}/ML-PACE)
file(GLOB PACE_EVALUATOR_SOURCES ${lib-pace}/ML-PACE/*.cpp)
list(FILTER PACE_EVALUATOR_SOURCES EXCLUDE REGEX pair_pace.cpp)
add_library(pace STATIC ${PACE_EVALUATOR_SOURCES})
add_subdirectory(${lib-pace} build-pace)
set_target_properties(pace PROPERTIES CXX_EXTENSIONS ON OUTPUT_NAME lammps_pace${LAMMPS_MACHINE})
target_include_directories(pace PUBLIC ${PACE_EVALUATOR_INCLUDE_DIR} ${YAML_CPP_INCLUDE_DIR})
target_link_libraries(pace PRIVATE yaml-cpp-pace)
if(CMAKE_PROJECT_NAME STREQUAL "lammps")
target_link_libraries(lammps PRIVATE pace)
endif()

View File

@ -1,4 +1,4 @@
# preset that will enable Intel compilers with support for MPI and OpenMP (on Linux boxes)
# preset that will enable the classic Intel compilers with support for MPI and OpenMP (on Linux boxes)
set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE)
@ -18,11 +18,11 @@ set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
set(OpenMP_C "icc" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE)
set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_CXX "icpc" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_Fortran_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_Fortran_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE)
set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE)

View File

@ -18,11 +18,11 @@ set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
set(OpenMP_C "icx" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE)
set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_CXX "icpx" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_Fortran_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_Fortran_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE)
set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE)

View File

@ -216,7 +216,7 @@ be multiple tests run automatically:
- A test that only standard, printable ASCII text characters are used.
This runs the command ``env LC_ALL=C grep -n '[^ -~]' src/*.rst`` and
thus prints all offending lines with filename and line number
prepended to the screen. Special characters like greek letters
prepended to the screen. Special characters like Greek letters
(:math:`\alpha~~\sigma~~\epsilon`), super- or subscripts
(:math:`x^2~~\mathrm{U}_{LJ}`), mathematical expressions
(:math:`\frac{1}{2}\mathrm{N}~~x\to\infty`), or the Angstrom symbol

View File

@ -236,6 +236,7 @@ OPT.
* :doc:`oxrna2/xstk <pair_oxrna2>`
* :doc:`oxrna2/coaxstk <pair_oxrna2>`
* :doc:`pace (k) <pair_pace>`
* :doc:`pace/extrapolation <pair_pace>`
* :doc:`peri/eps <pair_peri>`
* :doc:`peri/lps (o) <pair_peri>`
* :doc:`peri/pmb (o) <pair_peri>`

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ fixes, or variables in LAMMPS using the following functions:
- :cpp:func:`lammps_extract_compute`
- :cpp:func:`lammps_extract_fix`
- :cpp:func:`lammps_extract_variable_datatype`
- :cpp:func:`lammps_extract_variable`
- :cpp:func:`lammps_set_variable`
@ -21,6 +22,11 @@ fixes, or variables in LAMMPS using the following functions:
-----------------------
.. doxygenfunction:: lammps_extract_variable_datatype
:project: progguide
-----------------------
.. doxygenfunction:: lammps_extract_variable
:project: progguide
@ -36,3 +42,5 @@ fixes, or variables in LAMMPS using the following functions:
.. doxygenenum:: _LMP_STYLE_CONST
.. doxygenenum:: _LMP_TYPE_CONST
.. doxygenenum:: _LMP_VAR_CONST

View File

@ -16,8 +16,8 @@ This section documents the following functions:
--------------------
The library interface allows the extraction of different kinds of
information about the active simulation instance and also - in some
cases - to apply modifications to it. This enables combining of a
information about the active simulation instance and also---in some
cases---to apply modifications to it. This enables combining of a
LAMMPS simulation with other processing and simulation methods computed
by the calling code, or by another code that is coupled to LAMMPS via
the library interface. In some cases the data returned is direct
@ -25,9 +25,9 @@ reference to the original data inside LAMMPS, cast to a void pointer.
In that case the data needs to be cast to a suitable pointer for the
calling program to access it, and you may need to know the correct
dimensions and lengths. This also means you can directly change those
value(s) from the calling program, e.g. to modify atom positions. Of
course, this should be done with care. When accessing per-atom data,
please note that this data is the per-processor **local** data and is
value(s) from the calling program (e.g., to modify atom positions). Of
course, changing values should be done with care. When accessing per-atom
data, please note that these data are the per-processor **local** data and are
indexed accordingly. Per-atom data can change sizes and ordering at
every neighbor list rebuild or atom sort event as atoms migrate between
sub-domains and processors.

View File

@ -30,12 +30,13 @@ executable itself can be placed elsewhere.
.. note::
The redirection operator "<" will not always work when running
in parallel with mpirun or mpiexec; for those systems the -in form is required.
The redirection operator "<" will not always work when running in
parallel with ``mpirun`` or ``mpiexec``; for those systems the -in
form is required.
As LAMMPS runs it prints info to the screen and a logfile named
*log.lammps*\ . More info about output is given on the
:doc:`screen and logfile output <Run_output>` page.
*log.lammps*\ . More info about output is given on the :doc:`screen and
logfile output <Run_output>` page.
If LAMMPS encounters errors in the input script or while running a
simulation it will print an ERROR message and stop or a WARNING

View File

@ -93,13 +93,13 @@ switch is not set (the default), LAMMPS will operate as if the KOKKOS
package were not installed; i.e. you can run standard LAMMPS or with
the GPU or OPENMP packages, for testing or benchmarking purposes.
Additional optional keyword/value pairs can be specified which
determine how Kokkos will use the underlying hardware on your
platform. These settings apply to each MPI task you launch via the
"mpirun" or "mpiexec" command. You may choose to run one or more MPI
tasks per physical node. Note that if you are running on a desktop
machine, you typically have one physical node. On a cluster or
supercomputer there may be dozens or 1000s of physical nodes.
Additional optional keyword/value pairs can be specified which determine
how Kokkos will use the underlying hardware on your platform. These
settings apply to each MPI task you launch via the ``mpirun`` or
``mpiexec`` command. You may choose to run one or more MPI tasks per
physical node. Note that if you are running on a desktop machine, you
typically have one physical node. On a cluster or supercomputer there
may be dozens or 1000s of physical nodes.
Either the full word or an abbreviation can be used for the keywords.
Note that the keywords do not use a leading minus sign. I.e. the
@ -148,9 +148,9 @@ one of these 4 environment variables
MV2_COMM_WORLD_LOCAL_RANK (Mvapich)
OMPI_COMM_WORLD_LOCAL_RANK (OpenMPI)
which are initialized by the "srun", "mpirun" or "mpiexec" commands.
The environment variable setting for each MPI rank is used to assign a
unique GPU ID to the MPI task.
which are initialized by the ``srun``, ``mpirun``, or ``mpiexec``
commands. The environment variable setting for each MPI rank is used to
assign a unique GPU ID to the MPI task.
.. parsed-literal::

View File

@ -76,10 +76,11 @@ instructions.
**Run with the GPU package from the command line:**
The mpirun or mpiexec command sets the total number of MPI tasks used
by LAMMPS (one or multiple per compute node) and the number of MPI
tasks used per node. E.g. the mpirun command in MPICH does this via
its -np and -ppn switches. Ditto for OpenMPI via -np and -npernode.
The ``mpirun`` or ``mpiexec`` command sets the total number of MPI tasks
used by LAMMPS (one or multiple per compute node) and the number of MPI
tasks used per node. E.g. the ``mpirun`` command in MPICH does this via
its ``-np`` and ``-ppn`` switches. Ditto for OpenMPI via ``-np`` and
``-npernode``.
When using the GPU package, you cannot assign more than one GPU to a
single MPI task. However multiple MPI tasks can share the same GPU,
@ -129,8 +130,8 @@ GPU package pair styles.
**Or run with the GPU package by editing an input script:**
The discussion above for the mpirun/mpiexec command, MPI tasks/node,
and use of multiple MPI tasks/GPU is the same.
The discussion above for the ``mpirun`` or ``mpiexec`` command, MPI
tasks/node, and use of multiple MPI tasks/GPU is the same.
Use the :doc:`suffix gpu <suffix>` command, or you can explicitly add an
"gpu" suffix to individual styles in your input script, e.g.

View File

@ -72,12 +72,12 @@ See the :ref:`Build extras <kokkos>` page for instructions.
Running LAMMPS with the KOKKOS package
""""""""""""""""""""""""""""""""""""""
All Kokkos operations occur within the context of an individual MPI
task running on a single node of the machine. The total number of MPI
tasks used by LAMMPS (one or multiple per compute node) is set in the
usual manner via the mpirun or mpiexec commands, and is independent of
Kokkos. E.g. the mpirun command in OpenMPI does this via its -np and
-npernode switches. Ditto for MPICH via -np and -ppn.
All Kokkos operations occur within the context of an individual MPI task
running on a single node of the machine. The total number of MPI tasks
used by LAMMPS (one or multiple per compute node) is set in the usual
manner via the ``mpirun`` or ``mpiexec`` commands, and is independent of
Kokkos. E.g. the mpirun command in OpenMPI does this via its ``-np`` and
``-npernode`` switches. Ditto for MPICH via ``-np`` and ``-ppn``.
Running on a multi-core CPU
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -168,7 +168,7 @@ for your MPI installation), binding can be forced with these flags:
.. parsed-literal::
OpenMPI 1.8: mpirun -np 2 --bind-to socket --map-by socket ./lmp_openmpi ...
OpenMPI 1.8: mpirun -np 2 --bind-to socket --map-by socket ./lmp_openmpi ...
Mvapich2 2.0: mpiexec -np 2 --bind-to socket --map-by socket ./lmp_mvapich ...
For binding threads with KOKKOS OpenMP, use thread affinity environment
@ -310,7 +310,8 @@ Alternatively the effect of the "-sf" or "-pk" switches can be
duplicated by adding the :doc:`package kokkos <package>` or :doc:`suffix kk <suffix>` commands to your input script.
The discussion above for building LAMMPS with the KOKKOS package, the
mpirun/mpiexec command, and setting appropriate thread are the same.
``mpirun`` or ``mpiexec`` command, and setting appropriate thread
properties are the same.
You must still use the "-k on" :doc:`command-line switch <Run_options>`
to enable the KOKKOS package, and specify its additional arguments for

View File

@ -33,8 +33,8 @@ These examples assume one or more 16-core nodes.
mpirun -np 4 lmp_omp -sf omp -pk omp 4 -in in.script # 4 MPI tasks, 4 threads/task
mpirun -np 32 -ppn 4 lmp_omp -sf omp -pk omp 4 -in in.script # 8 nodes, 4 MPI tasks/node, 4 threads/task
The mpirun or mpiexec command sets the total number of MPI tasks used
by LAMMPS (one or multiple per compute node) and the number of MPI
The ``mpirun`` or ``mpiexec`` command sets the total number of MPI tasks
used by LAMMPS (one or multiple per compute node) and the number of MPI
tasks used per node. E.g. the mpirun command in MPICH does this via
its -np and -ppn switches. Ditto for OpenMPI via -np and -npernode.
@ -58,8 +58,8 @@ OMP_NUM_THREADS environment variable.
Or run with the OPENMP package by editing an input script
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
The discussion above for the mpirun/mpiexec command, MPI tasks/node,
and threads/MPI task is the same.
The discussion above for the ``mpirun`` or ``mpiexec`` command, MPI
tasks/node, and threads/MPI task is the same.
Use the :doc:`suffix omp <suffix>` command, or you can explicitly add an
"omp" suffix to individual styles in your input script, e.g.

View File

@ -1,11 +1,15 @@
.. index:: pair_style pace
.. index:: pair_style pace/kk
.. index:: pair_style pace/extrapolation
pair_style pace command
=======================
Accelerator Variants: *pace/kk*
pair_style pace/extrapolation command
=====================================
Syntax
""""""
@ -22,6 +26,10 @@ Syntax
*recursive* = use recursive algorithm for basis functions
*chunksize* value = number of atoms in each pass
.. code-block:: LAMMPS
pair_style pace/extrapolation
Examples
""""""""
@ -31,50 +39,96 @@ Examples
pair_style pace product chunksize 2048
pair_coeff * * Cu-PBE-core-rep.ace Cu
pair_style pace/extrapolation
pair_coeff * * Cu.yaml Cu.asi Cu
Description
"""""""""""
Pair style *pace* computes interactions using the Atomic Cluster
Expansion (ACE), which is a general expansion of the atomic energy in
multi-body basis functions. :ref:`(Drautz) <Drautz20191>`.
The *pace* pair style
provides an efficient implementation that
is described in this paper :ref:`(Lysogorskiy) <Lysogorskiy20211>`.
multi-body basis functions. :ref:`(Drautz) <Drautz20191>`. The *pace*
pair style provides an efficient implementation that is described in
this paper :ref:`(Lysogorskiy) <Lysogorskiy20211>`.
In ACE, the total energy is decomposed into a sum over
atomic energies. The energy of atom *i* is expressed as a
linear or non-linear function of one or more density functions.
By projecting the
density onto a local atomic base, the lowest order contributions
to the energy can be expressed as a set of scalar polynomials in
basis function contributions summed over neighbor atoms.
In ACE, the total energy is decomposed into a sum over atomic
energies. The energy of atom *i* is expressed as a linear or non-linear
function of one or more density functions. By projecting the density
onto a local atomic base, the lowest order contributions to the energy
can be expressed as a set of scalar polynomials in basis function
contributions summed over neighbor atoms.
Only a single pair_coeff command is used with the *pace* style which
specifies an ACE coefficient file followed by N additional arguments
specifying the mapping of ACE elements to LAMMPS atom types,
where N is the number of LAMMPS atom types:
specifying the mapping of ACE elements to LAMMPS atom types, where N is
the number of LAMMPS atom types:
* ACE coefficient file
* N element names = mapping of ACE elements to atom types
Only a single pair_coeff command is used with the *pace* style which
specifies an ACE file that fully defines the potential.
Note that unlike for other potentials, cutoffs are
not set in the pair_style or pair_coeff command; they are specified in
the ACE file.
specifies an ACE file that fully defines the potential. Note that
unlike for other potentials, cutoffs are not set in the pair_style or
pair_coeff command; they are specified in the ACE file.
The pair_style *pace* command may be followed by the optional keyword
*product* or *recursive*, which determines which of two algorithms
is used for the calculation of basis functions and derivatives.
The default is *recursive*.
*product* or *recursive*, which determines which of two algorithms is
used for the calculation of basis functions and derivatives. The
default is *recursive*.
The keyword *chunksize* is only applicable when
using the pair style *pace* with the KOKKOS package on GPUs and is
ignored otherwise. This keyword controls the number of atoms
in each pass used to compute the atomic cluster expansion and is used to
avoid running out of memory. For example if there are 8192 atoms in the
simulation and the *chunksize* is set to 4096, the ACE
calculation will be broken up into two passes (running on a single GPU).
The keyword *chunksize* is only applicable when using the pair style
*pace* with the KOKKOS package on GPUs and is ignored otherwise. This
keyword controls the number of atoms in each pass used to compute the
atomic cluster expansion and is used to avoid running out of memory.
For example if there are 8192 atoms in the simulation and the
*chunksize* is set to 4096, the ACE calculation will be broken up into
two passes (running on a single GPU).
Extrapolation grade
"""""""""""""""""""
Calculation of extrapolation grade in PACE is implemented in `pair_style
pace/extrapolation`. It is based on the MaxVol algorithm similar to
Moment Tensor Potential (MTP) by Shapeev et al. and is described in
:ref:`(Lysogorskiy2) <Lysogorskiy2022>`. In order to compute
extrapolation grade one needs to provide:
#. ACE potential in B-basis form (`.yaml` format) and
#. Active Set Inverted (ASI) file for corresponding potential (`.asi` format)
Calculation of extrapolation grades requires matrix-vector
multiplication for each atom and is slower than the usual `pair_style
pace recursive`, therefore it is *not* computed by default.
Extrapolation grade calculation is involved by `fix pair`, which
requests to compute `gamma`, as shown in example below:
.. code-block:: LAMMPS
pair_style pace/extrapolation
pair_coeff * * Cu.yaml Cu.asi Cu
fix pace_gamma all pair 10 pace/extrapolation gamma 1
compute max_pace_gamma all reduce max f_pace_gamma
variable dump_skip equal "c_max_pace_gamma < 5"
dump pace_dump all custom 20 extrapolative_structures.dump id x y z f_pace_gamma
dump_modify pace_dump skip v_dump_skip
variable max_pace_gamma equal c_max_pace_gamma
fix extreme_extrapolation all halt 10 v_max_pace_gamma > 25
Here extrapolation grade gamma is computed every 10 steps and is stored
in `f_pace_gamma` per-atom variable. The largest value of extrapolation
grade among all atoms in a structure is reduced to `c_max_pace_gamma`
variable. Only if this value exceeds extrapolation threshold 5, then
the structure will be dumped into `extrapolative_structures.dump` file,
but not more often than every 20 steps.
On all other steps `pair_style pace recursive` will be used.
----------
See the :doc:`pair_coeff <pair_coeff>` page for alternate ways
to specify the path for the ACE coefficient file.
@ -90,9 +144,10 @@ specify a pair_coeff command with I != J arguments for this style.
This pair style does not support the :doc:`pair_modify <pair_modify>`
shift, table, and tail options.
This pair style does not write its information to :doc:`binary restart files <restart>`, since it is stored in potential files. Thus, you
need to re-specify the pair_style and pair_coeff commands in an input
script that reads a restart file.
This pair style does not write its information to :doc:`binary restart
files <restart>`, since it is stored in potential files. Thus, you need
to re-specify the pair_style and pair_coeff commands in an input script
that reads a restart file.
This pair style can only be used via the *pair* keyword of the
:doc:`run_style respa <run_style>` command. It does not support the
@ -107,19 +162,20 @@ This pair style can only be used via the *pair* keyword of the
Restrictions
""""""""""""
This pair style is part of the ML-PACE package. It is only enabled if LAMMPS
was built with that package.
See the :doc:`Build package <Build_package>` page for more info.
This pair style is part of the ML-PACE package. It is only enabled if
LAMMPS was built with that package. See the :doc:`Build package
<Build_package>` page for more info.
Related commands
""""""""""""""""
:doc:`pair_style snap <pair_snap>`
:doc:`pair_style snap <pair_snap>`,
:doc:`fix pair <fix_pair>`
Default
"""""""
recursive, chunksize = 4096
recursive, chunksize = 4096,
.. _Drautz20191:
@ -127,4 +183,8 @@ recursive, chunksize = 4096
.. _Lysogorskiy20211:
**(Lysogorskiy)** Lysogorskiy, van der Oord, Bochkarev, Menon, Rinaldi, Hammerschmidt, Mrovec, Thompson, Csanyi, Ortner, Drautz, TBD (2021).
**(Lysogorskiy)** Lysogorskiy, van der Oord, Bochkarev, Menon, Rinaldi, Hammerschmidt, Mrovec, Thompson, Csanyi, Ortner, Drautz, npj Comp Mat, 7, 97 (2021).
.. _Lysogorskiy2022:
**(Lysogorskiy2022)** Lysogorskiy, Bochkarev, Mrovec, Drautz, TBS (2022).

View File

@ -313,6 +313,7 @@ accelerated styles exist.
* :doc:`oxrna2/stk <pair_oxrna2>` -
* :doc:`oxrna2/xstk <pair_oxrna2>` -
* :doc:`pace <pair_pace>` - Atomic Cluster Expansion (ACE) machine-learning potential
* :doc:`pace/extrapolation <pair_pace>` - Atomic Cluster Expansion (ACE) machine-learning potential with extrapolation grades
* :doc:`peri/eps <pair_peri>` - peridynamic EPS potential
* :doc:`peri/lps <pair_peri>` - peridynamic LPS potential
* :doc:`peri/pmb <pair_peri>` - peridynamic PMB potential

View File

@ -78,6 +78,7 @@ Alexey
ali
aliceblue
Allinger
allocatable
allocator
allocators
allosws
@ -657,6 +658,7 @@ Dcut
de
dE
De
deallocate
deallocated
debye
Debye
@ -691,6 +693,7 @@ dequidt
Dequidt
der
dereference
dereferenced
derekt
Deresiewicz
Derjagin
@ -1486,6 +1489,7 @@ interfacial
interial
interlayer
intermolecular
interoperable
Interparticle
interstitials
intertube
@ -2387,6 +2391,7 @@ Nmols
nn
nnodes
npits
npj
nO
Nocedal
nocite
@ -3163,6 +3168,7 @@ sfree
Sg
Shan
Shanno
Shapeev
shapex
shapey
shapez
@ -3619,6 +3625,7 @@ Universite
unix
unmaintained
unoptimized
unordered
unpadded
unphysical
unphysically

View File

@ -1,9 +1,9 @@
This directory contains Fortran code which interface LAMMPS as a library
and allows the LAMMPS library interface to be invoked from Fortran codes.
It requires a Fortran compiler that supports the Fortran 2003 standard.
This directory contains Fortran code that acts as an interface to LAMMPS as a
library and allows the LAMMPS library interface to be invoked from Fortran
code. It requires a Fortran compiler that supports the Fortran 2003 standard.
This interface is based on and supersedes the previous Fortran interfaces
in the examples/COUPLE/fortran* folders, but is fully supported by the
in the examples/COUPLE/fortran* folders, but it is fully supported by the
LAMMPS developers and included in the documentation and unit testing.
Details on this Fortran interface and how to build programs using it

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
# /* ----------------------------------------------------------------------
# Generic Linux Makefile for OpenCL
# /* ----------------------------------------------------------------------
# Linux Makefile for Intel oneAPI - Mixed precision
# ------------------------------------------------------------------------- */
# which file will be copied to Makefile.lammps
@ -11,11 +11,14 @@ EXTRAMAKE = Makefile.lammps.opencl
LMP_INC = -DLAMMPS_SMALLBIG
OCL_INC =
OCL_CPP = mpiicpc -std=c++11 -xHost -O2 -qopenmp -qopenmp-simd -DMPICH_IGNORE_CXX_SEEK $(LMP_INC) $(OCL_INC)
OCL_LINK = -lOpenCL
OCL_INC = -I$(ONEAPI_ROOT)/compiler/latest/linux/include/sycl/
CPP_OPT = -xHost -O2 -qopenmp -qopenmp-simd -fp-model fast=2 -no-prec-div \
-qoverride-limits
OCL_CPP = mpiicpc -std=c++11 -diag-disable=10441 -DMPICH_IGNORE_CXX_SEEK \
$(LMP_INC) $(OCL_INC) $(CPP_OPT)
OCL_LINK = -L$(ONEAPI_ROOT)/compiler/latest/linux/lib -lOpenCL
OCL_PREC = -D_SINGLE_DOUBLE
OCL_TUNE = -DMPI_GERYON -DGERYON_NUMA_FISSION -DUCL_NO_EXIT -fp-model fast=2 -no-prec-div
OCL_TUNE = -DMPI_GERYON -DCUDA_PROXY -DGERYON_NUMA_FISSION -DUCL_NO_EXIT
BIN_DIR = ./
OBJ_DIR = ./

View File

@ -264,6 +264,20 @@ GERYON_KERNEL_DUMP Dump all compiled OpenCL programs with compiler
flags and build logs
GPU_CAST Casting performed on GPU, untested recently
THREE_CONCURRENT Concurrent 3-body calcs in separate queues, untested
LAL_SERIALIZE_INIT Force serialization of initialization and compilation
for multiple MPI tasks sharing the same accelerator.
Some accelerator API implementations have had issues
with temporary file conflicts in the past.
GERYON_FORCE_SHARED_MAIN_MEM_ON Should only be used for builds where the
accelerator is guaranteed to share physical
main memory with the host (e.g. integrated
GPU or CPU device). Default behavior is to
auto-detect. Impacts OpenCL only.
GERYON_FORCE_SHARED_MAIN_MEM_OFF Should only be used for builds where the
accelerator is guaranteed to have discrete
physical main memory vs the host (discrete
GPU card). Default behavior is to
auto-detect. Impacts OpenCL only.
------------------------------------------------------------------------------

View File

@ -126,10 +126,13 @@ class UCL_Device {
/// Return the number of devices that support OpenCL
inline int num_devices() { return _num_devices; }
/// Specify whether profiling (device timers) will be used for the device (yes=true)
/// Specify whether profiling (device timers) will be used (yes=true)
/** No-op for CUDA and HIP **/
inline void configure_profiling(const bool profiling_on)
{ _cq_profiling = profiling_on; }
inline void configure_profiling(const bool profiling_on) {
#ifndef GERYON_NO_OCL_MARKERS
_cq_profiling = profiling_on;
#endif
}
/// Set the OpenCL device to the specified device number
/** A context and default command queue will be created for the device *
@ -176,8 +179,8 @@ class UCL_Device {
#ifdef CL_VERSION_2_0
if (_cq_profiling) {
cl_queue_properties props[] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE,
0};
cl_queue_properties props[] = {CL_QUEUE_PROPERTIES,
CL_QUEUE_PROFILING_ENABLE, 0};
_cq.back()=clCreateCommandQueueWithProperties(_context, _cl_device, props,
&errorv);
} else {
@ -187,8 +190,8 @@ class UCL_Device {
}
#else
if (_cq_profiling)
_cq.back()=clCreateCommandQueue(_context, _cl_device, CL_QUEUE_PROFILING_ENABLE,
&errorv);
_cq.back()=clCreateCommandQueue(_context, _cl_device,
CL_QUEUE_PROFILING_ENABLE, &errorv);
else
_cq.back()=clCreateCommandQueue(_context, _cl_device, 0, &errorv);
#endif
@ -403,7 +406,11 @@ class UCL_Device {
// Grabs the properties for all devices
UCL_Device::UCL_Device() {
_device=-1;
#ifndef GERYON_NO_OCL_MARKERS
_cq_profiling=true;
#else
_cq_profiling=false;
#endif
// --- Get Number of Platforms
cl_uint nplatforms;
@ -482,6 +489,7 @@ int UCL_Device::set_platform(int pid) {
_num_devices = 0;
for (int i=0; i<num_unpart; i++) {
cl_uint num_subdevices = 1;
cl_device_id *subdevice_list = device_list + i;
#ifdef CL_VERSION_1_2
cl_device_affinity_domain adomain;
@ -494,25 +502,29 @@ int UCL_Device::set_platform(int pid) {
props[0]=CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN;
props[1]=CL_DEVICE_AFFINITY_DOMAIN_NUMA;
props[2]=0;
cl_int err = CL_SUCCESS;
if (adomain & CL_DEVICE_AFFINITY_DOMAIN_NUMA)
CL_SAFE_CALL(clCreateSubDevices(device_list[i], props, 0, NULL,
&num_subdevices));
if (num_subdevices > 1) {
cl_device_id *subdevice_list = new cl_device_id[num_subdevices];
CL_SAFE_CALL(clCreateSubDevices(device_list[i], props, num_subdevices,
subdevice_list, &num_subdevices));
for (cl_uint j=0; j<num_subdevices; j++) {
_cl_devices.push_back(device_list[i]);
add_properties(device_list[i]);
_num_devices++;
err = clCreateSubDevices(device_list[i], props, 0, NULL,
&num_subdevices);
if (err == CL_SUCCESS && num_subdevices > 1) {
subdevice_list = new cl_device_id[num_subdevices];
err = clCreateSubDevices(device_list[i], props, num_subdevices,
subdevice_list, &num_subdevices);
if (err != CL_SUCCESS) {
delete[] subdevice_list;
num_subdevices = 1;
subdevice_list = device_list + i;
}
delete[] subdevice_list;
} else {
_cl_devices.push_back(device_list[i]);
add_properties(device_list[i]);
_num_devices++;
}
#endif
for (cl_uint j=0; j<num_subdevices; j++) {
_num_devices++;
_cl_devices.push_back(subdevice_list[j]);
add_properties(subdevice_list[j]);
}
if (num_subdevices > 1) delete[] subdevice_list;
} // for i
#endif
@ -686,10 +698,10 @@ void UCL_Device::add_properties(cl_device_id device_list) {
double arch = static_cast<double>(minor)/10+major;
if (arch >= 3.0)
op.has_shuffle_support=true;
op.shared_main_memory=_shared_mem_device(device_list);
}
delete[] buffer2;
#endif
op.shared_main_memory=_shared_mem_device(device_list);
_properties.push_back(op);
}

View File

@ -27,11 +27,15 @@
#include "ocl_macros.h"
#include "ocl_device.h"
#ifndef GERYON_NO_OCL_MARKERS
#ifdef CL_VERSION_1_2
#define UCL_OCL_MARKER(cq,event) clEnqueueMarkerWithWaitList(cq,0,nullptr,event)
#else
#define UCL_OCL_MARKER clEnqueueMarker
#endif
#else
#define UCL_OCL_MARKER(cq,event)
#endif
namespace ucl_opencl {
@ -51,8 +55,10 @@ class UCL_Timer {
inline void clear() {
if (_initialized) {
if (has_measured_time) {
#ifndef GERYON_NO_OCL_MARKERS
clReleaseEvent(start_event);
clReleaseEvent(stop_event);
#endif
has_measured_time = false;
}
CL_DESTRUCT_CALL(clReleaseCommandQueue(_cq));
@ -76,8 +82,10 @@ class UCL_Timer {
/// Start timing on default command queue
inline void start() {
if (has_measured_time) {
#ifndef GERYON_NO_OCL_MARKERS
clReleaseEvent(start_event);
clReleaseEvent(stop_event);
#endif
has_measured_time = false;
}
UCL_OCL_MARKER(_cq,&start_event);
@ -91,17 +99,26 @@ class UCL_Timer {
/// Block until the start event has been reached on device
inline void sync_start() {
#ifndef GERYON_NO_OCL_MARKERS
CL_SAFE_CALL(clWaitForEvents(1,&start_event));
if (has_measured_time) {
clReleaseEvent(start_event);
clReleaseEvent(stop_event);
has_measured_time = false;
}
CL_SAFE_CALL(clWaitForEvents(1,&start_event));
#else
CL_SAFE_CALL(clFinish(_cq));
has_measured_time = false;
#endif
}
/// Block until the stop event has been reached on device
inline void sync_stop() {
#ifndef GERYON_NO_OCL_MARKERS
CL_SAFE_CALL(clWaitForEvents(1,&stop_event));
#else
CL_SAFE_CALL(clFinish(_cq));
#endif
has_measured_time = true;
}
@ -126,6 +143,7 @@ class UCL_Timer {
/// Return the time (ms) of last start to stop - Forces synchronization
inline double time() {
if(!has_measured_time) return 0.0;
#ifndef GERYON_NO_OCL_MARKERS
cl_ulong tstart,tend;
CL_SAFE_CALL(clWaitForEvents(1,&stop_event));
CL_SAFE_CALL(clGetEventProfilingInfo(stop_event,
@ -138,6 +156,11 @@ class UCL_Timer {
clReleaseEvent(stop_event);
has_measured_time = false;
return (tend-tstart)*1e-6;
#else
CL_SAFE_CALL(clFinish(_cq));
has_measured_time = false;
return 0.0;
#endif
}
/// Return the time (s) of last start to stop - Forces synchronization

View File

@ -76,7 +76,7 @@ int beck_gpu_init(const int ntypes, double **cutsq, double **aa,
special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
BLMF.device->gpu_barrier();
BLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -84,7 +84,7 @@ int bornclcs_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
gpu_split, screen, host_cut_ljsq, host_cut_coulsq,
host_special_coul, qqrd2e, g_ewald);
BCLCSMF.device->gpu_barrier();
BCLCSMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -84,7 +84,7 @@ int borncl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
gpu_split, screen, host_cut_ljsq, host_cut_coulsq,
host_special_coul, qqrd2e, g_ewald);
BORNCLMF.device->gpu_barrier();
BORNCLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -86,7 +86,7 @@ int borncwcs_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
host_cut_coulsq, host_special_coul, qqrd2e,
alf, e_shift, f_shift);
BornCWCST.device->gpu_barrier();
BornCWCST.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -86,7 +86,7 @@ int borncw_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
host_cut_coulsq, host_special_coul, qqrd2e,
alf, e_shift, f_shift);
BORNCWMF.device->gpu_barrier();
BORNCWMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -80,7 +80,7 @@ int born_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
offset, special_lj, inum, nall, max_nbors,
maxspecial, cell_size, gpu_split, screen);
BORNMF.device->gpu_barrier();
BORNMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -114,7 +114,7 @@ void born_gpu_reinit(const int ntypes, double **host_rhoinv,
BORNMF.reinit(ntypes, host_rhoinv, host_born1, host_born2,
host_born3, host_a, host_c, host_d, offset);
BORNMF.device->gpu_barrier();
BORNMF.device->serialize_init();
}
}

View File

@ -83,7 +83,7 @@ int buckc_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
host_cut_ljsq, host_cut_coulsq,
host_special_coul, qqrd2e);
BUCKCMF.device->gpu_barrier();
BUCKCMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -82,7 +82,7 @@ int buckcl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
maxspecial, cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e, g_ewald);
BUCKCLMF.device->gpu_barrier();
BUCKCLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -77,7 +77,7 @@ int buck_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
host_a, host_c, offset, special_lj, inum, nall, max_nbors,
maxspecial, cell_size, gpu_split, screen);
BUCKMF.device->gpu_barrier();
BUCKMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -110,7 +110,7 @@ void buck_gpu_reinit(const int ntypes, double **cutsq, double **host_rhoinv,
BUCKMF.reinit(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2,
host_a, host_c, offset);
BUCKMF.device->gpu_barrier();
BUCKMF.device->serialize_init();
}
}

View File

@ -88,7 +88,7 @@ int crm_gpu_init(const int ntypes, double cut_bothsq, double **host_lj1,
qqrd2e, cut_lj_innersq, cut_coul_innersq, denom_lj,
denom_coul, epsilon, sigma, mix_arithmetic);
CRMMF.device->gpu_barrier();
CRMMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -86,7 +86,7 @@ int crml_gpu_init(const int ntypes, double cut_bothsq, double **host_lj1,
qqrd2e, g_ewald, cut_lj_innersq, denom_lj, epsilon,
sigma, mix_arithmetic);
CRMLMF.device->gpu_barrier();
CRMLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -83,7 +83,7 @@ int colloid_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
COLLMF.device->gpu_barrier();
COLLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -74,7 +74,7 @@ int cdebye_gpu_init(const int ntypes, double **host_scale, double **cutsq,
init_ok=CDEMF.init(ntypes, host_scale, cutsq, host_special_coul, inum, nall, max_nbors,
maxspecial, cell_size, gpu_split, screen, qqrd2e, kappa);
CDEMF.device->gpu_barrier();
CDEMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -103,7 +103,7 @@ void cdebye_gpu_reinit(const int ntypes, double **host_scale) {
if (gpu_rank==i && world_me!=0)
CDEMF.reinit(ntypes, host_scale);
CDEMF.device->gpu_barrier();
CDEMF.device->serialize_init();
}
}

View File

@ -77,7 +77,7 @@ int cdsf_gpu_init(const int ntypes, const int inum, const int nall,
gpu_split, screen, host_cut_coulsq, host_special_coul,
qqrd2e, e_shift, f_shift, alpha);
CDMF.device->gpu_barrier();
CDMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -74,7 +74,7 @@ int coul_gpu_init(const int ntypes, double **host_scale,
init_ok=COULMF.init(ntypes, host_scale, cutsq, special_coul, inum, nall, max_nbors,
maxspecial, cell_size, gpu_split, screen, qqrd2e);
COULMF.device->gpu_barrier();
COULMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -103,7 +103,7 @@ void coul_gpu_reinit(const int ntypes, double **host_scale) {
if (gpu_rank==i && world_me!=0)
COULMF.reinit(ntypes, host_scale);
COULMF.device->gpu_barrier();
COULMF.device->serialize_init();
}
}

View File

@ -76,7 +76,7 @@ int clcs_gpu_init(const int ntypes, double **host_scale,
cell_size, gpu_split, screen, host_cut_coulsq,
host_special_coul, qqrd2e, g_ewald);
CLCSMF.device->gpu_barrier();
CLCSMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -105,7 +105,7 @@ void clcs_gpu_reinit(const int ntypes, double **host_scale) {
if (gpu_rank==i && world_me!=0)
CLCSMF.reinit(ntypes, host_scale);
CLCSMF.device->gpu_barrier();
CLCSMF.device->serialize_init();
}
}

View File

@ -76,7 +76,7 @@ int cl_gpu_init(const int ntypes, double **host_scale,
cell_size, gpu_split, screen, host_cut_coulsq,
host_special_coul, qqrd2e, g_ewald);
CLMF.device->gpu_barrier();
CLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -105,7 +105,7 @@ void cl_gpu_reinit(const int ntypes, double **host_scale) {
if (gpu_rank==i && world_me!=0)
CLMF.reinit(ntypes, host_scale);
CLMF.device->gpu_barrier();
CLMF.device->serialize_init();
}
}

View File

@ -328,7 +328,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int ngpu,
for (int i=0; i<_procs_per_gpu; i++) {
if (_gpu_rank==i)
flag=compile_kernels();
gpu_barrier();
serialize_init();
}
// check if double precision support is available
@ -609,6 +609,10 @@ void DeviceT::init_message(FILE *screen, const char *name,
int last=last_gpu+1;
if (last>gpu->num_devices())
last=gpu->num_devices();
if (gpu->num_platforms()>1) {
std::string pname=gpu->platform_name();
fprintf(screen,"Platform: %s\n",pname.c_str());
}
for (int i=first_gpu; i<last; i++) {
std::string sname;
if (i==first_gpu)

View File

@ -217,6 +217,12 @@ class Device {
inline int gpu_rank() const { return _gpu_rank; }
/// MPI Barrier for gpu
inline void gpu_barrier() { MPI_Barrier(_comm_gpu); }
/// Serialize GPU initialization and JIT for unsafe platforms
inline void serialize_init() {
#ifdef LAL_SERIALIZE_INIT
gpu_barrier();
#endif
}
/// Return the 'mode' for acceleration: GPU_FORCE, GPU_NEIGH or GPU_HYB_NEIGH
inline int gpu_mode() const { return _gpu_mode; }
/// Index of first device used by a node

View File

@ -80,7 +80,7 @@ int dpl_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e);
DPLMF.device->gpu_barrier();
DPLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -80,7 +80,7 @@ int dplsf_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e);
DPLSFMF.device->gpu_barrier();
DPLSFMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -81,7 +81,7 @@ int dplj_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e, g_ewald);
DPLJMF.device->gpu_barrier();
DPLJMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int dpd_gpu_init(const int ntypes, double **cutsq, double **host_a0,
host_cut, special_lj, false, inum, nall, max_nbors,
maxspecial, cell_size, gpu_split, screen);
DPDMF.device->gpu_barrier();
DPDMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int dpd_tstat_gpu_init(const int ntypes, double **cutsq, double **host_a0,
host_cut, special_lj, true, inum, nall, 300,
maxspecial, cell_size, gpu_split, screen);
DPDTMF.device->gpu_barrier();
DPDTMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -90,7 +90,7 @@ int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq,
nz2r, nfrho, nr, nlocal, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
EAMALMF.device->gpu_barrier();
EAMALMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -90,7 +90,7 @@ int eam_gpu_init(const int ntypes, double host_cutforcesq,
nz2r, nfrho, nr, nlocal, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
EAMMF.device->gpu_barrier();
EAMMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -90,7 +90,7 @@ int eam_fs_gpu_init(const int ntypes, double host_cutforcesq,
nz2r, nfrho, nr, nlocal, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
EAMFSMF.device->gpu_barrier();
EAMFSMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a,
offset, special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
GLMF.device->gpu_barrier();
GLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -106,7 +106,7 @@ void gauss_gpu_reinit(const int ntypes, double **cutsq, double **host_a,
if (gpu_rank==i && world_me!=0)
GLMF.reinit(ntypes, cutsq, host_a, host_b, offset);
GLMF.device->gpu_barrier();
GLMF.device->serialize_init();
}
}

View File

@ -83,7 +83,7 @@ int gb_gpu_init(const int ntypes, const double gamma,
host_lj3, host_lj4, offset, special_lj, inum, nall,
max_nbors, maxspecial, cell_size, gpu_split, screen);
GBMF.device->gpu_barrier();
GBMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int lj96_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
offset, special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
LJ96MF.device->gpu_barrier();
LJ96MF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -81,7 +81,7 @@ int c2cl_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e, g_ewald);
C2CLMF.device->gpu_barrier();
C2CLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -81,7 +81,7 @@ int ljcd_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e, kappa);
LJCDMF.device->gpu_barrier();
LJCDMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -80,7 +80,7 @@ int ljc_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e);
LJCMF.device->gpu_barrier();
LJCMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -81,7 +81,7 @@ int ljcl_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e, g_ewald);
LJCLMF.device->gpu_barrier();
LJCLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -112,7 +112,7 @@ void ljcl_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1,
if (gpu_rank==i && world_me!=0)
LJCLMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4,
offset, host_cut_ljsq);
LJCLMF.device->gpu_barrier();
LJCLMF.device->serialize_init();
}
}

View File

@ -83,7 +83,7 @@ int ljcm_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, order, qqrd2e);
LJCMLMF.device->gpu_barrier();
LJCMLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -80,7 +80,7 @@ int ljcb_gpu_init(const int ntypes, double **cutsq, double **cut_inner_sq,
special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
LJCubicLMF.device->gpu_barrier();
LJCubicLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -84,7 +84,7 @@ int ljd_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
host_cut_coulsq, host_special_coul, qqrd2e, e_shift,
f_shift, alpha);
LJDMF.device->gpu_barrier();
LJDMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -81,7 +81,7 @@ int ljecl_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_cut_ljsq,
host_cut_coulsq, host_special_coul, qqrd2e, g_ewald);
LJECLMF.device->gpu_barrier();
LJECLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -112,7 +112,7 @@ void ljecl_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1,
if (gpu_rank==i && world_me!=0)
LJECLMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4,
offset, shift, host_cut_ljsq);
LJECLMF.device->gpu_barrier();
LJECLMF.device->serialize_init();
}
}

View File

@ -108,7 +108,7 @@ void lje_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1,
if (gpu_rank==i && world_me!=0)
LJEMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4,
offset, shift);
LJEMF.device->gpu_barrier();
LJEMF.device->serialize_init();
}
}

View File

@ -76,7 +76,7 @@ int ljl_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
offset, special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
LJLMF.device->gpu_barrier();
LJLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -105,7 +105,7 @@ void ljl_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1,
for (int i=0; i<procs_per_gpu; i++) {
if (gpu_rank==i && world_me!=0)
LJLMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, offset);
LJLMF.device->gpu_barrier();
LJLMF.device->serialize_init();
}
}

View File

@ -81,7 +81,7 @@ int ljgrm_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
gpu_split, screen, host_ljsw1, host_ljsw2, host_ljsw3,
host_ljsw4, host_ljsw5, cut_inner, cut_inner_sq);
LJGRMMF.device->gpu_barrier();
LJGRMMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -80,7 +80,7 @@ int ljsmt_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
cell_size, gpu_split, screen, host_ljsw0, host_ljsw1, host_ljsw2, host_ljsw3,
host_ljsw4, cut_inner, cut_inner_sq);
LJSMTMF.device->gpu_barrier();
LJSMTMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -110,7 +110,7 @@ void ljsmt_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1,
for (int i=0; i<procs_per_gpu; i++) {
if (gpu_rank==i && world_me!=0)
LJSMTMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, offset, host_ljsw0, host_ljsw1, host_ljsw2, host_ljsw3, host_ljsw4, cut_inner, cut_inner_sq);
LJSMTMF.device->gpu_barrier();
LJSMTMF.device->serialize_init();
}
}

View File

@ -77,7 +77,7 @@ int spica_gpu_init(const int ntypes, double **cutsq, int **cg_types,
host_lj4, offset, special_lj, inum, nall, max_nbors,
maxspecial, cell_size, gpu_split, screen);
CMMMF.device->gpu_barrier();
CMMMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -81,7 +81,7 @@ int spical_gpu_init(const int ntypes, double **cutsq, int **cg_type,
maxspecial, cell_size, gpu_split, screen,
host_cut_ljsq, host_cut_coulsq, host_special_coul,
qqrd2e, g_ewald);
CMMLMF.device->gpu_barrier();
CMMLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -89,7 +89,7 @@ int ljtip4p_long_gpu_init(const int ntypes, double **cutsq, double **host_lj1,
host_special_coul, qqrd2e,
g_ewald, map_size, max_same);
LJTIP4PLMF.device->gpu_barrier();
LJTIP4PLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -80,7 +80,7 @@ int mie_gpu_init(const int ntypes, double **cutsq, double **host_mie1,
offset, special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
MLMF.device->gpu_barrier();
MLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -77,7 +77,7 @@ int mor_gpu_init(const int ntypes, double **cutsq,
offset, special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
MORMF.device->gpu_barrier();
MORMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -81,7 +81,7 @@ grdtyp * pppm_gpu_init(memtyp &pppm, const int nlocal, const int nall,
vd_brick,slab_volfactor,nx_pppm,ny_pppm,nz_pppm,
split,success);
pppm.device->gpu_barrier();
pppm.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -80,7 +80,7 @@ int re_gpu_init(const int ntypes, double **shape, double **well, double **cutsq,
host_lj4, offset, special_lj, inum, nall,
max_nbors, maxspecial, cell_size, gpu_split, screen);
REMF.device->gpu_barrier();
REMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int soft_gpu_init(const int ntypes, double **cutsq, double **host_prefactor,
special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
SLMF.device->gpu_barrier();
SLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -106,7 +106,7 @@ void soft_gpu_reinit(const int ntypes, double **cutsq, double **host_prefactor,
if (gpu_rank==i && world_me!=0)
SLMF.reinit(ntypes, cutsq, host_prefactor, host_cut);
SLMF.device->gpu_barrier();
SLMF.device->serialize_init();
}
}

View File

@ -84,7 +84,7 @@ int sw_gpu_init(const int ntypes, const int inum, const int nall,
sigma_gamma, c1, c2, c3, c4, c5, c6, lambda_epsilon,
costheta, map, e2param);
SWMF.device->gpu_barrier();
SWMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int table_gpu_init(const int ntypes, double **cutsq, double ***table_coeffs,
special_lj, inum, nall, max_nbors, maxspecial, cell_size,
gpu_split, screen, tabstyle, ntables, tablength);
TBMF.device->gpu_barrier();
TBMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -91,7 +91,7 @@ int tersoff_gpu_init(const int ntypes, const int inum, const int nall, const int
ts_c1, ts_c2, ts_c3, ts_c4, ts_c, ts_d, ts_h,
ts_gamma, ts_beta, ts_powern, ts_cutsq);
TSMF.device->gpu_barrier();
TSMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -91,7 +91,7 @@ int tersoff_mod_gpu_init(const int ntypes, const int inum, const int nall,
ts_c3, ts_c4, ts_c5, ts_h, ts_beta, ts_powern,
ts_powern_del, ts_ca1, ts_cutsq);
TSMMF.device->gpu_barrier();
TSMMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -102,7 +102,7 @@ int tersoff_zbl_gpu_init(const int ntypes, const int inum, const int nall,
ts_ZBLcut, ts_ZBLexpscale, global_e, global_a_0,
global_epsilon_0, ts_cutsq);
TSZMF.device->gpu_barrier();
TSZMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -78,7 +78,7 @@ int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
offset, special_lj, inum, nall, max_nbors, maxspecial,
cell_size, gpu_split, screen);
UFMLMF.device->gpu_barrier();
UFMLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}
@ -106,7 +106,7 @@ void ufml_gpu_reinit(const int ntypes, double **cutsq, double **host_uf1,
for (int i=0; i<procs_per_gpu; i++) {
if (gpu_rank==i && world_me!=0)
UFMLMF.reinit(ntypes, cutsq, host_uf1, host_uf2, host_uf3, offset);
UFMLMF.device->gpu_barrier();
UFMLMF.device->serialize_init();
}
}

View File

@ -89,7 +89,7 @@ int vashishta_gpu_init(const int ntypes, const int inum, const int nall, const i
lam4inv, zizj, mbigd, dvrc, big6w, heta, bigh, bigw,
c0, costheta, bigb, big2b, bigc);
VashishtaMF.device->gpu_barrier();
VashishtaMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int ykcolloid_gpu_init(const int ntypes, double **cutsq, double **host_a,
inum, nall, max_nbors, maxspecial, cell_size, gpu_split,
screen, kappa);
YKCOLLMF.device->gpu_barrier();
YKCOLLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -76,7 +76,7 @@ int yukawa_gpu_init(const int ntypes, double **cutsq, double kappa,
inum, nall, max_nbors, maxspecial, cell_size,
gpu_split, screen);
YKMF.device->gpu_barrier();
YKMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -79,7 +79,7 @@ int zbl_gpu_init(const int ntypes, double **cutsq, double **host_sw1,
cut_globalsq, cut_innersq, cut_inner,
inum, nall, max_nbors, maxspecial, cell_size, gpu_split, screen);
ZBLMF.device->gpu_barrier();
ZBLMF.device->serialize_init();
if (message)
fprintf(screen,"Done.\n");
}

View File

@ -1,4 +1,4 @@
# TODO#!/usr/bin/env python
#!/usr/bin/env python
"""
Install.py tool to download, compile, and setup the pace library
@ -6,7 +6,10 @@ used to automate the steps described in the README file in this dir
"""
from __future__ import print_function
import sys, subprocess
import shutil
import subprocess
import sys
from argparse import ArgumentParser
sys.path.append('..')
@ -15,23 +18,16 @@ from install_helpers import fullpath, geturl, checkmd5sum
# settings
thisdir = fullpath('.')
version = 'v.2021.10.25.fix2'
version ='v.2022.09.27.fix10Oct'
# known checksums for different PACE versions. used to validate the download.
checksums = { \
'v.2021.2.3.upd2' : '8fd1162724d349b930e474927197f20d',
'v.2021.4.9' : '4db54962fbd6adcf8c18d46e1798ceb5',
'v.2021.9.28' : 'f98363bb98adc7295ea63974738c2a1b',
'v.2021.10.25' : 'a2ac3315c41a1a4a5c912bcb1bc9c5cc',
'v.2021.10.25.fix': 'e0572de57039d4afedefb25707b6ceae',
'v.2021.10.25.fix2': '32394d799bc282bb57696c78c456e64f'
}
'v.2022.09.27.fix10Oct': '766cebcc0e5c4b8430c2f3cd202d9905'
}
parser = ArgumentParser(prog='Install.py',
description="LAMMPS library build wrapper script")
# help message
HELP = """
@ -55,55 +51,68 @@ parser.add_argument("-v", "--version", default=version, choices=checksums.keys()
help="set version of PACE library to download and build (default: %s)" % version)
parser.add_argument("-vv", "--verbose", action="store_true",
help="be more verbose about is happening while this script runs")
parser.add_argument("-l", "--local", default=None,
help="use local version of PACE library build")
args = parser.parse_args()
# print help message and exit, if neither build nor path options are given
if not args.build:
parser.print_help()
sys.exit(HELP)
parser.print_help()
sys.exit(HELP)
buildflag = args.build
verboseflag = args.verbose
version = args.version
local = args.local
archive_extension = "tar.gz"
url = "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/%s.%s" % (version, archive_extension)
unarchived_folder_name = "lammps-user-pace-%s"%(version)
unarchived_folder_name = "lammps-user-pace-%s" % (version)
# download PACE tarball, unpack, build PACE
if buildflag:
if not local:
# download entire tarball
print("Downloading pace tarball ...")
archive_filename = "%s.%s" % (version, archive_extension)
download_filename = "%s/%s" % (thisdir, archive_filename)
print("Downloading from ", url, " to ", download_filename, end=" ")
geturl(url, download_filename)
print(" done")
# download entire tarball
# verify downloaded archive integrity via md5 checksum, if known.
if version in checksums:
if not checkmd5sum(checksums[version], archive_filename):
sys.exit("Checksum for pace library does not match")
print("Downloading pace tarball ...")
archive_filename = "%s.%s" % (version, archive_extension)
download_filename = "%s/%s" % (thisdir, archive_filename)
print("Downloading from ",url," to ",download_filename, end=" ")
geturl(url, download_filename)
print(" done")
print("Unpacking pace tarball ...")
src_folder = thisdir + "/src"
cmd = 'cd "%s"; rm -rf "%s"; tar -xvf %s; mv %s %s' % (
thisdir, src_folder, archive_filename, unarchived_folder_name, src_folder)
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
else:
# copy from local version of library PACE
print("Copy pace from ", local)
src_folder = thisdir + "/src"
shutil.copytree(local, src_folder,
# ignore=lambda (s1,s2): ('.git' in s1 or '.git' in s2),
dirs_exist_ok=True)
# verify downloaded archive integrity via md5 checksum, if known.
if version in checksums:
if not checkmd5sum(checksums[version], archive_filename):
sys.exit("Checksum for pace library does not match")
print("Unpacking pace tarball ...")
src_folder = thisdir+"/src"
cmd = 'cd "%s"; rm -rf "%s"; tar -xvf %s; mv %s %s' % (thisdir, src_folder, archive_filename, unarchived_folder_name, src_folder)
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
# build
print("Building libpace ...")
cmd = 'make lib -j2'
txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
if verboseflag:
print(txt.decode("UTF-8"))
# build
print("Building libpace ...")
cmd = 'make lib -j2'
txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
if verboseflag:
print(txt.decode("UTF-8"))
# remove source files
# remove source files
print("Removing pace build files and archive ...")
cmd = 'make clean-build'
if not local:
cmd = ('rm %s;' % (download_filename))+cmd
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
print("Removing pace build files and archive ...")
cmd = 'rm %s; make clean-build' % (download_filename)
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)

View File

@ -5,8 +5,14 @@ SHELL = /bin/sh
YAML_CPP_PATH = src/yaml-cpp
YAML_CPP_INC = $(YAML_CPP_PATH)/include
SRC_FILES = $(wildcard src/ML-PACE/*.cpp)
SRC = $(filter-out src/ML-PACE/pair_pace.cpp, $(SRC_FILES))
WIGNER_CPP_INC = src/wigner-cpp/include/wigner
CNPY_CPP_PATH = src/cnpy
CNPY_CPP_INC = $(CNPY_CPP_PATH)
CNPY_SRC_FILES = $(CNPY_CPP_PATH)/cnpy.cpp
SRC_FILES = $(wildcard src/ML-PACE/ace/*.cpp) $(wildcard src/ML-PACE/ace-evaluator/*.cpp)
SRC = $(filter-out src/ML-PACE/pair_pace.cpp, $(SRC_FILES)) $(CNPY_SRC_FILES)
# ------ DEFINITIONS ------
@ -15,7 +21,7 @@ OBJ = $(SRC:.cpp=.o)
# ------ SETTINGS ------
CXXFLAGS = -O3 -fPIC -Isrc/ML-PACE -I$(YAML_CPP_INC)
CXXFLAGS = -O3 -fPIC -Isrc/ML-PACE/ace -Isrc/ML-PACE/ace-evaluator -I$(YAML_CPP_INC) -I$(WIGNER_CPP_INC) -I$(CNPY_CPP_INC) -DEXTRA_C_PROJECTIONS
ARCHIVE = ar
ARCHFLAG = -rc

View File

@ -1,3 +1,3 @@
pace_SYSINC =-I../../lib/pace/src/ML-PACE -I../../lib/pace/src/yaml-cpp/include
pace_SYSINC =-I../../lib/pace/src/ML-PACE/ace -I../../lib/pace/src/ML-PACE/ace-evaluator -I../../lib/pace/src/yaml-cpp/include -I../../lib/pace/src/wigner-cpp/include/wigner -DEXTRA_C_PROJECTIONS
pace_SYSLIB = -L../../lib/pace/ -lpace -L../../lib/pace/src/yaml-cpp/ -lyaml-cpp
pace_SYSPATH =

View File

@ -60,7 +60,7 @@ lmp.command("thermo_style custom step v_emin v_elast pe")
lmp.command("run 0")
x = lmp.extract_atom("x")
lmp.command("variable elast equal $e")
estart = lmp.extract_compute("thermo_pe", LMP_STYLE_GLOBAL, LAMMPS_INT) / natoms
# loop over Monte Carlo moves
@ -92,7 +92,7 @@ for i in range(nloop):
else:
x[iatom][0] = x0
x[iatom][1] = y0
# final energy and stats
lmp.command("variable nbuild equal nbuild")

View File

@ -3,7 +3,7 @@
#
# Copyright (2005) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under
# certain rights in this software. This software is distributed under
# the GNU General Public License.
# for python3 compatibility
@ -19,8 +19,8 @@ g = gl(d) create OpenGL display for data in d
d = atom snapshot object (dump, data)
g.bg("black") set background color (def = "black")
g.size(N) set image size to NxN
g.size(N,M) set image size to NxM
g.size(N) set image size to NxN
g.size(N,M) set image size to NxM
g.rotate(60,135) view from z theta and azimuthal phi (def = 60,30)
g.shift(x,y) translate by x,y pixels in view window (def = 0,0)
g.zoom(0.5) scale image by factor (def = 1)
@ -30,7 +30,7 @@ g.box(0/1/2,"red",4) set box edge thickness
g.file = "image" file prefix for created images (def = "image")
g.show(N) show image of snapshot at timestep N
g.all() make images of all selected snapshots
g.all(P) images of all, start file label at P
g.all(N,M,P) make M images of snapshot N, start label at P
@ -43,12 +43,12 @@ g.pan() no pan during all() (default)
g.select = "$x > %g*3.0" string to pass to d.aselect.test() during all()
g.select = "" no extra aselect (default)
%g varies from 0.0 to 1.0 from beginning to end of all()
g.acol(2,"green") set atom colors by atom type (1-N)
g.acol([2,4],["red","blue"]) 1st arg = one type or list of types
g.acol(0,"blue") 2nd arg = one color or list of colors
g.acol(2,"green") set atom colors by atom type (1-N)
g.acol([2,4],["red","blue"]) 1st arg = one type or list of types
g.acol(0,"blue") 2nd arg = one color or list of colors
g.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
g.acol(range(10),"loop") assign colors in loop, randomly ordered
@ -58,23 +58,23 @@ g.acol(range(10),"loop") assign colors in loop, randomly ordered
g.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol()
g.bcol() set bond color, same args as acol()
g.brad() set bond thickness, same args as arad()
g.bcol() set bond color, same args as acol()
g.brad() set bond thickness, same args as arad()
g.tcol() set triangle color, same args as acol()
g.tfill() set triangle fill, 0 fill, 1 line, 2 both
g.tcol() set triangle color, same args as acol()
g.tfill() set triangle fill, 0 fill, 1 line, 2 both
g.lcol() set line color, same args as acol()
g.lrad() set line thickness, same args as arad()
g.adef() set atom/bond/tri/line properties to default
g.bdef() default = "loop" for colors, 0.45 for radii
g.tdef() default = 0.25 for bond/line thickness
g.ldef() default = 0 fill
g.bdef() default = "loop" for colors, 0.45 for radii
g.tdef() default = 0.25 for bond/line thickness
g.ldef() default = 0 fill
by default 100 types are assigned
if atom/bond/tri/line has type > # defined properties, is an error
from vizinfo import colors access color list
print(colors) list defined color names and RGB values
colors["nickname"] = [R,G,B] set new RGB values from 0 to 255
@ -148,7 +148,7 @@ class gl:
self.azphi = 30
self.scale = 1.0
self.xshift = self.yshift = 0
self.file = "image"
self.boxflag = 0
self.bxcol = [1,1,0]
@ -165,7 +165,7 @@ class gl:
self.nsides = 10
self.theta_amplify = 2
self.shiny = 2
self.clipflag = 0
self.clipxlo = self.clipylo = self.clipzlo = 0.0
self.clipxhi = self.clipyhi = self.clipzhi = 1.0
@ -189,7 +189,7 @@ class gl:
self.bdef()
self.tdef()
self.ldef()
self.center = 3*[0]
self.view = 3*[0]
self.up = 3*[0]
@ -211,7 +211,7 @@ class gl:
if not ynew: self.ypixels = self.xpixels
else: self.ypixels = ynew
self.create_window()
# --------------------------------------------------------------------
def axis(self,value):
@ -223,7 +223,7 @@ class gl:
def create_window(self):
if self.root: self.root.destroy()
from __main__ import tkroot
self.root = Toplevel(tkroot)
self.root.title('Pizza.py gl tool')
@ -232,7 +232,7 @@ class gl:
double=1,depth=1)
self.w.pack(expand=YES)
# self.w.pack(expand=YES,fill=BOTH)
glViewport(0,0,self.xpixels,self.ypixels)
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
@ -247,7 +247,7 @@ class gl:
self.w.parent = self
self.w.tkRedraw()
tkroot.update_idletasks() # force window to appear
# --------------------------------------------------------------------
def clip(self,which,value):
@ -314,7 +314,7 @@ class gl:
self.up[1] = sin(pi*self.azphi/180)
self.up[2] = 0.0
else:
dot = self.view[2] # dot = (0,0,1) . view
dot = self.view[2] # dot = (0,0,1) . view
self.up[0] = -dot*self.view[0] # up projected onto v = dot * v
self.up[1] = -dot*self.view[1] # up perp to v = up - dot * v
self.up[2] = 1.0 - dot*self.view[2]
@ -325,7 +325,7 @@ class gl:
# --------------------------------------------------------------------
# reset ztheta,azphi and thus view,up.right
# called as function from Pizza.py
def rotate(self,ztheta,azphi):
self.ztheta = ztheta
self.azphi = azphi
@ -366,11 +366,11 @@ class gl:
# rotate view,up around axis of rotation = old x new
# right = up x view
# reset ztheta,azphi from view
def mouse_rotate(self,xnew,ynew,xold,yold):
# change y pixels to measure from bottom of window instead of top
yold = self.ypixels - yold
ynew = self.ypixels - ynew
@ -407,7 +407,7 @@ class gl:
axis[1] = rot[0]*self.right[1] + rot[1]*self.up[1] + rot[2]*self.view[1]
axis[2] = rot[0]*self.right[2] + rot[1]*self.up[2] + rot[2]*self.view[2]
axis = vecnorm(axis)
# view is changed by (axis x view) scaled by theta
# up is changed by (axis x up) scaled by theta
# force up to be perp to view via up_perp = up - (up . view) view
@ -468,14 +468,14 @@ class gl:
# output: eye = distance to view scene from
# xto,yto,zto = point to look to
# xfrom,yfrom,zfrom = point to look from
def setview(self):
if not self.ready: return # no distance since no scene yet
self.eye = 3 * self.distance / self.scale
xfactor = 0.5*self.eye*self.xshift/self.xpixels
yfactor = 0.5*self.eye*self.yshift/self.ypixels
self.xto = self.center[0] - xfactor*self.right[0] - yfactor*self.up[0]
self.yto = self.center[1] - xfactor*self.right[1] - yfactor*self.up[1]
self.zto = self.center[2] - xfactor*self.right[2] - yfactor*self.up[2]
@ -486,7 +486,7 @@ class gl:
# --------------------------------------------------------------------
# box attributes, also used for triangle lines
def box(self,*args):
self.boxflag = args[0]
if len(args) > 1:
@ -500,7 +500,7 @@ class gl:
# --------------------------------------------------------------------
# grab all selected snapshots from data object
# add GL-specific info to each bond
def reload(self):
print("Loading data into gl tool ...")
data = self.data
@ -529,7 +529,7 @@ class gl:
self.bondframes.append(bonds)
self.triframes.append(tris)
self.lineframes.append(lines)
print(time,end='')
sys.stdout.flush()
print()
@ -545,11 +545,11 @@ class gl:
def nolabel(self):
self.cachelist = -self.cachelist
self.labels = []
# --------------------------------------------------------------------
# show a single snapshot
# distance from snapshot box or max box for all selected steps
def show(self,ntime):
data = self.data
which = data.findtime(ntime)
@ -571,7 +571,7 @@ class gl:
self.cachelist = -self.cachelist
self.w.tkRedraw()
self.save()
# --------------------------------------------------------------------
def pan(self,*list):
@ -584,7 +584,7 @@ class gl:
self.ztheta_stop = list[3]
self.azphi_stop = list[4]
self.scale_stop = list[5]
# --------------------------------------------------------------------
def all(self,*list):
@ -615,7 +615,7 @@ class gl:
if flag == -1: break
fraction = float(i) / (ncount-1)
if self.select != "":
newstr = self.select % fraction
data.aselect.test(newstr,time)
@ -653,7 +653,7 @@ class gl:
self.cachelist = -self.cachelist
self.w.tkRedraw()
self.save(file)
print(time,end='')
sys.stdout.flush()
i += 1
@ -731,19 +731,19 @@ class gl:
# --------------------------------------------------------------------
# draw the GL scene
def redraw(self,o):
# clear window to background color
glClearColor(self.bgcol[0],self.bgcol[1],self.bgcol[2],0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# not ready if no scene yet
if not self.ready: return
# set view from eye, distance, 3 lookat vectors (from,to,up)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
if self.orthoflag:
@ -759,14 +759,14 @@ class gl:
# draw scene from display list if caching allowed and list hasn't changed
# else redraw and store as new display list if caching allowed
if self.cache and self.cachelist > 0: glCallList(self.cachelist);
else:
if self.cache:
if self.cachelist < 0: glDeleteLists(-self.cachelist,1)
self.cachelist = glGenLists(1)
glNewList(self.cachelist,GL_COMPILE_AND_EXECUTE)
# draw box, clip-box, xyz axes, lines
glDisable(GL_LIGHTING)
@ -842,7 +842,7 @@ class gl:
if self.tridraw:
fillflag = self.vizinfo.tfill[int(self.tridraw[0][1])]
if fillflag != 1:
if fillflag:
glEnable(GL_POLYGON_OFFSET_FILL)
@ -921,7 +921,7 @@ class gl:
gluCylinder(obj,rad,rad,bond[10],self.nsides,self.nsides)
glPopMatrix()
if self.tridraw:
if self.tridraw:
fillflag = self.vizinfo.tfill[int(self.tridraw[0][1])]
if fillflag != 1:
@ -975,7 +975,7 @@ class gl:
glEnd()
glEnable(GL_LIGHTING)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
if self.cache: glEndList()
glFlush()
@ -983,16 +983,16 @@ class gl:
# --------------------------------------------------------------------
# make new call list for each atom type
# called when atom color/rad/quality is changed
def make_atom_calllist(self):
# extend calllist array if necessary
if self.vizinfo.nacolor > self.nclist:
for i in range(self.vizinfo.nacolor-self.nclist): self.calllist.append(0)
self.nclist = self.vizinfo.nacolor
# create new calllist for each atom type
for itype in xrange(1,self.vizinfo.nacolor+1):
if self.calllist[itype]: glDeleteLists(self.calllist[itype],1)
ilist = glGenLists(1)
@ -1001,12 +1001,12 @@ class gl:
red,green,blue = self.vizinfo.acolor[itype]
rad = self.vizinfo.arad[itype]
glColor3f(red,green,blue);
# glPointSize(10.0*rad)
# glBegin(GL_POINTS)
# glVertex3f(0.0,0.0,0.0)
# glEnd()
glMaterialfv(GL_FRONT,GL_EMISSION,[red,green,blue,1.0]);
glMaterialf(GL_FRONT,GL_SHININESS,self.shiny);
glutSolidSphere(rad,self.nslices,self.nstacks)
@ -1015,7 +1015,7 @@ class gl:
# --------------------------------------------------------------------
# augment bond info returned by viz() with info needed for GL draw
# info = length, theta, -dy, dx for bond orientation
def bonds_augment(self,bonds):
for bond in bonds:
dx = bond[5] - bond[2]
@ -1046,7 +1046,7 @@ class gl:
glLineWidth(self.bxthick)
glColor3f(self.bxcol[0],self.bxcol[1],self.bxcol[2])
glBegin(GL_LINE_LOOP)
glVertex3f(xlo,ylo,zlo)
glVertex3f(xhi,ylo,zlo)
@ -1081,7 +1081,7 @@ class gl:
if yhi-ylo > delta: delta = yhi-ylo
if zhi-zlo > delta: delta = zhi-zlo
delta *= 0.1
glLineWidth(self.bxthick)
glBegin(GL_LINES)
@ -1100,7 +1100,7 @@ class gl:
def save(self,file=None):
self.w.update() # force image on screen to be current before saving it
pstring = glReadPixels(0,0,self.xpixels,self.ypixels,
GL_RGBA,GL_UNSIGNED_BYTE)
snapshot = Image.fromstring("RGBA",(self.xpixels,self.ypixels),pstring)
@ -1110,14 +1110,14 @@ class gl:
snapshot.save(file + ".png")
# --------------------------------------------------------------------
def adef(self):
self.vizinfo.setcolors("atom",range(100),"loop")
self.vizinfo.setradii("atom",range(100),0.45)
self.make_atom_calllist()
self.cachelist = -self.cachelist
self.w.tkRedraw()
# --------------------------------------------------------------------
def bdef(self):
@ -1130,14 +1130,14 @@ class gl:
def tdef(self):
self.vizinfo.setcolors("tri",range(100),"loop")
self.vizinfo.setfills("tri",range(100),0)
self.vizinfo.setfills("tri",range(100),0)
self.cachelist = -self.cachelist
self.w.tkRedraw()
# --------------------------------------------------------------------
def ldef(self):
self.vizinfo.setcolors("line",range(100),"loop")
self.vizinfo.setcolors("line",range(100),"loop")
self.vizinfo.setradii("line",range(100),0.25)
self.cachelist = -self.cachelist
self.w.tkRedraw()
@ -1149,29 +1149,29 @@ class gl:
self.make_atom_calllist()
self.cachelist = -self.cachelist
self.w.tkRedraw()
# --------------------------------------------------------------------
def arad(self,atypes,radii):
self.vizinfo.setradii("atom",atypes,radii)
self.vizinfo.setradii("atom",atypes,radii)
self.make_atom_calllist()
self.cachelist = -self.cachelist
self.w.tkRedraw()
# --------------------------------------------------------------------
def bcol(self,btypes,colors):
self.vizinfo.setcolors("bond",btypes,colors)
self.cachelist = -self.cachelist
self.w.tkRedraw()
# --------------------------------------------------------------------
def brad(self,btypes,radii):
self.vizinfo.setradii("bond",btypes,radii)
self.cachelist = -self.cachelist
self.w.tkRedraw()
# --------------------------------------------------------------------
def tcol(self,ttypes,colors):
@ -1210,10 +1210,10 @@ class MyOpengl(Opengl):
args = (self,master,cnf)
Opengl.__init__(*args,**kw)
Opengl.autospin_allowed = 0
# redraw Opengl scene
# call parent redraw() method
def tkRedraw(self,*dummy):
if not self.initialised: return
self.tk.call(self._w,'makecurrent')
@ -1222,7 +1222,7 @@ class MyOpengl(Opengl):
# left button translate
# access parent xshift/yshift and call parent trans() method
def tkTranslate(self,event):
dx = event.x - self.xmouse
dy = event.y - self.ymouse
@ -1242,7 +1242,7 @@ class MyOpengl(Opengl):
# right button zoom
# access parent scale and call parent zoom() method
def tkScale(self,event):
scale = 1 - 0.01 * (event.y - self.ymouse)
if scale < 0.001: scale = 0.001

View File

@ -3,7 +3,7 @@
#
# Copyright (2005) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under
# certain rights in this software. This software is distributed under
# the GNU General Public License.
# vizinfo class, not a top-level Pizza.py tool
@ -25,7 +25,7 @@ import types
class vizinfo:
"""
Information holder for Pizza.py visualization tools
acolor,bcolor,tcolor,lcolor = RGB values for each atom/bond/tri/line type
arad = radius of each atom type
brad,lrad = thickness of each bond/line type
@ -41,7 +41,7 @@ class vizinfo:
setfill() = set triangle fill factor
extend() = grow an array
"""
# --------------------------------------------------------------------
def __init__(self):
@ -57,15 +57,15 @@ class vizinfo:
self.nbcolor = self.nbrad = 0
self.ntcolor = self.ntfill = 0
self.nlcolor = self.nlrad = 0
# --------------------------------------------------------------------
# set color RGB for which = atoms, bonds, triangles
def setcolors(self,which,ids,rgbs):
# convert args into lists if single values
# if arg = 0, convert to full-range list
if type(ids) is types.IntType and ids == 0:
if which == "atom": ids = range(self.nacolor)
if which == "bond": ids = range(self.nbcolor)
@ -101,11 +101,11 @@ class vizinfo:
if max(ids) > self.nlcolor:
self.nlcolor = self.extend(self.lcolor,max(ids))
self.nlcolor = self.extend(self.lrad,max(ids))
# set color for each type
# if list lengths match, set directly, else interpolate
# convert final color from 0-255 to 0.0-1.0
ntypes = len(ids)
nrgbs = len(rgbs)
@ -135,7 +135,7 @@ class vizinfo:
if which == "bond": self.bcolor[id] = color
if which == "tri": self.tcolor[id] = color
if which == "line": self.lcolor[id] = color
# --------------------------------------------------------------------
# set radii for which = atoms, bonds, lines
@ -143,7 +143,7 @@ class vizinfo:
# convert args into lists if single values
# if arg = 0, convert to full-range list
if type(ids) is types.IntType and ids == 0:
if which == "atom": ids = range(self.narad)
if which == "bond": ids = range(self.nbrad)
@ -199,16 +199,16 @@ class vizinfo:
if which == "atom": self.arad[id] = rad
if which == "bond": self.brad[id] = rad
if which == "line": self.lrad[id] = rad
# --------------------------------------------------------------------
# set triangle fill style
# 0 = fill only, 1 = line only, 2 = fill and line
def setfills(self,which,ids,fills):
# convert args into lists if single values
# if arg = 0, convert to full-range list
if type(ids) is types.IntType and ids == 0:
ids = range(self.ntfill)
if type(ids) is not types.ListType and type(ids) is not types.TupleType:
@ -237,7 +237,7 @@ class vizinfo:
for i in range(len(ids)): self.tfill[ids[i]] = int(fills[i])
else:
for id in ids: self.tfill[id] = int(fills[0])
# --------------------------------------------------------------------
def extend(self,array,n):

View File

@ -3,7 +3,7 @@
#
# Copyright (2005) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under
# certain rights in this software. This software is distributed under
# the GNU General Public License.
# for python3 compatibility
@ -20,24 +20,24 @@ from __future__ import print_function
oneline = "Control VMD from python"
docstr = """
v = vmd() start up VMD
v.stop() shut down VMD instance
v.clear() delete all visualizations
v = vmd() start up VMD
v.stop() shut down VMD instance
v.clear() delete all visualizations
v.rep(style) set default representation style. One of
(Lines|VDW|Licorice|DynamicBonds|Points|CPK)
v.new(file[,type]) load new file (default file type 'lammpstrj')
v.rep(style) set default representation style. One of
(Lines|VDW|Licorice|DynamicBonds|Points|CPK)
v.new(file[,type]) load new file (default file type 'lammpstrj')
v.data(file[,atomstyle]) load new data file (default atom style 'full')
v.replace(file[,type]) replace current frames with new file
v.append(file[,type]) append file to current frame(s)
v.replace(file[,type]) replace current frames with new file
v.append(file[,type]) append file to current frame(s)
v.set(snap,x,y,z,(True|False)) set coordinates from a pizza.py snapshot to new or current frame
v.frame(frame) set current frame
v.flush() flush pending input to VMD and update GUI
v.read(file) read Tcl script file (e.g. saved state)
v.enter() enter interactive shell
v.debug([True|False]) display generated VMD script commands?
v.frame(frame) set current frame
v.flush() flush pending input to VMD and update GUI
v.read(file) read Tcl script file (e.g. saved state)
v.enter() enter interactive shell
v.debug([True|False]) display generated VMD script commands?
"""
# History
@ -71,7 +71,7 @@ except ImportError:
# Class definition
class vmd:
# --------------------------------------------------------------------
def __init__(self):
@ -103,7 +103,7 @@ class vmd:
# open pipe to vmd and wait until we have a prompt
self.VMD = pexpect.spawn(self.vmdexe)
self.VMD.expect('vmd >')
# --------------------------------------------------------------------
# post command to vmd and wait until the prompt returns.
def __call__(self,command):
@ -113,7 +113,7 @@ class vmd:
if self.debugme:
print("call+result:"+self.VMD.before)
return
# --------------------------------------------------------------------
# exit VMD
def stop(self):
@ -198,7 +198,7 @@ class vmd:
self.__call__('mol addfile ' + filename + ' mol $tmol type ' + filetype + ' waitfor all')
self.__call__('foreach mol [molinfo list] { molinfo $mol set {center_matrix rotate_matrix scale_matrix global_matrix} $viewpoints($mol)}')
self.flush()
# --------------------------------------------------------------------
# replace all frames of a molecule with those from a given file
def update(self,filename,filetype='lammpstrj'):
@ -209,7 +209,7 @@ class vmd:
self.__call__('mol addfile ' + filename + ' mol $tmol type ' + filetype + ' waitfor all')
self.__call__('foreach mol [molinfo list] {molinfo $mol set {center_matrix rotate_matrix scale_matrix global_matrix} $viewpoints($mol)}')
self.flush()
# --------------------------------------------------------------------
# add or overwrite coordinates with coordinates in a snapshot
def set(self,snap,x,y,z,append=True):

View File

@ -1,4 +1,4 @@
conversion of lammps scripts to python code using PyLammps interface
Example for elastic.py
Example for elastic.py
python elastic.py Au.data EAM_Dynamo_Ackland_1987_Au__MO_754413982908_000 Au

View File

@ -32,7 +32,7 @@ nprocs = comm.Get_size()
if me < nprocs // 2: color = 0
else: color = 1
split = comm.Split(color,key=0)
if color == 0:
@ -69,12 +69,12 @@ else:
# could run a 2nd calculation on second partition
# with different LAMMPS instance or another code
# in this case, just sleep on second partition
import time
time.sleep(2)
print("Calculation on partition 1 complete")
# shutdown mpi4py
comm.Barrier()
MPI.Finalize()

View File

@ -50,7 +50,7 @@ ntimestep = 0
if me == 0:
tkroot = None
try:
try:
import Tkinter
except:
import tkinter as Tkinter

View File

@ -63,7 +63,7 @@ if me == 0:
p.single(ntimestep)
pm.load("tmp.pdb")
pm.show("spheres","tmp")
# run nfreq steps at a time w/out pre/post, read dump snapshot, display it
while ntimestep < nsteps:
@ -75,7 +75,7 @@ while ntimestep < nsteps:
p.single(ntimestep)
pm.load("tmp.pdb")
pm.forward()
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via mpi4py

View File

@ -22,7 +22,8 @@ LAMMPS_INT64 = 4
LAMMPS_INT64_2D = 5
LAMMPS_STRING = 6
# these must be kept in sync with the enums in library.h
# these must be kept in sync with the enums in src/library.h, tools/swig/lammps.i
# and the constants in fortran/lammps.f90
LMP_STYLE_GLOBAL = 0
LMP_STYLE_ATOM = 1
LMP_STYLE_LOCAL = 2
@ -42,6 +43,8 @@ LMP_ERROR_UNIVERSE = 8
LMP_VAR_EQUAL = 0
LMP_VAR_ATOM = 1
LMP_VAR_VECTOR = 2
LMP_VAR_STRING = 3
# -------------------------------------------------------------------------

View File

@ -301,6 +301,8 @@ class lammps(object):
self.lib.lammps_extract_fix.argtypes = [c_void_p, c_char_p, c_int, c_int, c_int, c_int]
self.lib.lammps_extract_variable.argtypes = [c_void_p, c_char_p, c_char_p]
self.lib.lammps_extract_variable_datatype.argtypes = [c_void_p, c_char_p]
self.lib.lammps_extract_variable_datatype.restype = c_int
self.lib.lammps_fix_external_get_force.argtypes = [c_void_p, c_char_p]
self.lib.lammps_fix_external_get_force.restype = POINTER(POINTER(c_double))
@ -1083,21 +1085,23 @@ class lammps(object):
# for vector, must copy nlocal returned values to local c_double vector
# memory was allocated by library interface function
def extract_variable(self, name, group=None, vartype=LMP_VAR_EQUAL):
def extract_variable(self, name, group=None, vartype=None):
""" Evaluate a LAMMPS variable and return its data
This function is a wrapper around the function
:cpp:func:`lammps_extract_variable` of the C-library interface,
:cpp:func:`lammps_extract_variable` of the C library interface,
evaluates variable name and returns a copy of the computed data.
The memory temporarily allocated by the C-interface is deleted
after the data is copied to a Python variable or list.
The variable must be either an equal-style (or equivalent)
variable or an atom-style variable. The variable type has to
provided as ``vartype`` parameter which may be one of two constants:
``LMP_VAR_EQUAL`` or ``LMP_VAR_ATOM``; it defaults to
equal-style variables.
The group parameter is only used for atom-style variables and
defaults to the group "all" if set to ``None``, which is the default.
variable or an atom-style variable. The variable type can be
provided as the ``vartype`` parameter, which may be one of several
constants: ``LMP_VAR_EQUAL``, ``LMP_VAR_ATOM``, ``LMP_VAR_VECTOR``,
or ``LMP_VAR_STRING``. If omitted or ``None``, LAMMPS will determine its
value for you based on a call to
:cpp:func:`lammps_extract_variable_datatype` from the C library interface.
The group parameter is only used for atom-style variables and defaults to
the group "all".
:param name: name of the variable to execute
:type name: string
@ -1111,6 +1115,8 @@ class lammps(object):
if name: name = name.encode()
else: return None
if group: group = group.encode()
if vartype is None :
vartype = self.lib.lammps_extract_variable_datatype(self.lmp, name)
if vartype == LMP_VAR_EQUAL:
self.lib.lammps_extract_variable.restype = POINTER(c_double)
with ExceptionCheck(self):
@ -1130,6 +1136,31 @@ class lammps(object):
self.lib.lammps_free(ptr)
else: return None
return result
elif vartype == LMP_VAR_VECTOR :
nvector = 0
self.lib.lammps_extract_variable.restype = POINTER(c_int)
ptr = self.lib.lammps_extract_variable(self.lmp,name,
'LMP_SIZE_VECTOR'.encode())
if ptr :
nvector = ptr[0]
self.lib.lammps_free(ptr)
else :
return None
self.lib.lammps_extract_variable.restype = POINTER(c_double)
result = (c_double*nvector)()
values = self.lib.lammps_extract_variable(self.lmp,name,group)
if values :
for i in range(nvector) :
result[i] = values[i]
# do NOT free the values pointer (points to internal vector data)
return result
else :
return None
elif vartype == LMP_VAR_STRING :
self.lib.lammps_extract_variable.restype = c_char_p
with ExceptionCheck(self) :
ptr = self.lib.lammps_extract_variable(self.lmp, name, group)
return ptr.decode('utf-8')
return None
# -------------------------------------------------------------------------

View File

@ -1,3 +1,3 @@
[build-system]
requires = [ "setuptools>=42", "wheel" ]
requires = [ "setuptools>=42", "wheel", "build" ]
build-backend = "setuptools.build_meta"

View File

@ -6,7 +6,7 @@ SHELL = /bin/sh
# compiler/linker settings
# specify flags and libraries needed for your compiler
CC = mpiicpc -std=c++11
CC = mpiicpc -std=c++11 -diag-disable=10441 -diag-disable=2196
OPTFLAGS = -xHost -O2 -fp-model fast=2 -no-prec-div -qoverride-limits \
-qopt-zmm-usage=high
CCFLAGS = -qopenmp -qno-offload -ansi-alias -restrict \
@ -15,9 +15,9 @@ CCFLAGS = -qopenmp -qno-offload -ansi-alias -restrict \
SHFLAGS = -fPIC
DEPFLAGS = -M
LINK = mpiicpc -std=c++11
LINK = mpiicpc -std=c++11 -diag-disable=10441 -diag-disable=2196
LINKFLAGS = -qopenmp $(OPTFLAGS) -L$(MKLROOT)/lib/intel64/
LIB = -ltbbmalloc -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core
LIB = -ltbbmalloc -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core
SIZE = size
ARCHIVE = ar

View File

@ -6,7 +6,7 @@ SHELL = /bin/sh
# compiler/linker settings
# specify flags and libraries needed for your compiler
CC = mpicxx -cxx=icc -std=c++11
CC = mpicxx -cxx=icc -std=c++11 -diag-disable=10441 -diag-disable=2196
OPTFLAGS = -xHost -O2 -fp-model fast=2 -no-prec-div -qoverride-limits \
-qopt-zmm-usage=high
CCFLAGS = -qopenmp -qno-offload -ansi-alias -restrict \
@ -15,7 +15,7 @@ CCFLAGS = -qopenmp -qno-offload -ansi-alias -restrict \
SHFLAGS = -fPIC
DEPFLAGS = -M
LINK = mpicxx -cxx=icc -std=c++11
LINK = mpicxx -cxx=icc -std=c++11 -diag-disable=10441 -diag-disable=2196
LINKFLAGS = -qopenmp $(OPTFLAGS) -L$(MKLROOT)/lib/intel64/
LIB = -ltbbmalloc -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core
SIZE = size

View File

@ -7,7 +7,7 @@ SHELL = /bin/sh
# specify flags and libraries needed for your compiler
export OMPI_CXX = icc
CC = mpicxx -std=c++11
CC = mpicxx -std=c++11 -diag-disable=10441 -diag-disable=2196
OPTFLAGS = -xHost -O2 -fp-model fast=2 -no-prec-div -qoverride-limits \
-qopt-zmm-usage=high
CCFLAGS = -qopenmp -qno-offload -ansi-alias -restrict \
@ -16,7 +16,7 @@ CCFLAGS = -qopenmp -qno-offload -ansi-alias -restrict \
SHFLAGS = -fPIC
DEPFLAGS = -M
LINK = mpicxx -std=c++11
LINK = mpicxx -std=c++11 -diag-disable=10441 -diag-disable=2196
LINKFLAGS = -qopenmp $(OPTFLAGS) -L$(MKLROOT)/lib/intel64/
LIB = -ltbbmalloc -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core
SIZE = size

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