Merge branch 'progguide-updates' into progguide-richard

This commit is contained in:
Axel Kohlmeyer
2020-10-05 19:31:03 -04:00
53 changed files with 646 additions and 748 deletions

4
.github/CODEOWNERS vendored
View File

@ -114,6 +114,7 @@ src/info.* @akohlmey @rbberger
src/timer.* @akohlmey src/timer.* @akohlmey
src/min* @sjplimp @stanmoore1 src/min* @sjplimp @stanmoore1
src/utils.* @akohlmey @rbberger src/utils.* @akohlmey @rbberger
src/math_eigen_impl.h @jewettaij
# tools # tools
tools/msi2lmp/* @akohlmey tools/msi2lmp/* @akohlmey
@ -134,6 +135,9 @@ cmake/presets/*.cmake @junghans @rbberger @akohlmey
# python # python
python/* @rbberger python/* @rbberger
# fortran
fortran/* @akohlmey
# docs # docs
doc/utils/*/* @rbberger doc/utils/*/* @rbberger
doc/Makefile @rbberger doc/Makefile @rbberger

View File

@ -343,20 +343,22 @@ find_program(GZIP_EXECUTABLE gzip)
find_package_handle_standard_args(GZIP REQUIRED_VARS GZIP_EXECUTABLE) find_package_handle_standard_args(GZIP REQUIRED_VARS GZIP_EXECUTABLE)
option(WITH_GZIP "Enable GZIP support" ${GZIP_FOUND}) option(WITH_GZIP "Enable GZIP support" ${GZIP_FOUND})
if(WITH_GZIP) if(WITH_GZIP)
if(NOT GZIP_FOUND) if(GZIP_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING))
target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP)
else()
message(FATAL_ERROR "gzip executable not found") message(FATAL_ERROR "gzip executable not found")
endif() endif()
target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP)
endif() endif()
find_program(FFMPEG_EXECUTABLE ffmpeg) find_program(FFMPEG_EXECUTABLE ffmpeg)
find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_EXECUTABLE) find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_EXECUTABLE)
option(WITH_FFMPEG "Enable FFMPEG support" ${FFMPEG_FOUND}) option(WITH_FFMPEG "Enable FFMPEG support" ${FFMPEG_FOUND})
if(WITH_FFMPEG) if(WITH_FFMPEG)
if(NOT FFMPEG_FOUND) if(FFMPEG_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING))
target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG)
else()
message(FATAL_ERROR "ffmpeg executable not found") message(FATAL_ERROR "ffmpeg executable not found")
endif() endif()
target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG)
endif() endif()
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)

View File

@ -1,7 +1,8 @@
# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes) # preset that will enable Intel compilers with support for MPI and OpenMP (on Linux boxes)
set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE)
set(CMAKE_Fortran_COMPILER "ifort" CACHE STRING "" FORCE)
set(MPI_CXX "icpc" CACHE STRING "" FORCE) set(MPI_CXX "icpc" CACHE STRING "" FORCE)
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE) unset(HAVE_OMP_H_INCLUDE CACHE)
@ -12,5 +13,6 @@ set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_CXX "icpc" CACHE STRING "" FORCE) set(OpenMP_CXX "icpc" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-qopenmp" CACHE STRING "" FORCE) set(OpenMP_CXX_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_Fortran_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE) set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE)

File diff suppressed because it is too large Load Diff

View File

@ -159,11 +159,11 @@ others (e.g. GCC version 9 and beyond, Clang version 10 and later) may
implement strict OpenMP 4.0 and later semantics, which are incompatible implement strict OpenMP 4.0 and later semantics, which are incompatible
with the OpenMP 3.1 semantics used in LAMMPS for maximal compatibility with the OpenMP 3.1 semantics used in LAMMPS for maximal compatibility
with compiler versions in use. If compilation with OpenMP enabled fails with compiler versions in use. If compilation with OpenMP enabled fails
because of your compiler requiring strict OpenMP 4.0 semantic, you can because of your compiler requiring strict OpenMP 4.0 semantics, you can
change the behavior by adding ``-D LAMMPS_OMP_COMPAT=4`` to the change the behavior by adding ``-D LAMMPS_OMP_COMPAT=4`` to the
``LMP_INC`` variable in your makefile, or add it to the command line ``LMP_INC`` variable in your makefile, or add it to the command line
while configuring with CMake. CMake will detect the suitable setting for while configuring with CMake. LAMMPS will auto-detect a suitable setting
the GNU, Clang, and Intel compilers. for most GNU, Clang, and Intel compilers.
---------- ----------

View File

@ -3005,9 +3005,6 @@ Doc page with :doc:`WARNING messages <Errors_warnings>`
*Dump image line requires atom style line* *Dump image line requires atom style line*
Self-explanatory. Self-explanatory.
*Dump image persp option is not yet supported*
Self-explanatory.
*Dump image requires one snapshot per file* *Dump image requires one snapshot per file*
Use a "\*" in the filename. Use a "\*" in the filename.
@ -5108,9 +5105,6 @@ Doc page with :doc:`WARNING messages <Errors_warnings>`
The file produced by dump image cannot be binary and must The file produced by dump image cannot be binary and must
be for a single processor. be for a single processor.
*Invalid dump image persp value*
Persp value must be >= 0.0.
*Invalid dump image theta value* *Invalid dump image theta value*
Theta must be between 0.0 and 180.0 inclusive. Theta must be between 0.0 and 180.0 inclusive.
@ -8116,9 +8110,6 @@ keyword to allow for additional bonds to be formed
*Variable for dump image center is invalid style* *Variable for dump image center is invalid style*
Must be an equal-style variable. Must be an equal-style variable.
*Variable for dump image persp is invalid style*
Must be an equal-style variable.
*Variable for dump image phi is invalid style* *Variable for dump image phi is invalid style*
Must be an equal-style variable. Must be an equal-style variable.
@ -8259,9 +8250,6 @@ keyword to allow for additional bonds to be formed
*Variable name for dump image center does not exist* *Variable name for dump image center does not exist*
Self-explanatory. Self-explanatory.
*Variable name for dump image persp does not exist*
Self-explanatory.
*Variable name for dump image phi does not exist* *Variable name for dump image phi does not exist*
Self-explanatory. Self-explanatory.

View File

@ -12,14 +12,20 @@ Note that each installer package has a date in its name, which
corresponds to the LAMMPS version of the same date. Installers for corresponds to the LAMMPS version of the same date. Installers for
current and older versions of LAMMPS are available. 32-bit and 64-bit current and older versions of LAMMPS are available. 32-bit and 64-bit
installers are available, and each installer contains both a serial installers are available, and each installer contains both a serial
and parallel executable. The installer site also explains how to and parallel executable. The installer web site also explains how to
install the Windows MPI package (MPICH2 from Argonne National Labs), install the Windows MPI package (MPICH2 from Argonne National Labs),
needed to run in parallel. needed to run in parallel.
The LAMMPS binaries contain all optional packages included in the The LAMMPS binaries contain *all* :doc:`optional packages <Packages>`
source distribution except: KIM, KOKKOS, USER-INTEL, and USER-QMMM. included in the source distribution except: KIM, KOKKOS, MSCG, PYTHON,
USER-ADIOS, USER-H5MD, USER-NETCDF, USER-QMMM, USER-QUIP, and USER-VTK.
The serial version also does not include the MPIIO and The serial version also does not include the MPIIO and
USER-LB packages. GPU support is provided for OpenCL. USER-LB packages. The GPU package is compiled for OpenCL with
mixed precision kernels.
The LAMMPS library is compiled as a shared library and the
:doc:`LAMMPS Python module <Python_module>` is installed, so that
it is possible to load LAMMPS into a Python interpreter.
The installer site also has instructions on how to run LAMMPS under The installer site also has instructions on how to run LAMMPS under
Windows, once it is installed, in both serial and parallel. Windows, once it is installed, in both serial and parallel.
@ -42,5 +48,3 @@ install multiple versions of LAMMPS (in different directories), but
only the executable for the last-installed package will be found only the executable for the last-installed package will be found
automatically, so this should only be done for debugging purposes. automatically, so this should only be done for debugging purposes.
Thanks to Axel Kohlmeyer (Temple U, akohlmey at gmail.com) for setting
up this Windows capability.

View File

@ -9,15 +9,15 @@ script <Python_head>`. Even the LAMMPS standalone executable is
essentially a thin wrapper on top of the LAMMPS library, creating a essentially a thin wrapper on top of the LAMMPS library, creating a
LAMMPS instance, processing input and then existing. LAMMPS instance, processing input and then existing.
Several of these approaches are based on C language wrapper functions Most of the APIs described below are based on C language wrapper
in the files ``src/library.h`` and ``src/library.cpp``, but it is also functions in the files ``src/library.h`` and ``src/library.cpp``, but
possible to use C++ directly. The basic procedure is always the same: it is also possible to use C++ directly. The basic procedure is
you create one or more instances of the always the same: you create one or more instances of
:cpp:class:`LAMMPS <LAMMPS_NS::LAMMPS>` and then pass commands as :cpp:class:`LAMMPS <LAMMPS_NS::LAMMPS>`, pass commands as strings or
strings or from files to that LAMMPS instance to execute calculations, from files to that LAMMPS instance to execute calculations, and/or
or read, manipulate, and update data from the active class instances call functions that read, manipulate, and update data from the active
inside the LAMMPS to do analysis or perform operations that are not class instances inside LAMMPS to do analysis or perform operations
possible with existing commands. that are not possible with existing input script commands.
.. _thread-safety: .. _thread-safety:
@ -36,13 +36,13 @@ possible with existing commands.
Another major issue to deal with is to correctly handle MPI. Another major issue to deal with is to correctly handle MPI.
Creating a LAMMPS instance requires passing an MPI communicator, or Creating a LAMMPS instance requires passing an MPI communicator, or
it assumes the ``MPI_COMM_WORLD`` communicator, which spans all MPI it assumes the ``MPI_COMM_WORLD`` communicator, which spans all MPI
processor ranks. When creating multiple LAMMPS object instances from processor ranks. When creating multiple LAMMPS object instances
different threads, this communicator has to be different for each from different threads, this communicator has to be different for
thread or else collisions can happen. or it has to be guaranteed, each thread or else collisions can happen. Or it has to be
that only one thread at a time is active. MPI communicators, guaranteed, that only one thread at a time is active. MPI
however, are not a problem, if LAMMPS is compiled with the MPI STUBS communicators, however, are not a problem, if LAMMPS is compiled
library, which implies that there is no MPI communication and only 1 with the MPI STUBS library, which implies that there is no MPI
MPI rank. communication and only 1 MPI rank.
---------- ----------
@ -51,7 +51,7 @@ possible with existing commands.
LAMMPS C Library API LAMMPS C Library API
==================== ====================
The C library interface is most commonly used path to manage LAMMPS The C library interface is the most commonly used path to manage LAMMPS
instances from a compiled code and it is the basis for the :doc:`Python instances from a compiled code and it is the basis for the :doc:`Python
<Python_module>` and :doc:`Fortran <Fortran>` modules. Almost all <Python_module>` and :doc:`Fortran <Fortran>` modules. Almost all
functions of the C language API require an argument containing a functions of the C language API require an argument containing a
@ -64,7 +64,7 @@ library interface. This usually must be the header from the same MPI
library as the LAMMPS library was compiled with. The exception is when library as the LAMMPS library was compiled with. The exception is when
LAMMPS was compiled in serial mode using the ``STUBS`` MPI library. In LAMMPS was compiled in serial mode using the ``STUBS`` MPI library. In
that case the calling code may be compiled with a different MPI library that case the calling code may be compiled with a different MPI library
for as long as :cpp:func:`lammps_open_no_mpi` is called to create a so long as :cpp:func:`lammps_open_no_mpi` is called to create a
LAMMPS instance. Then you may set the define ``-DLAMMPS_LIB_NO_MPI`` LAMMPS instance. Then you may set the define ``-DLAMMPS_LIB_NO_MPI``
when compiling your code and the inclusion of ``mpi.h`` will be skipped when compiling your code and the inclusion of ``mpi.h`` will be skipped
and consequently the function :cpp:func:`lammps_open` may not be used. and consequently the function :cpp:func:`lammps_open` may not be used.
@ -72,7 +72,7 @@ and consequently the function :cpp:func:`lammps_open` may not be used.
.. admonition:: Errors versus exceptions .. admonition:: Errors versus exceptions
:class: note :class: note
If any of the function calls in the LAMMPS library API will trigger If any of the function calls in the LAMMPS library API trigger
an error inside LAMMPS, this will result in an abort of the entire an error inside LAMMPS, this will result in an abort of the entire
program. This is not always desirable. Instead, LAMMPS can be program. This is not always desirable. Instead, LAMMPS can be
compiled to instead :ref:`throw a C++ exception <exceptions>`. compiled to instead :ref:`throw a C++ exception <exceptions>`.
@ -81,7 +81,7 @@ and consequently the function :cpp:func:`lammps_open` may not be used.
No checks are made on the arguments of the function calls of the C No checks are made on the arguments of the function calls of the C
library interface. *All* function arguments must be non-NULL unless library interface. *All* function arguments must be non-NULL unless
*explicitly* allowed and point to consistent and valid data. Buffers *explicitly* allowed, and must point to consistent and valid data. Buffers
for storing returned data must be allocated to a suitable size. for storing returned data must be allocated to a suitable size.
Passing invalid or unsuitable information will likely cause crashes Passing invalid or unsuitable information will likely cause crashes
or corrupt data. or corrupt data.
@ -113,10 +113,10 @@ Python by dynamically loading functions in the LAMMPS shared library through
the `Python ctypes module <https://docs.python.org/3/library/ctypes.html>`_. the `Python ctypes module <https://docs.python.org/3/library/ctypes.html>`_.
Because of the dynamic loading, it is **required** that LAMMPS is compiled Because of the dynamic loading, it is **required** that LAMMPS is compiled
in :ref:`"shared" mode <exe>`. The Python interface is object oriented, but in :ref:`"shared" mode <exe>`. The Python interface is object oriented, but
otherwise trying to be very similar to the C library API. Three different otherwise tries to be very similar to the C library API. Three different
Python classes to run LAMMPS are available and they build on each other. Python classes to run LAMMPS are available and they build on each other.
More information on this is in the :doc:`Python_head` More information on this is in the :doc:`Python_head`
section of the manual and for using the LAMMPS Python modules is in section of the manual. Use of the LAMMPS Python module is described in
:doc:`Python_module`. :doc:`Python_module`.
------------------- -------------------
@ -127,8 +127,8 @@ LAMMPS Fortran API
================== ==================
The LAMMPS Fortran module is a wrapper around calling functions from the The LAMMPS Fortran module is a wrapper around calling functions from the
LAMMPS C library API from Fortran through the ISO_C_BINDING feature in LAMMPS C library API. This is done using the ISO_C_BINDING feature in
Fortran 2003. The interface is object oriented but otherwise trying to Fortran 2003. The interface is object oriented but otherwise tries to
be very similar to the C library API and the basic Python module. be very similar to the C library API and the basic Python module.
.. toctree:: .. toctree::
@ -144,8 +144,8 @@ LAMMPS C++ API
============== ==============
It is also possible to invoke the LAMMPS C++ API directly in your code. It is also possible to invoke the LAMMPS C++ API directly in your code.
It is lacking some of the convenience of the C library API, but it allows It lacks some of the convenience of the C library API, but it allows
a more direct access to simulation data and thus more low-level manipulations. more direct access to simulation data and thus more low-level manipulations.
The following links provide some examples and references to the C++ API. The following links provide some examples and references to the C++ API.
.. toctree:: .. toctree::

View File

@ -2,11 +2,11 @@ Adding code to the Library interface
==================================== ====================================
The functionality of the LAMMPS library interface has historically The functionality of the LAMMPS library interface has historically
always been motivated by the needs of its users and functions were been motivated by the needs of its users. Functions have been added
added or expanded as they were needed and used. Contributions to or expanded as they were needed and used. Contributions to the
the interface are always welcome. However with a refactoring of interface are always welcome. However with a refactoring of the
the library interface and its documentation that started in 2020, library interface and its documentation that started in 2020, there
there are now a few requirements for inclusion of changes. are now a few requirements for including new changes or extensions.
- New functions should be orthogonal to existing ones and not - New functions should be orthogonal to existing ones and not
implement functionality that can already be achieved with the implement functionality that can already be achieved with the
@ -17,17 +17,18 @@ there are now a few requirements for inclusion of changes.
``doc/src`` folder. ``doc/src`` folder.
- If possible, new unit tests to test those new features should - If possible, new unit tests to test those new features should
be added. be added.
- The new feature should also be implemented and documented for - The new feature should also be implemented and documented not
the Python and Fortran modules. just for the C interface, but also the Python and Fortran interfaces.
- All additions should work and be compatible with ``-DLAMMPS_BIGBIG``, - All additions should work and be compatible with ``-DLAMMPS_BIGBIG``,
``-DLAMMPS_SMALLBIG``, ``-DLAMMPS_SMALLSMALL`` and compiling ``-DLAMMPS_SMALLBIG``, ``-DLAMMPS_SMALLSMALL`` and when compiling
with and without MPI support. with and without MPI support.
- The ``library.h`` file should be kept compatible to C code at - The ``library.h`` file should be kept compatible to C code at
a level similar to C89. Its interfaces may not reference any a level similar to C89. Its interfaces may not reference any
custom data types (e.g. ``bigint``, ``tagint``, and so on) only custom data types (e.g. ``bigint``, ``tagint``, and so on) that
known inside of LAMMPS. are only known inside of LAMMPS.
- only C style comments, not C++ style - only use C style comments, not C++ style
Please note that these are *not* *strict* requirements, but the LAMMPS
developers appreciate if they are followed and can assist with
implementing what is missing.
Please note, that these are *not* *strict* requirements, but the
LAMMPS developers appreciate if they are followed closely and will
assist with implementing what is missing.

View File

@ -1,18 +1,35 @@
Retrieving LAMMPS configuration information Retrieving LAMMPS configuration information
=========================================== ===========================================
The following library functions can be used to query the LAMMPS library This section documents the following functions:
about compile time settings and included packages and styles. This
enables programs that use the library interface to run LAMMPS - :cpp:func:`lammps_config_has_mpi_support`
simulations to determine, whether the linked LAMMPS library is compatible - :cpp:func:`lammps_config_has_gzip_support`
with the requirements of the application without crashing during the - :cpp:func:`lammps_config_has_png_support`
LAMMPS functions (e.g. due to missing pair styles from packages) or to - :cpp:func:`lammps_config_has_jpeg_support`
choose between different options (e.g. whether to use ``lj/cut``, - :cpp:func:`lammps_config_has_ffmpeg_support`
``lj/cut/opt``, ``lj/cut/omp`` or ``lj/cut/intel``). Most of the - :cpp:func:`lammps_config_has_exceptions`
functions can be called directly without first creating a LAMMPS - :cpp:func:`lammps_config_has_package`
instance. While crashes within LAMMPS may be recovered from through - :cpp:func:`lammps_config_package_count`
enabling :ref:`exceptions <exceptions>`, avoiding them proactively is - :cpp:func:`lammps_config_package_name`
a safer approach. - :cpp:func:`lammps_has_style`
- :cpp:func:`lammps_style_count`
- :cpp:func:`lammps_style_name`
--------------------
These library functions can be used to query the LAMMPS library for
compile time settings and included packages and styles. This enables
programs that use the library interface to determine whether the
linked LAMMPS library is compatible with the requirements of the
application without crashing during the LAMMPS functions (e.g. due to
missing pair styles from packages) or to choose between different
options (e.g. whether to use ``lj/cut``, ``lj/cut/opt``,
``lj/cut/omp`` or ``lj/cut/intel``). Most of the functions can be
called directly without first creating a LAMMPS instance. While
crashes within LAMMPS may be recovered from by enabling
:ref:`exceptions <exceptions>`, avoiding them proactively is a safer
approach.
.. code-block:: C .. code-block:: C
:caption: Example for using configuration settings functions :caption: Example for using configuration settings functions

View File

@ -1,13 +1,24 @@
Creating or deleting a LAMMPS object Creating or deleting a LAMMPS object
==================================== ====================================
The :cpp:func:`lammps_open` and :cpp:func:`lammps_open_no_mpi` This section documents the following functions:
functions are used to create and initialize a
:cpp:func:`LAMMPS` instance. The calling program has to - :cpp:func:`lammps_open`
provide a handle where a reference to this instance can be stored and - :cpp:func:`lammps_open_no_mpi`
which has to be used in all subsequent function calls until that - :cpp:func:`lammps_open_fortran`
instance is destroyed by calling :cpp:func:`lammps_close`. - :cpp:func:`lammps_close`
Here is a simple example demonstrating its use: - :cpp:func:`lammps_mpi_init`
- :cpp:func:`lammps_mpi_finalize`
- :cpp:func:`lammps_free`
--------------------
The :cpp:func:`lammps_open` and :cpp:func:`lammps_open_no_mpi` functions
are used to create and initialize a :cpp:func:`LAMMPS` instance. They
return a reference to this instance as a ``void *`` pointer to be used
as the "handle" argument in subsequent function calls until that
instance is destroyed by calling :cpp:func:`lammps_close`. Here is a
simple example demonstrating its use:
.. code-block:: C .. code-block:: C
@ -39,29 +50,30 @@ Here is a simple example demonstrating its use:
return 0; return 0;
} }
The LAMMPS library will be using the MPI library it was compiled with The LAMMPS library uses the MPI library it was compiled with and will
and will either run on all processors in the ``MPI_COMM_WORLD`` either run on all processors in the ``MPI_COMM_WORLD`` communicator or
communicator or on the set of processors in the communicator given in on the set of processors in the communicator passed as the ``comm``
the ``comm`` argument of :cpp:func:`lammps_open`. This means argument of :cpp:func:`lammps_open`. This means the calling code can
the calling code can run LAMMPS on all or a subset of processors. For run LAMMPS on all or a subset of processors. For example, a wrapper
example, a wrapper code might decide to alternate between LAMMPS and code might decide to alternate between LAMMPS and another code, allowing
another code, allowing them both to run on all the processors. Or it them both to run on all the processors. Or it might allocate part of
might allocate part of the processors to LAMMPS and the rest to the the processors to LAMMPS and the rest to the other code by creating a
other code by creating a custom communicator with ``MPI_Comm_split()`` custom communicator with ``MPI_Comm_split()`` and running both codes
and running both codes concurrently before syncing them up periodically. concurrently before syncing them up periodically. Or it might
Or it might instantiate multiple instances of LAMMPS to perform instantiate multiple instances of LAMMPS to perform different
different calculations and either alternate between them, run them calculations and either alternate between them, run them concurrently on
concurrently on split communicators, or run them one after the other. split communicators, or run them one after the other. The
The :cpp:func:`lammps_open` function may be called multiple :cpp:func:`lammps_open` function may be called multiple times for this
times for this latter purpose. latter purpose.
The :cpp:func:`lammps_close` function is used to shut down The :cpp:func:`lammps_close` function is used to shut down the
the :cpp:class:`LAMMPS <LAMMPS_NS::LAMMPS>` class pointed to by the handle :cpp:class:`LAMMPS <LAMMPS_NS::LAMMPS>` class pointed to by the handle
passed as an argument and free all its memory. This has to be called for passed as an argument and free all its memory. This has to be called
every instance created with any of the :cpp:func:`lammps_open` functions. It will, however, **not** call for every instance created with one of the :cpp:func:`lammps_open`
``MPI_Finalize()``, since that may only be called once. See functions. It will, however, **not** call ``MPI_Finalize()``, since
:cpp:func:`lammps_mpi_finalize` for an alternative to calling that may only be called once. See :cpp:func:`lammps_mpi_finalize` for
``MPI_Finalize()`` explicitly in the calling program. an alternative to invoking ``MPI_Finalize()`` explicitly from the
calling program.
The :cpp:func:`lammps_free` function is a clean-up The :cpp:func:`lammps_free` function is a clean-up
function to free memory that the library allocated previously function to free memory that the library allocated previously

View File

@ -1,25 +1,34 @@
Executing LAMMPS commands Executing LAMMPS commands
========================= =========================
This section documents the following functions:
- :cpp:func:`lammps_file`
- :cpp:func:`lammps_command`
- :cpp:func:`lammps_commands_list`
- :cpp:func:`lammps_commands_string`
--------------------
Once a LAMMPS instance is created, there are multiple ways to "drive" a Once a LAMMPS instance is created, there are multiple ways to "drive" a
simulation. In most cases it is easiest to process single or multiple simulation. In most cases it is easiest to process single or multiple
LAMMPS commands like in an input file. This can be done through reading LAMMPS commands like in an input file. This can be done through reading
a file or passing single commands or lists of commands or blocks of a file or passing single commands or lists of commands or blocks of
commands with the following functions. commands with the following functions.
Via these functions, the calling code can have the LAMMPS instance act Via these functions, the calling code can have LAMMPS act on a series
on a series of :doc:`input file commands <Commands_all>` that are either of :doc:`input file commands <Commands_all>` that are either read from
read from a file or passed as strings. This for, for example, allows to a file or passed as strings. For example, this allows setup of a
setup a problem from a template file and then run it in stages while problem from an input script, and then running it in stages while
performing other operations in between or concurrently. The caller can performing other operations in between or concurrently. The caller
interleave the LAMMPS function calls with operations it performs, calls can interleave the LAMMPS function calls with operations it performs,
to extract information from or set information within LAMMPS, or calls such as calls to extract information from or set information within
to another code's library. LAMMPS, or calls to another code's library.
Also equivalent to regular :doc:`input script parsing <Commands_parse>` Just as with :doc:`input script parsing <Commands_parse>` comments can
is the handling of comments and expansion of variables with ``${name}`` be included in the file or strings, and expansion of variables with
or ``$(expression)`` syntax before the commands are parsed and ``${name}`` or ``$(expression)`` syntax is performed.
executed. Below is a short example using some of these functions. Below is a short example using some of these functions.
.. code-block:: C .. code-block:: C

View File

@ -1,8 +1,14 @@
Accessing LAMMPS Neighbor lists Accessing LAMMPS Neighbor lists
=============================== ===============================
The following functions allow to access neighbor lists The following functions enable access to neighbor lists generated by
generated by LAMMPS or query their properties. LAMMPS or querying of their properties:
- :cpp:func:`lammps_find_compute_neighlist`
- :cpp:func:`lammps_find_fix_neighlist`
- :cpp:func:`lammps_find_pair_neighlist`
- :cpp:func:`lammps_neighlist_num_elements`
- :cpp:func:`lammps_neighlist_element_neighbors`
----------------------- -----------------------

View File

@ -1,8 +1,13 @@
Retrieving or setting properties of LAMMPS objects Retrieving or setting properties of LAMMPS objects
================================================== ==================================================
This section documents accessing or modifying data from objects like This section documents accessing or modifying data stored by computes,
computes, fixes, or variables in LAMMPS. fixes, or variables in LAMMPS using the following functions:
- :cpp:func:`lammps_extract_compute`
- :cpp:func:`lammps_extract_fix`
- :cpp:func:`lammps_extract_variable`
- :cpp:func:`lammps_set_variable`
----------------------- -----------------------

View File

@ -1,18 +1,40 @@
Retrieving or setting LAMMPS system properties Retrieving or setting LAMMPS system properties
============================================== ==============================================
The library interface allows to extract different kinds of information This section documents the following functions:
about the active simulation instance and also to modify some of it.
This enables combining MD simulation steps with other processing and - :cpp:func:`lammps_version`
simulation methods computed in the calling code or another code that is - :cpp:func:`lammps_memory_usage`
coupled to LAMMPS via the library interface. In some cases the data - :cpp:func:`lammps_get_mpi_comm`
returned is direct reference to the original data inside LAMMPS cast - :cpp:func:`lammps_get_natoms`
to a void pointer. In that case the data needs to be cast to a suitable - :cpp:func:`lammps_get_thermo`
pointer to be able to access it, and you need to know the correct dimensions - :cpp:func:`lammps_extract_box`
and lengths. When accessing per-atom data, please note that this data - :cpp:func:`lammps_reset_box`
is the per-processor **local** data and indexed accordingly. These arrays - :cpp:func:`lammps_extract_setting`
can change sizes and order at every neighbor list rebuild and atom sort - :cpp:func:`lammps_extract_global_datatype`
event as atoms are migrating between sub-domains. - :cpp:func:`lammps_extract_global`
- :cpp:func:`lammps_extract_atom_datatype`
- :cpp:func:`lammps_extract_atom`
- :cpp:func:`lammps_create_atoms`
--------------------
The library interface allows extraction of different kinds of
information about the active simulation instance and also
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 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 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.
.. code-block:: C .. code-block:: C
@ -26,9 +48,18 @@ event as atoms are migrating between sub-domains.
handle = lammps_open_no_mpi(0, NULL, NULL); handle = lammps_open_no_mpi(0, NULL, NULL);
lammps_file(handle,"in.sysinit"); lammps_file(handle,"in.sysinit");
printf("running simulation with %g atoms\n", printf("Running a simulation with %g atoms.\n",
lammps_get_natoms(handle)); lammps_get_natoms(handle));
printf(" %d local and %d ghost atoms. %d atom types\n",
lammps_extract_setting(handle,"nlocal"),
lammps_extract_setting(handle,"nghost"),
lammps_extract_setting(handle,"ntypes"));
double *dt = (double *)lammps_extract_global(handle,"dt");
printf("Changing timestep from %g to 0.5\n", *dt);
*dt = 0.5;
lammps_command(handle,"run 1000 post no"); lammps_command(handle,"run 1000 post no");
for (i=0; i < 10; ++i) { for (i=0; i < 10; ++i) {

View File

@ -1,7 +1,27 @@
Library functions for scatter/gather operations Library functions for scatter/gather operations
================================================ ================================================
.. TODO add description This section has functions which gather per-atom data from one or more
processors into a contiguous global list ordered by atom ID. The same
list is returned to all calling processors. It also contains
functions which scatter per-atom data from a contiguous global list
across the processors that own those atom IDs. It also has a
create_atoms() function which can create new atoms by scattering them
appropriately to owning processors in the LAMMPS spatial
decomposition.
It documents the following functions:
- :cpp:func:`lammps_gather_atoms`
- :cpp:func:`lammps_gather_atoms_concat`
- :cpp:func:`lammps_gather_atoms_subset`
- :cpp:func:`lammps_scatter_atoms`
- :cpp:func:`lammps_scatter_atoms_subset`
- :cpp:func:`lammps_gather`
- :cpp:func:`lammps_gather_concat`
- :cpp:func:`lammps_gather_subset`
- :cpp:func:`lammps_scatter`
- :cpp:func:`lammps_scatter_subset`
----------------------- -----------------------
@ -27,3 +47,28 @@ Library functions for scatter/gather operations
.. doxygenfunction:: lammps_scatter_atoms_subset .. doxygenfunction:: lammps_scatter_atoms_subset
:project: progguide :project: progguide
-----------------------
.. doxygenfunction:: lammps_gather
:project: progguide
-----------------------
.. doxygenfunction:: lammps_gather_concat
:project: progguide
-----------------------
.. doxygenfunction:: lammps_gather_subset
:project: progguide
-----------------------
.. doxygenfunction:: lammps_scatter
:project: progguide
-----------------------
.. doxygenfunction:: lammps_scatter_subset
:project: progguide

View File

@ -1,8 +1,16 @@
Library interface utility functions Library interface utility functions
=================================== ===================================
To simplify some of the tasks, the library interface contains To simplify some tasks, the library interface contains these utility
some utility functions that are not directly calling LAMMPS. functions. They do not directly call the LAMMPS library.
- :cpp:func:`lammps_encode_image_flags`
- :cpp:func:`lammps_decode_image_flags`
- :cpp:func:`lammps_set_fix_external_callback`
- :cpp:func:`lammps_fix_external_set_energy_global`
- :cpp:func:`lammps_fix_external_set_virial_global`
- :cpp:func:`lammps_has_error`
- :cpp:func:`lammps_get_last_error_message`
----------------------- -----------------------
@ -21,6 +29,16 @@ some utility functions that are not directly calling LAMMPS.
----------------------- -----------------------
.. doxygenfunction:: lammps_fix_external_set_energy_global
:project: progguide
-----------------------
.. doxygenfunction:: lammps_fix_external_set_virial_global
:project: progguide
-----------------------
.. doxygenfunction:: lammps_has_error .. doxygenfunction:: lammps_has_error
:project: progguide :project: progguide

View File

@ -663,6 +663,7 @@ The singularity sub-directory contains container definitions files
that can be used to build container images for building and testing that can be used to build container images for building and testing
LAMMPS on specific OS variants using the `Singularity <https://sylabs.io>`_ LAMMPS on specific OS variants using the `Singularity <https://sylabs.io>`_
container software. Contributions for additional variants are welcome. container software. Contributions for additional variants are welcome.
For more details please see the README.md file in that folder.
---------- ----------

View File

@ -133,7 +133,7 @@ simulation into gold (FCC). These were provided by Jon Zimmerman
Stacking faults ~ 5.0 (4.0 to 6.0) Stacking faults ~ 5.0 (4.0 to 6.0)
Free surface ~ 23.0 Free surface ~ 23.0
These values are \*not\* normalized by the square of the lattice These values are **not** normalized by the square of the lattice
parameter. If they were, normalized values would be: parameter. If they were, normalized values would be:
.. parsed-literal:: .. parsed-literal::

View File

@ -24,8 +24,8 @@ Examples
.. code-block:: LAMMPS .. code-block:: LAMMPS
dump 1 all cfg/uef 10 dump.\*.cfg mass type xs ys zs dump 1 all cfg/uef 10 dump.*.cfg mass type xs ys zs
dump 2 all cfg/uef 100 dump.\*.cfg mass type xs ys zs id c_stress dump 2 all cfg/uef 100 dump.*.cfg mass type xs ys zs id c_stress
Description Description
""""""""""" """""""""""

View File

@ -21,7 +21,7 @@ Syntax
* color = atom attribute that determines color of each atom * color = atom attribute that determines color of each atom
* diameter = atom attribute that determines size of each atom * diameter = atom attribute that determines size of each atom
* zero or more keyword/value pairs may be appended * zero or more keyword/value pairs may be appended
* keyword = *atom* or *adiam* or *bond* or *line* or *tri* or *body* or *fix* or *size* or *view* or *center* or *up* or *zoom* or *persp* or *box* or *axes* or *subbox* or *shiny* or *ssao* * keyword = *atom* or *adiam* or *bond* or *line* or *tri* or *body* or *fix* or *size* or *view* or *center* or *up* or *zoom* or *box* or *axes* or *subbox* or *shiny* or *ssao*
.. parsed-literal:: .. parsed-literal::
@ -62,9 +62,6 @@ Syntax
*zoom* value = zfactor = size that simulation box appears in image *zoom* value = zfactor = size that simulation box appears in image
zfactor = scale image size by factor > 1 to enlarge, factor < 1 to shrink zfactor = scale image size by factor > 1 to enlarge, factor < 1 to shrink
zfactor can be a variable (see below) zfactor can be a variable (see below)
*persp* value = pfactor = amount of "perspective" in image
pfactor = amount of perspective (0 = none, < 1 = some, > 1 = highly skewed)
pfactor can be a variable (see below)
*box* values = yes/no diam = draw outline of simulation box *box* values = yes/no diam = draw outline of simulation box
yes/no = do or do not draw simulation box lines yes/no = do or do not draw simulation box lines
diam = diameter of box lines as fraction of shortest box length diam = diameter of box lines as fraction of shortest box length
@ -87,9 +84,9 @@ Examples
.. code-block:: LAMMPS .. code-block:: LAMMPS
dump d0 all image 100 dump.\*.jpg type type dump d0 all image 100 dump.*.jpg type type
dump d1 mobile image 500 snap.\*.png element element ssao yes 4539 0.6 dump d1 mobile image 500 snap.*.png element element ssao yes 4539 0.6
dump d2 all image 200 img-\*.ppm type type zoom 2.5 adiam 1.5 size 1280 720 dump d2 all image 200 img-*.ppm type type zoom 2.5 adiam 1.5 size 1280 720
dump m0 all movie 1000 movie.mpg type type size 640 480 dump m0 all movie 1000 movie.mpg type type size 640 480
dump m1 all movie 1000 movie.avi type type size 640 480 dump m1 all movie 1000 movie.avi type type size 640 480
dump m2 all movie 100 movie.m4v type type zoom 1.8 adiam v_value size 1280 720 dump m2 all movie 100 movie.m4v type type zoom 1.8 adiam v_value size 1280 720
@ -426,13 +423,14 @@ i.e. the number of pixels in each direction.
---------- ----------
The *view*\ , *center*\ , *up*\ , *zoom*\ , and *persp* values determine how The *view*\ , *center*\ , *up*\ , and *zoom* values determine how
3d simulation space is mapped to the 2d plane of the image. Basically 3d simulation space is mapped to the 2d plane of the image. Basically
they control how the simulation box appears in the image. they control how the simulation box appears in the image.
All of the *view*\ , *center*\ , *up*\ , *zoom*\ , and *persp* values can be All of the *view*\ , *center*\ , *up*\ , and *zoom* values can be
specified as numeric quantities, whose meaning is explained below. specified as numeric quantities, whose meaning is explained below.
Any of them can also be specified as an :doc:`equal-style variable <variable>`, by using v_name as the value, where "name" is Any of them can also be specified as an :doc:`equal-style variable <variable>`,
by using v_name as the value, where "name" is
the variable name. In this case the variable will be evaluated on the the variable name. In this case the variable will be evaluated on the
timestep each image is created to create a new value. If the timestep each image is created to create a new value. If the
equal-style variable is time-dependent, this is a means of changing equal-style variable is time-dependent, this is a means of changing
@ -483,19 +481,6 @@ image mostly filled by the atoms in the simulation box. A *zfactor* >
1 will make the simulation box larger; a *zfactor* < 1 will make it 1 will make the simulation box larger; a *zfactor* < 1 will make it
smaller. *Zfactor* must be a value > 0.0. smaller. *Zfactor* must be a value > 0.0.
The *persp* keyword determines how much depth perspective is present
in the image. Depth perspective makes lines that are parallel in
simulation space appear non-parallel in the image. A *pfactor* value
of 0.0 means that parallel lines will meet at infinity (1.0/pfactor),
which is an orthographic rendering with no perspective. A *pfactor*
value between 0.0 and 1.0 will introduce more perspective. A *pfactor*
value > 1 will create a highly skewed image with a large amount of
perspective.
.. note::
The *persp* keyword is not yet supported as an option.
---------- ----------
The *box* keyword determines if and how the simulation box boundaries The *box* keyword determines if and how the simulation box boundaries
@ -692,7 +677,6 @@ The defaults for the keywords are as follows:
* up = 0 0 1 (for 3d) * up = 0 0 1 (for 3d)
* up = 0 1 0 (for 2d) * up = 0 1 0 (for 2d)
* zoom = 1.0 * zoom = 1.0
* persp = 0.0
* box = yes 0.02 * box = yes 0.02
* axes = no 0.0 0.0 * axes = no 0.0 0.0
* subbox no 0.0 * subbox no 0.0

View File

@ -77,8 +77,11 @@ boron nitride nanotubes.
.. note:: .. note::
LAMMPS comes with one *mesocnt* style potential file Because of their size, *mesocnt* style potential files
where the default number of data points per table is 1001. are not bundled with LAMMPS. When compiling LAMMPS from
source code, the file ``C_10_10.mesocnt`` should be downloaded
transparently from `https://download.lammps.org/potentials/C_10_10.mesocnt <https://download.lammps.org/potentials/C_10_10.mesocnt>`_
This file has as number of data points per table 1001.
This is sufficient for NVT simulations. For proper energy This is sufficient for NVT simulations. For proper energy
conservation, we recommend using a potential file where conservation, we recommend using a potential file where
the resolution for Phi is at least 2001 data points. the resolution for Phi is at least 2001 data points.

View File

@ -147,12 +147,17 @@ where L is the maximum segment length, R is the maximum tube radius, and
segments. Because of the use of extended chain concept at CNT ends, the recommended segments. Because of the use of extended chain concept at CNT ends, the recommended
cutoff is 3L. cutoff is 3L.
The MESONT-TABTP_10_10.xrs potential file provided with LAMMPS (see the .. note::
potentials directory) is parameterized for metal :doc:`units <units>`.
Because of their size, *mesont* style potential files
are not bundled with LAMMPS. When compiling LAMMPS from
source code, the file ``TABTP_10_10.mesont`` should be downloaded
transparently from `https://download.lammps.org/potentials/TABTP_10_10.mesont <https://download.lammps.org/potentials/TABTP_10_10.mesont>`_
The ``TABTP_10_10.mesont`` potential file is parameterized for metal :doc:`units <units>`.
You can use the carbon nanotube mesoscopic force field with any LAMMPS units, You can use the carbon nanotube mesoscopic force field with any LAMMPS units,
but you would need to create your own TPMSSTP.xrs and TPMA.xrs potential files but you would need to create your own potential files with coefficients listed in
with coefficients listed in appropriate units, if your simulation appropriate units, if your simulation does not use "metal" units.
does not use "metal" units.
The chirality parameters set during system generation must match the values The chirality parameters set during system generation must match the values
specified during generation of the potential tables. specified during generation of the potential tables.

View File

@ -34,7 +34,7 @@ Examples
restart 0 restart 0
restart 1000 poly.restart restart 1000 poly.restart
restart 1000 poly.restart.mpiio restart 1000 poly.restart.mpiio
restart 1000 restart.\*.equil restart 1000 restart.*.equil
restart 10000 poly.%.1 poly.%.2 nfile 10 restart 10000 poly.%.1 poly.%.2 nfile 10
restart v_mystep poly.restart restart v_mystep poly.restart

View File

@ -203,6 +203,8 @@ class lammps(object):
# determine module file location # determine module file location
modpath = dirname(abspath(getsourcefile(lambda:0))) modpath = dirname(abspath(getsourcefile(lambda:0)))
# for windows installers the shared library is in a different folder
winpath = abspath(os.path.join(modpath,'..','bin'))
self.lib = None self.lib = None
self.lmp = None self.lmp = None
@ -231,6 +233,10 @@ class lammps(object):
elif any([f.startswith('liblammps') and f.endswith('.dll') elif any([f.startswith('liblammps') and f.endswith('.dll')
for f in os.listdir(modpath)]): for f in os.listdir(modpath)]):
lib_ext = ".dll" lib_ext = ".dll"
elif os.path.exists(winpath) and any([f.startswith('liblammps') and f.endswith('.dll')
for f in os.listdir(winpath)]):
lib_ext = ".dll"
modpath = winpath
else: else:
lib_ext = ".so" lib_ext = ".so"

View File

@ -74,7 +74,6 @@ void PairLineLJ::compute(int eflag, int vflag)
double xi[2],xj[2],fi[2],dxi,dxj,dyi,dyj; double xi[2],xj[2],fi[2],dxi,dxj,dyi,dyj;
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist,*jlist,*numneigh,**firstneigh;
evdwl = 0.0;
ev_init(eflag,vflag); ev_init(eflag,vflag);
double **x = atom->x; double **x = atom->x;

View File

@ -74,7 +74,6 @@ void PairTriLJ::compute(int eflag, int vflag)
double dc1[3],dc2[3],dc3[3]; double dc1[3],dc2[3],dc3[3];
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist,*jlist,*numneigh,**firstneigh;
evdwl = 0.0;
ev_init(eflag,vflag); ev_init(eflag,vflag);
AtomVecTri::Bonus *bonus = avec->bonus; AtomVecTri::Bonus *bonus = avec->bonus;

View File

@ -123,7 +123,7 @@ void ComputeBodyLocal::compute_local()
int ncount = compute_body(0); int ncount = compute_body(0);
if (ncount > nmax) reallocate(ncount); if (ncount > nmax) reallocate(ncount);
size_local_rows = ncount; size_local_rows = ncount;
ncount = compute_body(1); compute_body(1);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -343,7 +343,6 @@ void ComputeTempBody::compute_vector()
inertia = bonus[body[i]].inertia; inertia = bonus[body[i]].inertia;
quat = bonus[body[i]].quat; quat = bonus[body[i]].quat;
massone = rmass[i];
// wbody = angular velocity in body frame // wbody = angular velocity in body frame

View File

@ -447,10 +447,6 @@ double AngleClass2::single(int type, int i1, int i2, int i3)
if (c > 1.0) c = 1.0; if (c > 1.0) c = 1.0;
if (c < -1.0) c = -1.0; if (c < -1.0) c = -1.0;
double s = sqrt(1.0 - c*c);
if (s < SMALL) s = SMALL;
s = 1.0/s;
double dtheta = acos(c) - theta0[type]; double dtheta = acos(c) - theta0[type];
double dtheta2 = dtheta*dtheta; double dtheta2 = dtheta*dtheta;
double dtheta3 = dtheta2*dtheta; double dtheta3 = dtheta2*dtheta;

View File

@ -298,7 +298,7 @@ void NEBSpin::run()
fprintf(uscreen,"Step MaxReplicaTorque MaxAtomTorque " fprintf(uscreen,"Step MaxReplicaTorque MaxAtomTorque "
"GradV0 GradV1 GradVc EBF EBR RDT " "GradV0 GradV1 GradVc EBF EBR RDT "
"RD1 PE1 RD2 PE2 ... RDN PEN " "RD1 PE1 RD2 PE2 ... RDN PEN "
"GradV0dottan DN0... GradVNdottan DNN\n"); "GradV0dottan DN0 ... GradVNdottan DNN\n");
} else { } else {
fprintf(uscreen,"Step MaxReplicaTorque MaxAtomTorque " fprintf(uscreen,"Step MaxReplicaTorque MaxAtomTorque "
"GradV0 GradV1 GradVc " "GradV0 GradV1 GradVc "

View File

@ -379,7 +379,7 @@ void PairSpinDipoleCut::compute_dipolar(int /* i */, int /* j */, double eij[3],
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSpinDipoleCut::compute_dipolar_mech(int /* i */, int /* j */, double eij[3], void PairSpinDipoleCut::compute_dipolar_mech(int /* i */, int /* j */, double eij[3],
double fi[3], double spi[3], double spj[3], double r2inv) double fi[3], double spi[4], double spj[4], double r2inv)
{ {
double sisj,sieij,sjeij; double sisj,sieij,sjeij;
double gigjri4,bij,pre; double gigjri4,bij,pre;

View File

@ -453,7 +453,7 @@ void PairSpinDipoleLong::compute_long(int /* i */, int /* j */, double eij[3],
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSpinDipoleLong::compute_long_mech(int /* i */, int /* j */, double eij[3], void PairSpinDipoleLong::compute_long_mech(int /* i */, int /* j */, double eij[3],
double bij[4], double fi[3], double spi[3], double spj[3]) double bij[4], double fi[3], double spi[4], double spj[4])
{ {
double sisj,sieij,sjeij,b2,b3; double sisj,sieij,sjeij,b2,b3;
double g1,g2,g1b2_g2b3,gigj,pre; double g1,g2,g1b2_g2b3,gigj,pre;

View File

@ -160,9 +160,9 @@ FixIntel::FixIntel(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
// if using LRT mode, create the integrate style // if using LRT mode, create the integrate style
if (_lrt) { if (_lrt) {
char *str; char *cmd[1];
str = (char *) "verlet/lrt/intel"; cmd[0] = (char *) "verlet/lrt/intel";
update->create_integrate(1,&str,0); update->create_integrate(1,cmd,0);
} }
// error check // error check

View File

@ -35,114 +35,10 @@
#include <fvec.h> #include <fvec.h>
#endif #endif
// Vector classes for Cilk array notation
// This is experimental and doesn't yield good code yet
template<int VL, typename fscal>
struct lmp_intel_an_fvec {
fscal data[VL];
lmp_intel_an_fvec() {}
explicit lmp_intel_an_fvec(const fscal f) { data[:] = f; }
explicit lmp_intel_an_fvec(fscal f[VL]) { data[:] = f[:]; }
lmp_intel_an_fvec(const lmp_intel_an_fvec &a) { data[:] = a.data[:]; }
lmp_intel_an_fvec& operator =(const lmp_intel_an_fvec &a) { data[:] = a.data[:]; return *this; }
const lmp_intel_an_fvec operator +(const lmp_intel_an_fvec &b) const {
lmp_intel_an_fvec ret = *this;
ret.data[:] += b.data[:];
return ret;
}
const lmp_intel_an_fvec operator -(const lmp_intel_an_fvec &b) const {
lmp_intel_an_fvec ret = *this;
ret.data[:] -= b.data[:];
return ret;
}
const lmp_intel_an_fvec operator *(const lmp_intel_an_fvec &b) const {
lmp_intel_an_fvec ret = *this;
ret.data[:] *= b.data[:];
return ret;
}
const lmp_intel_an_fvec operator /(const lmp_intel_an_fvec &b) const {
lmp_intel_an_fvec ret = *this;
ret.data[:] /= b.data[:];
return ret;
}
lmp_intel_an_fvec& operator +=(const lmp_intel_an_fvec &b) {
data[:] += b.data[:]; return *this;
}
lmp_intel_an_fvec& operator -=(const lmp_intel_an_fvec &b) {
data[:] -= b.data[:]; return *this;
}
lmp_intel_an_fvec& operator *=(const lmp_intel_an_fvec &b) {
data[:] *= b.data[:]; return *this;
}
lmp_intel_an_fvec& operator /=(const lmp_intel_an_fvec &b) {
data[:] /= b.data[:]; return *this;
}
friend lmp_intel_an_fvec sqrt(const lmp_intel_an_fvec &a) __attribute__((always_inline)) {
lmp_intel_an_fvec ret; ret.data[:] = sqrt(a.data[:]); return ret;
}
friend lmp_intel_an_fvec exp(const lmp_intel_an_fvec &a) __attribute__((always_inline)) {
lmp_intel_an_fvec ret; ret.data[:] = exp(a.data[:]); return ret;
}
friend lmp_intel_an_fvec sin(const lmp_intel_an_fvec &a) __attribute__((always_inline)) {
lmp_intel_an_fvec ret; ret.data[:] = sin(a.data[:]); return ret;
}
friend lmp_intel_an_fvec invsqrt(const lmp_intel_an_fvec &a) __attribute__((always_inline)) {
lmp_intel_an_fvec ret; ret.data[:] = ((fscal)1.) / sqrt(a.data[:]); return ret;
}
friend lmp_intel_an_fvec pow(const lmp_intel_an_fvec &a, const lmp_intel_an_fvec &b) __attribute__((always_inline)) {
lmp_intel_an_fvec ret; ret.data[:] = pow(a.data[:], b.data[:]); return ret;
}
lmp_intel_an_fvec operator - () const {
lmp_intel_an_fvec ret; ret.data[:] = - data[:]; return ret;
}
};
template<int VL>
struct lmp_intel_an_ivec {
int data[VL];
lmp_intel_an_ivec() {}
explicit lmp_intel_an_ivec(int i) { data[:] = i; }
explicit lmp_intel_an_ivec(const int * a) { data[:] = a[0:VL]; }
const lmp_intel_an_ivec operator &(const lmp_intel_an_ivec &b) {
lmp_intel_an_ivec ret = *this;
ret.data[:] &= b.data[:];
return ret;
}
const lmp_intel_an_ivec operator |(const lmp_intel_an_ivec &b) {
lmp_intel_an_ivec ret = *this;
ret.data[:] |= b.data[:];
return ret;
}
const lmp_intel_an_ivec operator +(const lmp_intel_an_ivec &b) {
lmp_intel_an_ivec ret = *this;
ret.data[:] += b.data[:];
return ret;
}
};
template<int VL>
struct lmp_intel_an_bvec {
bool data[VL];
lmp_intel_an_bvec() {}
lmp_intel_an_bvec(const lmp_intel_an_bvec &a) { data[:] = a.data[:]; }
lmp_intel_an_bvec& operator =(const lmp_intel_an_bvec &a) { data[:] = a.data[:]; return *this; }
explicit lmp_intel_an_bvec(int i) { data[:] = i; }
friend lmp_intel_an_bvec operator &(const lmp_intel_an_bvec &a, const lmp_intel_an_bvec &b) __attribute__((always_inline)) {
lmp_intel_an_bvec ret; ret.data[:] = a.data[:] & b.data[:]; return ret;
}
friend lmp_intel_an_bvec operator |(const lmp_intel_an_bvec &a, const lmp_intel_an_bvec &b) __attribute__((always_inline)) {
lmp_intel_an_bvec ret; ret.data[:] = a.data[:] | b.data[:]; return ret;
}
friend lmp_intel_an_bvec operator ~(const lmp_intel_an_bvec &a) __attribute__((always_inline)) {
lmp_intel_an_bvec ret; ret.data[:] = ! a.data[:]; return ret;
}
lmp_intel_an_bvec& operator &=(const lmp_intel_an_bvec &a) __attribute__((always_inline)) {
data[:] &= a.data[:]; return *this;
}
};
namespace lmp_intel { namespace lmp_intel {
// Self explanatory mostly, KNC=IMCI and AVX-512, NONE=Scalar, AN=Array Not. // Self explanatory mostly, KNC=IMCI and AVX-512, NONE=Scalar.
enum CalculationMode { KNC, AVX, AVX2, SSE, NONE, AN }; enum CalculationMode {KNC, AVX, AVX2, SSE, NONE};
#ifdef __MIC__ #ifdef __MIC__
#ifdef LMP_INTEL_VECTOR_MIC #ifdef LMP_INTEL_VECTOR_MIC
static const CalculationMode mode = LMP_INTEL_VECTOR_MIC; static const CalculationMode mode = LMP_INTEL_VECTOR_MIC;
@ -1916,148 +1812,6 @@ struct vector_ops<flt_t, NONE> {
} }
}; };
// Array notation implementation
template<class flt_t>
struct vector_ops<flt_t, AN> {
static const int VL = 4;
typedef flt_t fscal;
typedef lmp_intel_an_fvec<VL, fscal> fvec;
typedef lmp_intel_an_ivec<VL> ivec;
typedef lmp_intel_an_bvec<VL> bvec;
typedef flt_t farr[VL];
typedef int iarr[VL];
static fvec recip(const fvec &a) {
fvec ret; ret.data[:] = ((fscal)1.) / a.data[:]; return ret;
}
template<int scale>
static void gather_prefetch_t0(const ivec &idx, const bvec &mask, const void *base) {
// nop
}
template<int scale>
static fvec gather(const fvec &from, const bvec &mask, const ivec &idx, const void *base) {
fvec ret = from;
if (mask.data[:]) ret.data[:] = *reinterpret_cast<const fscal *>(reinterpret_cast<const char*>(base) + scale * idx.data[:]);
return ret;
}
template<class T>
static void gather_x(const ivec &idxs, const bvec &mask, const T *base, fvec *x, fvec *y, fvec *z, ivec *w) {
*x = gather<1>(*x, mask, idxs, &base->x);
*y = gather<1>(*y, mask, idxs, &base->y);
*z = gather<1>(*z, mask, idxs, &base->z);
*w = int_gather<1>(*w, mask, idxs, &base->w);
}
static void gather_8(const ivec &idxs, const bvec &mask, const void *base,
fvec *r0, fvec *r1, fvec *r2, fvec *r3, fvec *r4, fvec *r5, fvec *r6, fvec *r7) {
fvec a = zero(), b = zero(), c = zero(), d = zero();
gather_4(idxs, mask, base, r0, r1, r2, r3);
gather_4(idxs, mask, reinterpret_cast<const char*>(base) + 4 * sizeof(fscal), r4, r5, r6, r7);
}
static void gather_4(const ivec &idxs, const bvec &mask, const void *base,
fvec *r0, fvec *r1, fvec *r2, fvec *r3) {
*r0 = gather<4>(*r0, mask, idxs, reinterpret_cast<const char*>(base) + 0 * sizeof(fscal));
*r1 = gather<4>(*r1, mask, idxs, reinterpret_cast<const char*>(base) + 1 * sizeof(fscal));
*r2 = gather<4>(*r2, mask, idxs, reinterpret_cast<const char*>(base) + 2 * sizeof(fscal));
*r3 = gather<4>(*r3, mask, idxs, reinterpret_cast<const char*>(base) + 3 * sizeof(fscal));
}
static fvec blend(const bvec &mask, const fvec &a, const fvec &b) {
fvec ret = a;
if (mask.data[:]) ret.data[:] = b.data[:];
return ret;
}
static ivec int_blend(const bvec &mask, const ivec &a, const ivec &b) {
fvec ret = a;
if (mask.data[:]) ret.data[:] = b.data[:];
return ret;
}
static fvec fmadd(const fvec &a, const fvec &b, const fvec &c) {
fvec ret; ret.data[:] = a.data[:] * b.data[:] + c.data[:]; return ret;
}
static fvec zero() {
return fvec(0.);
}
static bvec cmpeq(const fvec &a, const fvec &b) {
bvec ret; ret.data[:] = a.data[:] == b.data[:]; return ret;
}
static bvec cmpnle(const fvec &a, const fvec &b) {
bvec ret; ret.data[:] = !(a.data[:] <= b.data[:]); return ret;
}
static bvec cmple(const fvec &a, const fvec &b) {
bvec ret; ret.data[:] = a.data[:] <= b.data[:]; return ret;
}
static bvec cmplt(const fvec &a, const fvec &b) {
bvec ret; ret.data[:] = a.data[:] < b.data[:]; return ret;
}
static bvec int_cmpneq(const ivec &a, const ivec &b) {
bvec ret; ret.data[:] = a.data[:] != b.data[:]; return ret;
}
static bvec int_cmplt(const ivec &a, const ivec &b) {
bvec ret; ret.data[:] = a.data[:] < b.data[:]; return ret;
}
static fvec invsqrt(const fvec &a) {
fvec ret; ret.data[:] = ((fscal)1.) / sqrt(a.data[:]); return ret;
}
static fvec sincos(fvec *c, const fvec &a) {
c->data[:] = cos(a.data[:]);
fvec ret; ret.data[:] = sin(a.data[:]); return ret;
}
static fscal reduce_add(const fvec &a) {
return __sec_reduce_add(a.data[:]);
}
static ivec int_mullo(const ivec &a, const ivec &b) {
ivec ret; ret.data[:] = a.data[:] * b.data[:]; return ret;
}
static ivec int_mask_add(const ivec &src, const bvec &mask, const ivec &a, const ivec &b) {
ivec ret = src;
if (mask.data[:]) ret.data[:] = a.data[:] + b.data[:];
return ret;
}
template<int scale>
static ivec int_gather(const ivec &from, bvec mask, const ivec &idx, const void *base) {
ivec ret = from;
if (mask.data[:]) ret.data[:] = reinterpret_cast<const int*>(base)[scale * idx.data[:] / sizeof(int)];
return ret;
}
static fvec mask_add(const fvec &src, const bvec &mask, const fvec &a, const fvec &b) {
fvec ret = src;
if (mask.data[:]) ret.data[:] = a.data[:] + b.data[:];
return ret;
}
static void store(void *at, const fvec &a) {
reinterpret_cast<fscal*>(at)[0:VL] = a.data[:];
}
static void int_store(int *at, const ivec &a) {
reinterpret_cast<int*>(at)[0:VL] = a.data[:];
}
static void mask_store(int *at, const bvec &a) {
at[0:VL] = a.data[:];
}
static fvec min(const fvec &a, const fvec &b) {
fvec ret = b;
if (a.data[:] < b.data[:]) ret.data[:] = a.data[:];
return ret;
}
static bool mask_test_at(const bvec &mask, int at) {
return mask.data[at];
}
static bool mask_testz(const bvec &mask) {
return ! __sec_reduce_or(mask.data[:]);
}
static bvec mask_enable_lower(int n) {
bvec ret; ret.data[:] = __sec_implicit_index(0) < n; return ret;
}
static ivec int_load_vl(const int *a) {
return ivec(a);
}
static void int_clear_arr(int *a) {
a[0:VL] = 0;
}
static bvec full_mask() {
return bvec(1);
}
static void int_print(const ivec &a) {
}
};
// Mixins to implement mixed precision and single/single and double/double // Mixins to implement mixed precision and single/single and double/double
// This one is for single/single and double/double // This one is for single/single and double/double
template<class BASE_flt_t, CalculationMode BASE_mic> template<class BASE_flt_t, CalculationMode BASE_mic>
@ -2138,7 +1892,7 @@ struct AccumulatorTwiceMixin {
}; };
// For cases where vector_ops<float,x>::VL == vector_ops<double,x>::VL // For cases where vector_ops<float,x>::VL == vector_ops<double,x>::VL
// i.e. scalar & AN
template<class BASE_flt_t, class HIGH_flt_t, CalculationMode mic> template<class BASE_flt_t, class HIGH_flt_t, CalculationMode mic>
struct AccumulatorTwiceMixinNone { struct AccumulatorTwiceMixinNone {
typedef vector_ops<BASE_flt_t, mic> BASE; typedef vector_ops<BASE_flt_t, mic> BASE;
@ -2177,11 +1931,8 @@ struct vector_routines<float,float,mic> : public vector_ops<float, mic>, public
template<CalculationMode mic> template<CalculationMode mic>
struct vector_routines<float,double,mic> : public vector_ops<float, mic>, public AccumulatorTwiceMixin<float,double, mic> {}; struct vector_routines<float,double,mic> : public vector_ops<float, mic>, public AccumulatorTwiceMixin<float,double, mic> {};
// Specialize for AN and scalar // Specialize for scalar
template<> template<>
struct vector_routines<float,double,NONE> : public vector_ops<float, NONE>, public AccumulatorTwiceMixinNone<float,double, NONE> {}; struct vector_routines<float,double,NONE> : public vector_ops<float, NONE>, public AccumulatorTwiceMixinNone<float,double, NONE> {};
template<>
struct vector_routines<float,double,AN> : public vector_ops<float, AN>, public AccumulatorTwiceMixinNone<float,double, AN> {};
} // namespace lmp_intel } // namespace lmp_intel

View File

@ -184,8 +184,8 @@ void BondSpecial::read_restart(FILE *fp)
allocate(); allocate();
if (comm->me == 0) { if (comm->me == 0) {
fread(&factor_lj[1],sizeof(double),atom->nbondtypes,fp); utils::sfread(FLERR,&factor_lj[1],sizeof(double),atom->nbondtypes,fp,nullptr,error);
fread(&factor_coul[1],sizeof(double),atom->nbondtypes,fp); utils::sfread(FLERR,&factor_coul[1],sizeof(double),atom->nbondtypes,fp,nullptr,error);
} }
MPI_Bcast(&factor_lj[1],atom->nbondtypes,MPI_DOUBLE,0,world); MPI_Bcast(&factor_lj[1],atom->nbondtypes,MPI_DOUBLE,0,world);
MPI_Bcast(&factor_coul[1],atom->nbondtypes,MPI_DOUBLE,0,world); MPI_Bcast(&factor_coul[1],atom->nbondtypes,MPI_DOUBLE,0,world);

View File

@ -160,13 +160,13 @@ template <int filter_by_type>
void FixPropelSelf::post_force_quaternion(int /* vflag */ ) void FixPropelSelf::post_force_quaternion(int /* vflag */ )
{ {
double **f = atom->f; double **f = atom->f;
AtomVecEllipsoid *av = static_cast<AtomVecEllipsoid*>(atom->avec);
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
int *type = atom->type; int *type = atom->type;
int* ellipsoid = atom->ellipsoid; int* ellipsoid = atom->ellipsoid;
AtomVecEllipsoid *av = static_cast<AtomVecEllipsoid*>(atom->style_match("ellipsoid"));
AtomVecEllipsoid::Bonus *bonus = av->bonus; AtomVecEllipsoid::Bonus *bonus = av->bonus;
// Add the active force to the atom force: // Add the active force to the atom force:

View File

@ -152,10 +152,10 @@ void PairCoulSlaterCut::write_restart_settings(FILE *fp)
void PairCoulSlaterCut::read_restart_settings(FILE *fp) void PairCoulSlaterCut::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
fread(&lamda,sizeof(double),1,fp); utils::sfread(FLERR,&lamda,sizeof(double),1,fp,nullptr,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&lamda,1,MPI_DOUBLE,0,world); MPI_Bcast(&lamda,1,MPI_DOUBLE,0,world);

View File

@ -78,10 +78,10 @@ FixOMP::FixOMP(LAMMPS *lmp, int narg, char **arg)
#endif #endif
} }
#if defined(_OPENMP)
if (nthreads < 1) if (nthreads < 1)
error->all(FLERR,"Illegal number of OpenMP threads requested"); error->all(FLERR,"Illegal number of OpenMP threads requested");
#if defined(_OPENMP)
int reset_thr = 0; int reset_thr = 0;
#endif #endif
if (nthreads != comm->nthreads) { if (nthreads != comm->nthreads) {

View File

@ -78,7 +78,7 @@ double ComputePressureUef::compute_scalar()
addstep(update->ntimestep+1); addstep(update->ntimestep+1);
int k =0; int k =0;
scalar = 0; scalar = 0.0;
if (ext_flags[0]) { if (ext_flags[0]) {
scalar += vector[0]; scalar += vector[0];
k++; k++;
@ -92,7 +92,7 @@ double ComputePressureUef::compute_scalar()
k++; k++;
} }
scalar /= k; if (k > 1) scalar /= k;
return scalar; return scalar;
} }

View File

@ -176,7 +176,7 @@ void ChangeBox::command(int narg, char **arg)
int move_atoms = 0; int move_atoms = 0;
for (int m = 0; m < nops; m++) { for (int m = 0; m < nops; m++) {
if (ops[m].style != ORTHO || ops[m].style != TRICLINIC) move_atoms = 1; if (ops[m].style != ORTHO && ops[m].style != TRICLINIC) move_atoms = 1;
} }
// error if moving atoms and there is stored per-atom restart state // error if moving atoms and there is stored per-atom restart state

View File

@ -36,7 +36,7 @@ using namespace LAMMPS_NS;
ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), Compute(lmp, narg, arg),
vptr(nullptr), id_temp(nullptr) vptr(nullptr), id_temp(nullptr), pstyle(nullptr)
{ {
if (narg < 4) error->all(FLERR,"Illegal compute pressure command"); if (narg < 4) error->all(FLERR,"Illegal compute pressure command");
if (igroup) error->all(FLERR,"Compute pressure must use group all"); if (igroup) error->all(FLERR,"Compute pressure must use group all");
@ -146,6 +146,7 @@ ComputePressure::~ComputePressure()
delete [] id_temp; delete [] id_temp;
delete [] vector; delete [] vector;
delete [] vptr; delete [] vptr;
delete [] pstyle;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -52,7 +52,7 @@ enum{NO,YES};
DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
DumpCustom(lmp, narg, arg), thetastr(nullptr), phistr(nullptr), cxstr(nullptr), DumpCustom(lmp, narg, arg), thetastr(nullptr), phistr(nullptr), cxstr(nullptr),
cystr(nullptr), czstr(nullptr), upxstr(nullptr), upystr(nullptr), upzstr(nullptr), cystr(nullptr), czstr(nullptr), upxstr(nullptr), upystr(nullptr), upzstr(nullptr),
zoomstr(nullptr), perspstr(nullptr), diamtype(nullptr), diamelement(nullptr), zoomstr(nullptr), diamtype(nullptr), diamelement(nullptr),
bdiamtype(nullptr), colortype(nullptr), colorelement(nullptr), bcolortype(nullptr), bdiamtype(nullptr), colortype(nullptr), colorelement(nullptr), bcolortype(nullptr),
avec_line(nullptr), avec_tri(nullptr), avec_body(nullptr), fixptr(nullptr), image(nullptr), avec_line(nullptr), avec_tri(nullptr), avec_body(nullptr), fixptr(nullptr), image(nullptr),
chooseghost(nullptr), bufcopy(nullptr) chooseghost(nullptr), bufcopy(nullptr)
@ -133,7 +133,6 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
upxstr = upystr = upzstr = nullptr; upxstr = upystr = upzstr = nullptr;
zoomstr = nullptr; zoomstr = nullptr;
perspstr = nullptr;
boxflag = YES; boxflag = YES;
boxdiam = 0.02; boxdiam = 0.02;
axesflag = NO; axesflag = NO;
@ -305,20 +304,6 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
} }
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"persp") == 0) {
error->all(FLERR,"Dump image persp option is not yet supported");
if (iarg+2 > narg) error->all(FLERR,"Illegal dump image command");
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
int n = strlen(&arg[iarg+1][2]) + 1;
perspstr = new char[n];
strcpy(perspstr,&arg[iarg+1][2]);
} else {
double persp = utils::numeric(FLERR,arg[iarg+1],false,lmp);
if (persp < 0.0) error->all(FLERR,"Illegal dump image command");
image->persp = persp;
}
iarg += 2;
} else if (strcmp(arg[iarg],"box") == 0) { } else if (strcmp(arg[iarg],"box") == 0) {
if (iarg+3 > narg) error->all(FLERR,"Illegal dump image command"); if (iarg+3 > narg) error->all(FLERR,"Illegal dump image command");
if (strcmp(arg[iarg+1],"yes") == 0) boxflag = YES; if (strcmp(arg[iarg+1],"yes") == 0) boxflag = YES;
@ -449,7 +434,7 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
viewflag = STATIC; viewflag = STATIC;
if (thetastr || phistr || cflag == DYNAMIC || if (thetastr || phistr || cflag == DYNAMIC ||
upxstr || upystr || upzstr || zoomstr || perspstr) viewflag = DYNAMIC; upxstr || upystr || upzstr || zoomstr) viewflag = DYNAMIC;
box_bounds(); box_bounds();
if (cflag == STATIC) box_center(); if (cflag == STATIC) box_center();
@ -553,13 +538,6 @@ void DumpImage::init_style()
if (!input->variable->equalstyle(zoomvar)) if (!input->variable->equalstyle(zoomvar))
error->all(FLERR,"Variable for dump image zoom is invalid style"); error->all(FLERR,"Variable for dump image zoom is invalid style");
} }
if (perspstr) {
perspvar = input->variable->find(perspstr);
if (perspvar < 0)
error->all(FLERR,"Variable name for dump image persp does not exist");
if (!input->variable->equalstyle(perspvar))
error->all(FLERR,"Variable for dump image persp is invalid style");
}
// set up type -> element mapping // set up type -> element mapping
@ -719,12 +697,10 @@ void DumpImage::view_params()
if (upystr) image->up[1] = input->variable->compute_equal(upyvar); if (upystr) image->up[1] = input->variable->compute_equal(upyvar);
if (upzstr) image->up[2] = input->variable->compute_equal(upzvar); if (upzstr) image->up[2] = input->variable->compute_equal(upzvar);
// zoom and perspective // zoom
if (zoomstr) image->zoom = input->variable->compute_equal(zoomvar); if (zoomstr) image->zoom = input->variable->compute_equal(zoomvar);
if (image->zoom <= 0.0) error->all(FLERR,"Invalid dump image zoom value"); if (image->zoom <= 0.0) error->all(FLERR,"Invalid dump image zoom value");
if (perspstr) image->persp = input->variable->compute_equal(perspvar);
if (image->persp < 0.0) error->all(FLERR,"Invalid dump image persp value");
// remainder of view setup is internal to Image class // remainder of view setup is internal to Image class

View File

@ -67,8 +67,8 @@ class DumpImage : public DumpCustom {
int cxvar,cyvar,czvar; // index to box center vars int cxvar,cyvar,czvar; // index to box center vars
char *upxstr,*upystr,*upzstr; // view up vector variables char *upxstr,*upystr,*upzstr; // view up vector variables
int upxvar,upyvar,upzvar; // index to up vector vars int upxvar,upyvar,upzvar; // index to up vector vars
char *zoomstr,*perspstr; // view zoom and perspective variables char *zoomstr; // view zoom variable name
int zoomvar,perspvar; // index to zoom,persp vars int zoomvar; // index to zoom variable
int boxflag,axesflag; // 0/1 for draw box and axes int boxflag,axesflag; // 0/1 for draw box and axes
double boxdiam,axeslen,axesdiam; // params for drawing box and axes double boxdiam,axeslen,axesdiam; // params for drawing box and axes
int subboxflag; int subboxflag;
@ -136,10 +136,6 @@ E: Invalid dump image theta value
Theta must be between 0.0 and 180.0 inclusive. Theta must be between 0.0 and 180.0 inclusive.
E: Dump image persp option is not yet supported
Self-explanatory.
E: Dump image line requires atom style line E: Dump image line requires atom style line
Self-explanatory. Self-explanatory.
@ -196,14 +192,6 @@ E: Variable for dump image zoom is invalid style
Must be an equal-style variable. Must be an equal-style variable.
E: Variable name for dump image persp does not exist
Self-explanatory.
E: Variable for dump image persp is invalid style
Must be an equal-style variable.
E: Invalid dump image element name E: Invalid dump image element name
The specified element name was not in the standard list of elements. The specified element name was not in the standard list of elements.
@ -218,10 +206,6 @@ E: Invalid dump image zoom value
Zoom value must be > 0.0. Zoom value must be > 0.0.
E: Invalid dump image persp value
Persp value must be >= 0.0.
E: Invalid color in dump_modify command E: Invalid color in dump_modify command
The specified color name was not in the list of recognized colors. The specified color name was not in the list of recognized colors.

View File

@ -1234,12 +1234,11 @@ void Input::shell()
} else if (strcmp(arg[0],"putenv") == 0) { } else if (strcmp(arg[0],"putenv") == 0) {
if (narg < 2) error->all(FLERR,"Illegal shell putenv command"); if (narg < 2) error->all(FLERR,"Illegal shell putenv command");
for (int i = 1; i < narg; i++) { for (int i = 1; i < narg; i++) {
char *ptr = strdup(arg[i]);
rv = 0; rv = 0;
#ifdef _WIN32 #ifdef _WIN32
if (ptr != nullptr) rv = _putenv(ptr); if (arg[i]) rv = _putenv(arg[i]);
#else #else
if (ptr != nullptr) rv = putenv(ptr); if (arg[i]) rv = putenv(arg[i]);
#endif #endif
rv = (rv < 0) ? errno : 0; rv = (rv < 0) ? errno : 0;
MPI_Reduce(&rv,&err,1,MPI_INT,MPI_MAX,0,world); MPI_Reduce(&rv,&err,1,MPI_INT,MPI_MAX,0,world);

View File

@ -4252,7 +4252,7 @@ int lammps_find_compute_neighlist(void* handle, char * id, int request) {
} }
} }
if (compute == nullptr) { if (compute != nullptr) {
// find neigh list // find neigh list
for (int i = 0; i < lmp->neighbor->nlist; i++) { for (int i = 0; i < lmp->neighbor->nlist; i++) {
NeighList * list = lmp->neighbor->lists[i]; NeighList * list = lmp->neighbor->lists[i];

View File

@ -849,6 +849,8 @@ void Jacobi<Scalar, Vector, Matrix, ConstMatrix>::
Dealloc() { Dealloc() {
//assert(! is_preallocated); //assert(! is_preallocated);
Dealloc2D(&M); Dealloc2D(&M);
delete[] max_idx_row;
max_idx_row = nullptr;
Init(); Init();
} }

View File

@ -25,11 +25,30 @@
// so this is what LAMMPS primarily uses. For those compilers // so this is what LAMMPS primarily uses. For those compilers
// that strictly implement OpenMP 4.0 (such as GCC 9.0 and later // that strictly implement OpenMP 4.0 (such as GCC 9.0 and later
// or Clang 10.0 and later), we give up default(none). // or Clang 10.0 and later), we give up default(none).
#if LAMMPS_OMP_COMPAT == 4
# define LMP_SHARED(...) // autodetect OpenMP compatibility if not explicitly set
# define LMP_DEFAULT_NONE default(shared)
#else #ifndef LAMMPS_OMP_COMPAT
# define LMP_SHARED(...) shared(__VA_ARGS__) # if defined(__INTEL_COMPILER)
# define LMP_DEFAULT_NONE default(none) # if __INTEL_COMPILER > 18
# define LAMMPS_OMP_COMPAT 4
# endif
# elif defined(__clang__)
# if __clang_major__ >= 10
# define LAMMPS_OMP_COMPAT 4
# endif
# elif defined(__GNUC__)
# if __GNUC__ >= 9
# define LAMMPS_OMP_COMPAT 4
# endif
# endif
#endif
#if LAMMPS_OMP_COMPAT == 4
# define LMP_SHARED(...)
# define LMP_DEFAULT_NONE default(shared)
#else
# define LMP_SHARED(...) shared(__VA_ARGS__)
# define LMP_DEFAULT_NONE default(none)
#endif #endif

View File

@ -368,9 +368,9 @@ void ResetIDs::sort()
// bins are numbered from 0 to Nbins-1 // bins are numbered from 0 to Nbins-1
bigint nbins = (bigint) nbinx*nbiny*nbinz; bigint nbins = (bigint) nbinx*nbiny*nbinz;
int nlo = nbins / nprocs; bigint nlo = nbins / nprocs;
int nhi = nlo + 1; bigint nhi = nlo + 1;
int nplo = nprocs - (nbins % nprocs); bigint nplo = nprocs - (nbins % nprocs);
bigint nbinlo = nplo*nlo; bigint nbinlo = nplo*nlo;
if (me < nplo) { if (me < nplo) {

View File

@ -152,6 +152,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
#include <ctype.h>
#endif
/* global variables */ /* global variables */
char *rootname; char *rootname;

View File

@ -5,12 +5,12 @@ for [Singularity](https://sylabs.io), suitable for compiling and testing
LAMMPS on a variety of OS variants with support for most standard LAMMPS on a variety of OS variants with support for most standard
packages and - for some of them - also building/spellchecking the manual packages and - for some of them - also building/spellchecking the manual
in all supported formats. This allows to test and debug LAMMPS code on in all supported formats. This allows to test and debug LAMMPS code on
different OS variants than what is locally installed on your development different OS variants without doing a full installation on your development
workstation, e.g. when bugs are reported that can only be reproduced on workstation, e.g. when bugs are reported that can only be reproduced on
a specific OS or with specific (mostly older) versions of tools, a specific OS or with specific (mostly older) versions of tools,
compilers, or libraries. compilers, or libraries.
Ready-to-use container images built from these definition files are Ready-to-use container images built from some these definition files are
occasionally uploaded to the container library at sylabs.io. They occasionally uploaded to the container library at sylabs.io. They
can be found here: https://cloud.sylabs.io/library/lammps/default/lammps_development# can be found here: https://cloud.sylabs.io/library/lammps/default/lammps_development#
and will be signed with a GPG key that has the fingerprint: and will be signed with a GPG key that has the fingerprint:
@ -25,7 +25,7 @@ git clone --depth 500 git://github.com/lammps/lammps.git lammps
mkdir build-centos7 mkdir build-centos7
cd build-centos7 cd build-centos7
sudo singularity build centos7.sif ../tools/singularity/centos7.def sudo singularity build centos7.sif ../tools/singularity/centos7.def
singularity shell centos7.sif singularity exec centos7.sif bash --login
cmake -C ../cmake/presets/most.cmake ../cmake cmake -C ../cmake/presets/most.cmake ../cmake
make make
``` ```
@ -39,7 +39,7 @@ git clone --depth 500 git://github.com/lammps/lammps.git lammps
mkdir build-ubuntu18 mkdir build-ubuntu18
cd build-ubuntu18 cd build-ubuntu18
singularity pull library://lammps/default/lammps_development:ubuntu18.04 singularity pull library://lammps/default/lammps_development:ubuntu18.04
singularity shell lammps_development_ubuntu18.04.sif singularity exec lammps_development_ubuntu18.04.sif bash --login
cmake -C ../cmake/presets/most.cmake ../cmake cmake -C ../cmake/presets/most.cmake ../cmake
make make
``` ```

View File

@ -63,7 +63,7 @@ TEST_F(LibraryProperties, memory_usage)
lammps_memory_usage(lmp, meminfo); lammps_memory_usage(lmp, meminfo);
EXPECT_GT(meminfo[0], 0.0); EXPECT_GT(meminfo[0], 0.0);
#if defined(__linux__) || defined(_WIN32) #if defined(__linux__) || defined(_WIN32)
EXPECT_GT(meminfo[1], 0.0); EXPECT_GE(meminfo[1], 0.0);
#endif #endif
EXPECT_GT(meminfo[2], 0.0); EXPECT_GT(meminfo[2], 0.0);
}; };

View File

@ -312,6 +312,32 @@ TEST_F(SimpleCommandsTest, Units)
TEST_FAILURE(".*ERROR: Illegal units command.*", lmp->input->one("units unknown");); TEST_FAILURE(".*ERROR: Illegal units command.*", lmp->input->one("units unknown"););
} }
TEST_F(SimpleCommandsTest, Shell)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("shell putenv TEST_VARIABLE=simpletest");
if (!verbose) ::testing::internal::GetCapturedStdout();
char * test_var = getenv("TEST_VARIABLE");
ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("simpletest"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("shell putenv TEST_VARIABLE=simpletest");
lmp->input->one("shell putenv TEST_VARIABLE2=simpletest2 OTHER_VARIABLE=2");
if (!verbose) ::testing::internal::GetCapturedStdout();
char * test_var2 = getenv("TEST_VARIABLE2");
char * other_var = getenv("OTHER_VARIABLE");
ASSERT_NE(test_var2, nullptr);
ASSERT_THAT(test_var2, StrEq("simpletest2"));
ASSERT_NE(other_var, nullptr);
ASSERT_THAT(other_var, StrEq("2"));
}
} // namespace LAMMPS_NS } // namespace LAMMPS_NS
int main(int argc, char **argv) int main(int argc, char **argv)