diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9b3992da84..62829c44b6 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -51,42 +51,35 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR}) include(CheckCCompilerFlag) include(CheckIncludeFileCXX) +# set required compiler flags and compiler/CPU arch specific optimizations if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict") + 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") + endif() endif() if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - if(NOT ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -ftree-vectorize -fexpensive-optimizations") - endif() + set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native") +endif() + +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native") endif() # we require C++11 set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# GNU compiler features +# GNU compiler specific features for testing if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - option(ENABLE_COVERAGE "Enable code coverage" OFF) + option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) mark_as_advanced(ENABLE_COVERAGE) if(ENABLE_COVERAGE) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") endif() - option(ENABLE_SANITIZE_ADDRESS "Enable address sanitizer" OFF) - mark_as_advanced(ENABLE_SANITIZE_ADDRESS) - if(ENABLE_SANITIZE_ADDRESS) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") - endif() - option(ENABLE_SANITIZE_UNDEFINED "Enable undefined behavior sanitizer" OFF) - mark_as_advanced(ENABLE_SANITIZE_UNDEFINED) - if(ENABLE_SANITIZE_UNDEFINED) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") - endif() - option(ENABLE_SANITIZE_THREAD "Enable thread sanitizer" OFF) - mark_as_advanced(ENABLE_SANITIZE_THREAD) - if(ENABLE_SANITIZE_THREAD) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") - endif() endif() ######################################################################## @@ -347,6 +340,11 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") list(APPEND LAMMPS_LINK_LIBS -lwsock32 -lpsapi) endif() +set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific optimization or instrumentation") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_TUNE_FLAGS}") +if(CMAKE_Fortran_FLAGS) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${CMAKE_TUNE_FLAGS}") +endif() ######################################################################## # Basic system tests (standard libraries, headers, functions, types) # ######################################################################## diff --git a/cmake/Modules/Packages/USER-INTEL.cmake b/cmake/Modules/Packages/USER-INTEL.cmake index 3c0cc7ba24..d0941a0a12 100644 --- a/cmake/Modules/Packages/USER-INTEL.cmake +++ b/cmake/Modules/Packages/USER-INTEL.cmake @@ -74,11 +74,6 @@ if(PKG_USER-INTEL) add_definitions(-DLMP_INTEL_OFFLOAD) else() 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_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xCOMMON-AVX512") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost") - endif() include(CheckCXXCompilerFlag) foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict) check_cxx_compiler_flag("${__FLAG}" COMPILER_SUPPORTS${_FLAG}) diff --git a/cmake/presets/clang.cmake b/cmake/presets/clang.cmake index 828f359f54..e2b1e02cc9 100644 --- a/cmake/presets/clang.cmake +++ b/cmake/presets/clang.cmake @@ -13,5 +13,5 @@ set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_CXX "clang++" CACHE STRING "" FORCE) set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE) set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) -set(OpenMP_omp_LIBRARY "/usr/lib64/libomp.so" CACHE PATH "" FORCE) +set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE) diff --git a/cmake/presets/intel.cmake b/cmake/presets/intel.cmake new file mode 100644 index 0000000000..869bf7bca2 --- /dev/null +++ b/cmake/presets/intel.cmake @@ -0,0 +1,17 @@ +# preset that will enable clang/clang++ 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) +set(CMAKE_CXX_FLAGS "-O3 -DNDEBG" CACHE STRING "" FORCE) +set(MPI_CXX "icpc" CACHE STRING "" FORCE) +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_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_CXX "icpc" CACHE STRING "" FORCE) +set(OpenMP_CXX_FLAGS "-qopenmp" CACHE STRING "" FORCE) +set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE) + diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index b2c53bd41d..2f5b517526 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -13,3 +13,5 @@ set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) endforeach() + +set(BUILD_TOOLS ON CACHE BOOL "" FORCE) diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index 51c3fd871d..8ad48b0810 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -213,6 +213,14 @@ A few example command lines are: For compiling with the Clang/LLVM compilers a special CMake preset is included that can be loaded with `-C ../cmake/presets/clang.cmake`. +In addition you can set ``CMAKE_TUNE_FLAGS`` to specifically add compiler +flags to tune for optimal performance on given hosts. By default these are +initialized to some compiler specific flags, where known, to optimize the +LAMMPS executable with optimizations and instructions available on the host +where LAMMPS is compiled. For example, for Intel compilers this would be +``-xHost`` and for GNU compilers this would be ``-march=native``. To turn +these flags off, set ``-D CMAKE_TUNE_FLAGS=``. + .. note:: When the cmake command completes, it prints a summary to the screen diff --git a/doc/src/Build_cmake.rst b/doc/src/Build_cmake.rst index c41136c0a5..06e5a87594 100644 --- a/doc/src/Build_cmake.rst +++ b/doc/src/Build_cmake.rst @@ -22,28 +22,30 @@ Makefile(s). Example: cd lammps # change to the LAMMPS distribution directory mkdir build; cd build # create a new directory (folder) for build cmake [options ...] ../cmake # configuration with (command-line) cmake - make # compilation + cmake --build . # compilation (or type "make") -The cmake command will detect available features, enable selected +The ``cmake`` command will detect available features, enable selected packages and options, and will generate the build environment. By default this build environment will be created for "Unix Makefiles" on most platforms and particularly on Linux. However, alternate build tools (e.g. Ninja) and project files for Integrated Development Environments (IDEs) like Eclipse, CodeBlocks, or Kate can be generated, too. This is -selected via the "-G" command line flag. For the rest of the documentation -we will assume that the build environment is generated for makefiles -and thus the make command will be used to compile and link LAMMPS as -indicated above, producing (by default) an executable called "lmp" and -a library called "liblammps.a" in the "build" folder. When generating -a build environment for the "Ninja" build tool, the build command would -be "ninja" instead of "make". +selected via the ``-G`` command line flag. Further details about features +and settings for CMake are in the `CMake online documentation `_ -If your machine has multiple CPU cores (most do these days), using a -command like "make -jN" (with N being the number of available local -CPU cores) can be much faster. If you plan to do development on -LAMMPS or need to re-compile LAMMPS repeatedly, installation of the -ccache (= Compiler Cache) software may speed up repeated compilation -even more. +.. _cmake_doc: https://cmake.org/documentation/ + +For the rest of the documentation +we will assume that the build environment is generated for "Unix Makefiles" +and thus the ``make`` command will be used to compile and link LAMMPS as +indicated above, producing (by default) an executable called ``lmp`` and +a library called ``liblammps.a`` in the ``build`` folder. + +If your machine has multiple CPU cores (most do these days), you can +compile sources in parallel with a command like ``make -j N`` (with N +being the maximum number of concurrently executed tasks). Also +installation of the ``ccache`` (= Compiler Cache) software may speed +up repeated compilation, e.g. during code development, significantly. After compilation, you may optionally install the LAMMPS executable into your system with: @@ -60,9 +62,11 @@ to ${HOME}/.local ---------- +.. _cmake_build: + There are 3 variants of the CMake command itself: a command-line version -(*cmake* or *cmake3*), a text mode UI version (*ccmake* or *ccmake3*), -and a graphical GUI version (*cmake-gui*). You can use any of them +(``cmake`` or ``cmake3``), a text mode UI version (``ccmake`` or ``ccmake3``), +and a graphical GUI version (``cmake-gui``). You can use any of them interchangeably to configure and create the LAMMPS build environment. On Linux all the versions produce a Makefile as their output by default. See more details on each below. @@ -75,7 +79,7 @@ the :doc:`Build ` doc page. You must perform the CMake build system generation and compilation in a new directory you create. It can be anywhere on your local machine. In these Build pages we assume that you are building in a directory -called "lammps/build". You can perform separate builds independently +called ``lammps/build``. You can perform separate builds independently with different options, so long as you perform each of them in a separate directory you create. All the auxiliary files created by one build process (executable, object files, log files, etc) are stored in @@ -84,10 +88,10 @@ this directory or sub-directories within it that CMake creates. .. note:: To perform a CMake build, no packages can be installed or a build - been previously attempted in the LAMMPS src directory by using "make" + been previously attempted in the LAMMPS src directory by using ``make`` commands to :doc:`perform a conventional LAMMPS build `. CMake detects if this is the case and generates an error, telling you - to type "make no-all purge" in the src directory to un-install all + to type ``make no-all purge`` in the src directory to un-install all packages. The purge removes all the \*.h files auto-generated by make. @@ -123,7 +127,7 @@ command-line options. Several useful ones are: -D CMAKE_INSTALL_PREFIX=path # where to install LAMMPS executable/lib if desired -D CMAKE_BUILD_TYPE=type # type = RelWithDebInfo (default), Release, MinSizeRel, or Debug -G output # style of output CMake generates (e.g. "Unix Makefiles" or "Ninja") - -D CMAKE_MAKE_PROGRAM=builder # name of the builder executable (e.g. set to "gmake" instead of "make") + -D CMAKE_MAKE_PROGRAM=builder # name of the builder executable (e.g. when using "gmake" instead of "make") -DVARIABLE=value # setting for a LAMMPS feature to enable -D VARIABLE=value # ditto, but cannot come after CMakeLists.txt dir -C path/to/preset/file # load some CMake settings before configuring @@ -137,7 +141,7 @@ these forms can be used: yes/no, on/off, 1/0. On Unix/Linux machines, CMake generates a Makefile by default to perform the LAMMPS build. Alternate forms of build info can be generated via the -G switch, e.g. Visual Studio on a Windows machine, -Xcode on MacOS, or KDevelop on Linux. Type "cmake --help" to see the +Xcode on MacOS, or KDevelop on Linux. Type ``cmake --help`` to see the "Generator" styles of output your system supports. .. note:: diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index 4954fb522b..21e99d69be 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -2,7 +2,7 @@ Development build options (CMake only) ====================================== The CMake build of LAMMPS has a few extra options which are useful during -development, testing or debugging. +development, testing or debugging. ---------- @@ -32,20 +32,27 @@ Another way of doing this without reconfiguration is calling make with variable Address, Undefined Behavior, and Thread Sanitizer Support ------------------------------------------------------------------------- -Compilers such as GCC and Clang support generating binaries which use different -sanitizers to detect problems in code during run-time. They can detect `memory leaks `_, -code that runs into `undefined behavior `_ of the -language and `data races `_ in threaded code. +Compilers such as GCC and Clang support generating instrumented binaries +which use different sanitizer libraries to detect problems in code +during run-time. They can detect issues like: -The following settings allow you enable these features if your compiler supports -it. Please note that they come with a performance hit. However, they are -usually faster than using tools like Valgrind. + - `memory leaks `_ + - `undefined behavior `_ + - `data races `_ + +Please note that this kind of instrumentation usually comes with a small +performance hit (much less than using tools like `Valgrind `_). +The to enable these features additional compiler flags need to be added +to the compilation and linking stages. This is most easily done through +setting the ``CMAKE_TUNE_FLAGS`` variable during configuration. Examples: .. code-block:: bash - -D ENABLE_SANITIZE_ADDRESS=value # enable Address Sanitizer, value = no (default) or yes - -D ENABLE_SANITIZE_UNDEFINED=value # enable Undefined Behavior Sanitizer, value = no (default) or yes - -D ENABLE_SANITIZE_THREAD=value # enable Thread Sanitizer, value = no (default) or yes + -D CMAKE_TUNE_FLAGS=-fsanitize=address # enable address sanitizer / memory leak checker + -D CMAKE_TUNE_FLAGS=-fsanitize=undefined # enable undefined behavior sanitizer + -D CMAKE_TUNE_FLAGS=-fsanitize=thread # enable thread sanitizer + +.. _valgrind: https://valgrind.org ---------- diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst index b3d2d3fc56..dabe65ee0f 100644 --- a/doc/src/Build_package.rst +++ b/doc/src/Build_package.rst @@ -146,13 +146,14 @@ one of them as a starting point and customize it to your needs. .. code-block:: bash - cmake -C ../cmake/presets/all_on.cmake [OPTIONS] ../cmake # enable all packages - cmake -C ../cmake/presets/all_off.cmake [OPTIONS] ../cmake # disable all packages cmake -C ../cmake/presets/minimal.cmake [OPTIONS] ../cmake # enable just a few core packages - cmake -C ../cmake/presets/most.cmake [OPTIONS] ../cmake # enable most common packages + cmake -C ../cmake/presets/most.cmake [OPTIONS] ../cmake # enable most packages cmake -C ../cmake/presets/nolib.cmake [OPTIONS] ../cmake # disable packages that do require extra libraries or tools cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake # change settings to use the Clang compilers by default - cmake -C ../cmake/presets/mingw.cmake [OPTIONS] ../cmake # enable all packages compatible with MinGW compilers + cmake -C ../cmake/presets/intel.cmake [OPTIONS] ../cmake # change settings to use the Intel compilers by default + cmake -C ../cmake/presets/mingw.cmake [OPTIONS] ../cmake # enable packages compatible with MinGW compilers for Windows + cmake -C ../cmake/presets/all_on.cmake [OPTIONS] ../cmake # enable all packages + cmake -C ../cmake/presets/all_off.cmake [OPTIONS] ../cmake # disable all packages .. note:: diff --git a/doc/src/Tools.rst b/doc/src/Tools.rst index 6137b1aa6f..8feb2afefa 100644 --- a/doc/src/Tools.rst +++ b/doc/src/Tools.rst @@ -40,33 +40,61 @@ own sub-directories with their own Makefiles and/or README files. Pre-processing tools ==================== -+-----------------------------+------------------------+----------------------+----------------------------------+----------------------------------+-----------------------------+ -| :ref:`amber2lmp ` | :ref:`ch2lmp ` | :ref:`chain ` | :ref:`createatoms ` | :ref:`drude ` | :ref:`eam database ` | -+-----------------------------+------------------------+----------------------+----------------------------------+----------------------------------+-----------------------------+ -| :ref:`eam generate ` | :ref:`eff ` | :ref:`ipp ` | :ref:`micelle2d ` | :ref:`moltemplate ` | :ref:`msi2lmp ` | -+-----------------------------+------------------------+----------------------+----------------------------------+----------------------------------+-----------------------------+ -| :ref:`polybond ` | | | | | | -+-----------------------------+------------------------+----------------------+----------------------------------+----------------------------------+-----------------------------+ +.. table_from_list:: + :columns: 6 + + * :ref:`amber2lmp ` + * :ref:`ch2lmp ` + * :ref:`chain ` + * :ref:`createatoms ` + * :ref:`drude ` + * :ref:`eam database ` + * :ref:`eam generate ` + * :ref:`eff ` + * :ref:`ipp ` + * :ref:`micelle2d ` + * :ref:`moltemplate ` + * :ref:`msi2lmp ` + * :ref:`polybond ` + Post-processing tools ===================== -+--------------------------+----------------------------+------------------------+--------------------------+-------------------------------+-----------------------------+ -| :ref:`amber2lmp ` | :ref:`binary2txt ` | :ref:`ch2lmp ` | :ref:`colvars ` | :ref:`eff ` | :ref:`fep ` | -+--------------------------+----------------------------+------------------------+--------------------------+-------------------------------+-----------------------------+ -| :ref:`lmp2arc ` | :ref:`lmp2cfg ` | :ref:`matlab ` | :ref:`phonon ` | :ref:`pymol_asphere ` | :ref:`python ` | -+--------------------------+----------------------------+------------------------+--------------------------+-------------------------------+-----------------------------+ -| :ref:`reax ` | :ref:`replica ` | :ref:`smd ` | :ref:`spin ` | :ref:`xmgrace ` | | -+--------------------------+----------------------------+------------------------+--------------------------+-------------------------------+-----------------------------+ +.. table_from_list:: + :columns: 6 + + * :ref:`amber2lmp ` + * :ref:`binary2txt ` + * :ref:`ch2lmp ` + * :ref:`colvars ` + * :ref:`eff ` + * :ref:`fep ` + * :ref:`lmp2arc ` + * :ref:`lmp2cfg ` + * :ref:`matlab ` + * :ref:`phonon ` + * :ref:`pymol_asphere ` + * :ref:`python ` + * :ref:`reax ` + * :ref:`replica ` + * :ref:`smd ` + * :ref:`spin ` + * :ref:`xmgrace ` Miscellaneous tools =================== -+--------------------------+----------------------+-------------------+--------------------+---------------------------------------+ -| :ref:`doxygen ` | :ref:`emacs ` | :ref:`i-pi ` | :ref:`kate ` | :ref:`singularity ` | -+--------------------------+----------------------+-------------------+--------------------+---------------------------------------+ -| :ref:`vim ` | | | | | -+--------------------------+----------------------+-------------------+--------------------+---------------------------------------+ +.. table_from_list:: + :columns: 6 + + * :ref:`CMake ` + * :ref:`doxygen ` + * :ref:`emacs ` + * :ref:`i-pi ` + * :ref:`kate ` + * :ref:`singularity ` + * :ref:`vim ` ---------- @@ -157,6 +185,30 @@ See the def.chain or def.chain.ab files in the tools directory for examples of definition files. This tool was used to create the system for the :doc:`chain benchmark `. +---------- + +.. _cmake: + +CMake tools +----------- + +The ``cmbuild`` script is a wrapper around using ``cmake --build +--target`` and allows compiling LAMMPS in a :ref:`CMake build folder +` with a make-like syntax regardless of the actual build +tool and the specific name of the program used (e.g. ``ninja-v1.10`` or +``gmake``) when using ``-D CMAKE_MAKE_PROGRAM=``. + +.. parsed-literal:: + + Usage: cmbuild [-v] [-h] [-C ] [-j ] [] + + Options: + -h print this message + -j allow processing of NUM concurrent tasks + -C DIRECTORY execute build in folder DIRECTORY + -v produce verbose output + + ---------- .. _colvars: diff --git a/doc/src/pair_coul_slater.rst b/doc/src/pair_coul_slater.rst index ce1dafba23..16db7c614a 100644 --- a/doc/src/pair_coul_slater.rst +++ b/doc/src/pair_coul_slater.rst @@ -12,10 +12,10 @@ Syntax .. code-block:: LAMMPS - pair_style coul/slater/cut lamda cutoff - pair_style coul/slater/long lamda cutoff + pair_style coul/slater/cut lambda cutoff + pair_style coul/slater/long lambda cutoff -lamda = decay length of the charge (distance units) +lambda = decay length of the charge (distance units) cutoff = cutoff (distance units) Examples @@ -36,24 +36,23 @@ Description """"""""""" Styles *coul/slater* compute electrostatic interactions in mesoscopic models -which employ potentials without explicit excluded-volume interactions. -The goal is to prevent artificial ionic pair formation by including a charge -distribution in the Coulomb potential, following the formulation of -:ref:`(Melchor) `: +which employ potentials without explicit excluded-volume interactions. +The goal is to prevent artificial ionic pair formation by including a charge +distribution in the Coulomb potential, following the formulation of +:ref:`(Melchor) `: .. math:: - E = \frac{Cq_iq_j}{\epsilon r} \left( 1- \left( 1 + \frac{r_{ij}}{\lambda} exp\left( -2r_{ij}/\lambda \right) \right) \right) \qquad r < r_c - + E = \frac{Cq_iq_j}{\epsilon r} \left( 1- \left( 1 + \frac{r_{ij}}{\lambda} exp\left( -2r_{ij}/\lambda \right) \right) \right) \qquad r < r_c where :math:`r_c` is the cutoff distance and :math:`\lambda` is the decay length of the charge. -C is the same Coulomb conversion factor as in the pair\_styles coul/cut and coul/long. In this way the Coulomb -interaction between ions is corrected at small distances r. -For the *coul/slater/cut* style, the potential energy for distances larger than the cutoff is zero, +C is the same Coulomb conversion factor as in the pair_styles coul/cut and coul/long. In this way the Coulomb +interaction between ions is corrected at small distances r. +For the *coul/slater/cut* style, the potential energy for distances larger than the cutoff is zero, while for the *coul/slater/long*, the long-range interactions are computed either by the Ewald or the PPPM technique. -Phenomena that can be captured at a mesoscopic level using this type of electrostatic -interactions include the formation of polyelectrolyte-surfactant aggregates, +Phenomena that can be captured at a mesoscopic level using this type of electrostatic +interactions include the formation of polyelectrolyte-surfactant aggregates, charge stabilization of colloidal suspensions, and the formation of complexes driven by charged species in biological systems. :ref:`(Vaiwala) `. @@ -66,17 +65,15 @@ commands: * :math:`r_c` (distance units) -The global decay length of the charge (:math:`\lambda`) specified in the pair\_style command is used for all pairs. - +The global decay length of the charge (:math:`\lambda`) specified in the pair_style command is used for all pairs. ---------- - **Mixing, shift, table, tail correction, restart, rRESPA info**\ : For atom type pairs I,J and I != J, the cutoff distance for the *coul/slater* styles can be mixed. The default mix value is *geometric*\ . -See the "pair\_modify" command for details. +See the "pair_modify" command for details. The :doc:`pair_modify ` shift and table options are not relevant for these pair styles. @@ -85,7 +82,7 @@ These pair styles do not support the :doc:`pair_modify ` tail option for adding long-range tail corrections to energy and pressure. -These pair styles write their information to :doc:`binary restart files `, so pair\_style and pair\_coeff commands do not need +These pair styles write their information to :doc:`binary restart files `, so pair_style and pair_coeff commands do not need to be specified in an input script that reads a restart file. This pair style can only be used via the *pair* keyword of the @@ -95,7 +92,7 @@ This pair style can only be used via the *pair* keyword of the Restrictions """""""""""" -The *coul/slater/long* style requires the long-range solvers included in the KSPACE package. +The *coul/slater/long* style requires the long-range solvers included in the KSPACE package. These styles are part of the "USER-MISC" package. They are only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. @@ -109,13 +106,11 @@ Related commands ---------- - .. _Melchor: -**(Melchor)** Gonzalez-Melchor, Mayoral, Velázquez, and Alejandre, J Chem Phys, 125, 224107 (2006). +**(Melchor)** Gonzalez-Melchor, Mayoral, Velazquez, and Alejandre, J Chem Phys, 125, 224107 (2006). .. _Vaiwala: **(Vaiwala)** Vaiwala, Jadhav, and Thaokar, J Chem Phys, 146, 124904 (2017). - diff --git a/doc/src/pair_granular.rst b/doc/src/pair_granular.rst index 73b1ec85ec..f581c502f3 100644 --- a/doc/src/pair_granular.rst +++ b/doc/src/pair_granular.rst @@ -770,7 +770,7 @@ in contact. J. Appl. Mech., ASME 16, 259-268. .. _Thornton2013: **(Thornton et al, 2013)** Thornton, C., Cummins, S. J., & Cleary, -P. W. (2013). An investigation of the comparative behaviour of +P. W. (2013). An investigation of the comparative behavior of alternative contact force models during inelastic collisions. Powder Technology, 233, 30-46. diff --git a/doc/utils/sphinx-config/_themes/lammps_theme/breadcrumbs.html b/doc/utils/sphinx-config/_themes/lammps_theme/breadcrumbs.html index 1eb53c70a2..7c3bd2d6f4 100644 --- a/doc/utils/sphinx-config/_themes/lammps_theme/breadcrumbs.html +++ b/doc/utils/sphinx-config/_themes/lammps_theme/breadcrumbs.html @@ -1,5 +1,4 @@
-
LAMMPS {{ version }}
  • Docs »
  • {% for doc in parents %} @@ -22,7 +21,7 @@ {% endif %}
-
+
{% if next or prev %} {% endif %} -
+

diff --git a/doc/utils/sphinx-config/_themes/lammps_theme/layout.html b/doc/utils/sphinx-config/_themes/lammps_theme/layout.html index 9e672151d1..3d11a92b32 100644 --- a/doc/utils/sphinx-config/_themes/lammps_theme/layout.html +++ b/doc/utils/sphinx-config/_themes/lammps_theme/layout.html @@ -100,6 +100,8 @@ {% endif %} +

Version: {{ version }}
+ {% include "searchbox.html" %} {% endblock %} diff --git a/doc/utils/sphinx-config/_themes/lammps_theme/static/css/theme.css b/doc/utils/sphinx-config/_themes/lammps_theme/static/css/theme.css index 5e0d43b128..303222df8a 100644 --- a/doc/utils/sphinx-config/_themes/lammps_theme/static/css/theme.css +++ b/doc/utils/sphinx-config/_themes/lammps_theme/static/css/theme.css @@ -4189,8 +4189,7 @@ div[class^='highlight'] pre { } } .wy-affix { - position: fixed; - top: 1.618em; + position: fixed; top: 0.618em; } .wy-menu a:hover { @@ -4411,7 +4410,7 @@ div[class^='highlight'] pre { font-weight: bold; display: inline-block; padding: 4px 6px; - margin-bottom: 0.809em; + /*margin-bottom: 0.809em;*/ } .wy-side-nav-search > a:hover, .wy-side-nav-search .wy-dropdown > a:hover { background: rgba(255, 255, 255, 0.1); @@ -4540,7 +4539,7 @@ div[class^='highlight'] pre { } .wy-nav-content { - padding: 1.618em 3.236em; + padding: 0.5em 1.0em; height: 100%; margin: auto; } @@ -5105,4 +5104,10 @@ span[id*='MathJax-Span'] { padding: 0; } +.lammps_version { + text-align: center; + display: block; + margin-bottom: 0.809em; +} + /*# sourceMappingURL=theme.css.map */ diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 6eb824e482..9553504673 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -202,7 +202,6 @@ bcolor bdiam bdw Beckman -behaviour Belak Bellott benchmarking @@ -2559,8 +2558,7 @@ Salles sandia Sandia sandybrown -Sanitizer -sanitizers +sanitizer Sanyal sc scafacos diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 81f96ad668..00615c740e 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1659,7 +1659,7 @@ int PPPMDisp::check_convergence(double** A,double** Q,double** A0, allocate memory that depends on # of K-vectors and order ------------------------------------------------------------------------- */ -void PPPMDisp::allocate() +void _noopt PPPMDisp::allocate() { int (*procneigh)[2] = comm->procneigh; diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index 2763c561d6..10ab1d7080 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -5017,7 +5017,7 @@ double PairBOP::PiBo(int itmp, int jtmp) /* ---------------------------------------------------------------------- */ -void PairBOP::read_table(char *filename) +void _noopt PairBOP::read_table(char *filename) { int i,j,k,n,m; int buf1,pass; diff --git a/src/USER-MEAMC/meam.h b/src/USER-MEAMC/meam.h index 719e1af6f0..b4f8fd341b 100644 --- a/src/USER-MEAMC/meam.h +++ b/src/USER-MEAMC/meam.h @@ -214,7 +214,7 @@ protected: void alloyparams(); void compute_pair_meam(); double phi_meam(double, int, int); - const double phi_meam_series(const double scrn, const int Z1, const int Z2, const int a, const int b, const double r, const double arat); + double phi_meam_series(const double scrn, const int Z1, const int Z2, const int a, const int b, const double r, const double arat); void compute_reference_density(); void get_tavref(double*, double*, double*, double*, double*, double*, double, double, double, double, double, double, double, int, int, lattice_t); diff --git a/src/USER-MEAMC/meam_setup_done.cpp b/src/USER-MEAMC/meam_setup_done.cpp index b37f56dda2..25f1bb9e81 100644 --- a/src/USER-MEAMC/meam_setup_done.cpp +++ b/src/USER-MEAMC/meam_setup_done.cpp @@ -163,11 +163,10 @@ MEAM::alloyparams(void) void MEAM::compute_pair_meam(void) { - - double r, b2nn, phi_val; + double r; int j, a, b, nv2; double astar, frac, phizbl; - int n, Z1, Z2; + int Z1, Z2; double arat, rarat, scrn, scrn2; double phiaa, phibb /*unused:,phitmp*/; double C, s111, s112, s221, S11, S22; @@ -320,7 +319,7 @@ MEAM::phi_meam(double r, int a, int b) double Eu; double arat, scrn, scrn2; int Z12, errorflag; - int n, Z1nn, Z2nn; + int Z1nn, Z2nn; lattice_t latta /*unused:,lattb*/; double rho_bkgd1, rho_bkgd2; double b11s, b22s; @@ -519,7 +518,7 @@ MEAM::phi_meam(double r, int a, int b) // To avoid nan values of phir due to rapid decrease of b2nn^n or/and // argument of phi_meam, i.e. r*arat^n, in some cases (3NN dia with low Cmin value) // -const double +double MEAM::phi_meam_series(const double scrn, const int Z1, const int Z2, const int a, const int b, const double r, const double arat) { double phi_sum = 0.0; diff --git a/src/atom.cpp b/src/atom.cpp index 1396eb596c..f2ee14291a 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -973,16 +973,23 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset, error->all(FLERR,"Incorrect atom format in data file"); } - if (imageflag) - imagedata = ((imageint) (atoi(values[iptr]) + IMGMAX) & IMGMASK) | - (((imageint) (atoi(values[iptr+1]) + IMGMAX) & IMGMASK) << IMGBITS) | - (((imageint) (atoi(values[iptr+2]) + IMGMAX) & IMGMASK) << IMG2BITS); - else imagedata = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; + int imx = 0; + int imy = 0; + int imz = 0; + if (imageflag) { + imx = utils::inumeric(FLERR,values[iptr],false,lmp); + imy = utils::inumeric(FLERR,values[iptr+1],false,lmp); + imz = utils::inumeric(FLERR,values[iptr+2],false,lmp); + if ((domain->dimension == 2) && (imz != 0)) + error->all(FLERR,"Z-direction image flag must be 0 for 2d-systems"); + } + imagedata = ((imageint) (imx + IMGMAX) & IMGMASK) | + (((imageint) (imy + IMGMAX) & IMGMASK) << IMGBITS) | + (((imageint) (imz + IMGMAX) & IMGMASK) << IMG2BITS); - xdata[0] = atof(values[xptr]); - xdata[1] = atof(values[xptr+1]); - xdata[2] = atof(values[xptr+2]); + xdata[0] = utils::numeric(FLERR,values[xptr],false,lmp); + xdata[1] = utils::numeric(FLERR,values[xptr+1],false,lmp); + xdata[2] = utils::numeric(FLERR,values[xptr+2],false,lmp); if (shiftflag) { xdata[0] += shift[0]; xdata[1] += shift[1]; diff --git a/src/fix_numdiff.cpp b/src/fix_numdiff.cpp index 23c982725e..0fc5b4ada0 100644 --- a/src/fix_numdiff.cpp +++ b/src/fix_numdiff.cpp @@ -40,8 +40,8 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixNumDiff::FixNumDiff(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), numdiff_forces(NULL), temp_f(NULL), - id_pe(NULL) + Fix(lmp, narg, arg), id_pe(NULL), numdiff_forces(NULL), + temp_x(NULL), temp_f(NULL) { if (narg < 5) error->all(FLERR,"Illegal fix numdiff command"); @@ -68,9 +68,6 @@ FixNumDiff::FixNumDiff(LAMMPS *lmp, int narg, char **arg) : delete [] newarg; maxatom = 0; - numdiff_forces = NULL; - temp_x = NULL; - temp_f = NULL; if (atom->map_style == 0) error->all(FLERR,"Fix numdiff requires an atom map, see atom_modify"); @@ -156,7 +153,7 @@ void FixNumDiff::min_setup(int vflag) /* ---------------------------------------------------------------------- */ -void FixNumDiff::post_force(int vflag) +void FixNumDiff::post_force(int /* vflag */) { if (update->ntimestep % nevery) return; diff --git a/src/molecule.cpp b/src/molecule.cpp index a8bf469a4a..15b2385436 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -45,8 +45,8 @@ Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) : improper_type(NULL), improper_atom1(NULL), improper_atom2(NULL), improper_atom3(NULL), improper_atom4(NULL), nspecial(NULL), special(NULL), shake_flag(NULL), shake_atom(NULL), shake_type(NULL), avec_body(NULL), ibodyparams(NULL), - dbodyparams(NULL), dx(NULL), dxcom(NULL), dxbody(NULL), quat_external(NULL), - fp(NULL), count(NULL), fragmentmask(NULL) + dbodyparams(NULL), fragmentmask(NULL), fragmentnames(NULL), + dx(NULL), dxcom(NULL), dxbody(NULL), quat_external(NULL), fp(NULL), count(NULL) { me = comm->me; @@ -1569,10 +1569,12 @@ void Molecule::allocate() if (xflag) memory->create(x,natoms,3,"molecule:x"); if (typeflag) memory->create(type,natoms,"molecule:type"); if (moleculeflag) memory->create(molecule,natoms,"molecule:molecule"); - if (fragmentflag) fragmentnames = new char*[nfragments]; - if (fragmentflag) memory->create(fragmentmask,nfragments,natoms,"molecule:fragmentmask"); - for (int i = 0; i < nfragments; i++) - for (int j = 0; j < natoms; j++) fragmentmask[i][j] = 0; + if (fragmentflag) { + fragmentnames = new char*[nfragments]; + memory->create(fragmentmask,nfragments,natoms,"molecule:fragmentmask"); + for (int i = 0; i < nfragments; i++) + for (int j = 0; j < natoms; j++) fragmentmask[i][j] = 0; + } if (qflag) memory->create(q,natoms,"molecule:q"); if (radiusflag) memory->create(radius,natoms,"molecule:radius"); if (rmassflag) memory->create(rmass,natoms,"molecule:rmass"); @@ -1665,6 +1667,7 @@ void Molecule::deallocate() memory->destroy(radius); memory->destroy(rmass); + memory->destroy(molecule); memory->destroy(fragmentmask); if (fragmentflag) { for (int i = 0; i < nfragments; i++) delete [] fragmentnames[i]; diff --git a/src/molecule.h b/src/molecule.h index 757eb3415c..49d0cd1ef0 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -34,10 +34,6 @@ class Molecule : protected Pointers { int nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; int nibody,ndbody; - // fragment info - char **fragmentnames; - int **fragmentmask; // nfragments by natoms - // max bond,angle,etc per atom int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; @@ -95,6 +91,11 @@ class Molecule : protected Pointers { int *ibodyparams; // integer and double body params double *dbodyparams; + // fragment info + + int **fragmentmask; // nfragments by natoms + char **fragmentnames; + double center[3]; // geometric center of molecule double masstotal; // total mass of molecule double com[3]; // center of mass of molecule diff --git a/src/utils.cpp b/src/utils.cpp index f6556a3ac8..5e0db6afb9 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -84,29 +84,6 @@ bool utils::strmatch(std::string text, std::string pattern) return (pos >= 0); } -/* utility function to avoid code repetition when parsing args */ -int utils::cfvarg(std::string mode, const char *arg, char *&cfv_id) -{ - int rv = utils::NONE; - cfv_id = NULL; - - if (!arg) return rv; - - if (utils::strmatch(arg,std::string("^[") + mode + "]_")) { - if (*arg == 'c') rv = utils::COMPUTE; - else if (*arg == 'f') rv = utils::FIX; - else if (*arg == 'v') rv = utils::VARIABLE; - else return rv; // should not happen - - arg += 2; - int n = strlen(arg)+1; - cfv_id = new char[n]; - strcpy(cfv_id,arg); - } - - return rv; -} - /** \brief try to detect pathname from FILE pointer. Currently only supported on Linux, otherwise will report "(unknown)". * * \param buf storage buffer for pathname. output will be truncated if not large enough diff --git a/src/utils.h b/src/utils.h index e87aa4bb91..45fb95aaac 100644 --- a/src/utils.h +++ b/src/utils.h @@ -36,25 +36,6 @@ namespace LAMMPS_NS { */ bool strmatch(std::string text, std::string pattern); - /** Categories of special arguments for cfvarg() function - * - * Enum starts from 100 to avoid conflicts with other local define flags - */ - enum {NONE=100, /// does not match any category - COMPUTE, /// processed a compute - FIX, /// processed a fix - VARIABLE /// processed a variable - }; - - /** \brief Convenience function to process 'c_', 'f_', and 'v_' arguments - * - * \param mode types to search for. 1-3 char string from 'c', 'f', or 'v' - * \param arg argument string to test against the prefixes - * \param cfv_id name or ID of the compute, fix, or variable - * \return utils::COMPUTE, utils::FIX, utils::VARIABLE or utils::NONE - */ - int cfvarg(std::string mode, const char *arg, char *&cfv_id); - /** \brief safe wrapper around fgets() which aborts on errors * or EOF and prints a suitable error message to help debugging * diff --git a/tools/README b/tools/README index b20e82c53e..2a6f28caf0 100644 --- a/tools/README +++ b/tools/README @@ -12,36 +12,37 @@ at. These are the included tools: -amber2lmp python scripts for using AMBER to setup LAMMPS input -binary2txt convert a LAMMPS dump file from binary to ASCII text -ch2lmp convert CHARMM files to LAMMPS input -chain create a data file of bead-spring chains -colvars post-process output of the fix colvars command -createatoms generate lattices of atoms within a geometry +amber2lmp python scripts for using AMBER to setup LAMMPS input +binary2txt convert a LAMMPS dump file from binary to ASCII text +ch2lmp convert CHARMM files to LAMMPS input +chain create a data file of bead-spring chains +cmake tools and scripts for use with CMake +colvars post-process output of the fix colvars command +createatoms generate lattices of atoms within a geometry drude create Drude core/electron atom pairs in a data file -eam_database one tool to generate EAM alloy potential files -eam_generate 2nd tool to generate EAM alloy potential files -eff scripts for working with the eFF (electron force field) -emacs add-ons to EMACS editor for editing LAMMPS input scripts -fep scripts for free-energy perturbation with USER-FEP pkg +eam_database one tool to generate EAM alloy potential files +eam_generate 2nd tool to generate EAM alloy potential files +eff scripts for working with the eFF (electron force field) +emacs add-ons to EMACS editor for editing LAMMPS input scripts +fep scripts for free-energy perturbation with USER-FEP pkg i-pi Python wrapper for performing path-integral MD (PIMD) -ipp input pre-processor Perl tool for creating input scripts +ipp input pre-processor Perl tool for creating input scripts kate add-ons to Kate editor for editing LAMMPS input scripts -lmp2arc convert LAMMPS output to Accelrys Insight format -lmp2cfg convert LAMMPS output to CFG files for AtomEye viz -matlab MatLab scripts for post-processing LAMMPS output -micelle2d create a data file of small lipid chains in solvent +lmp2arc convert LAMMPS output to Accelrys Insight format +lmp2cfg convert LAMMPS output to CFG files for AtomEye viz +matlab MatLab scripts for post-processing LAMMPS output +micelle2d create a data file of small lipid chains in solvent moltemplate Instructions for installing the Moltemplate builder program -msi2lmp use Accelrys Insight code to setup LAMMPS input +msi2lmp use Accelrys Insight code to setup LAMMPS input phonon post-process output of the fix phonon command polybond Python tool for programmable polymer bonding -pymol_asphere convert LAMMPS output of ellipsoids to PyMol format -python Python scripts for post-processing LAMMPS output -reax Tools for analyzing output of ReaxFF simulations -replica tool to reorder LAMMPS replica trajectories according to temperature +pymol_asphere convert LAMMPS output of ellipsoids to PyMol format +python Python scripts for post-processing LAMMPS output +reax Tools for analyzing output of ReaxFF simulations +replica tool to reorder LAMMPS replica trajectories according to temperature smd convert Smooth Mach Dynamics triangles to VTK spin perform a cubic polynomial interpolation of a GNEB MEP -vim add-ons to VIM editor for editing LAMMPS input scripts +vim add-ons to VIM editor for editing LAMMPS input scripts xmgrace a collection of scripts to generate xmgrace plots For tools that are single C, C++, or Fortran files, a Makefile for diff --git a/tools/cmake/cmbuild b/tools/cmake/cmbuild new file mode 100755 index 0000000000..f9e0f87390 --- /dev/null +++ b/tools/cmake/cmbuild @@ -0,0 +1,69 @@ +#!/bin/bash +# make like wrapper around "cmake --build" +# (c) 2020 Axel Kohlmeyer +# This file is in the public domain + +WORKDIR="${PWD}" +PARAMS="" +MYARGS="" + +usage() +{ + echo "Usage: cmbuild [-v] [-h] [-C ] [-j ] []" >&2 +} + +help() +{ + usage + cat >&2 < allow processing of NUM concurrent tasks + -C DIRECTORY execute build in folder DIRECTORY + -v produce verbose output +EOF +} + +while (( "$#" )); do + case "$1" in + -C) + WORKDIR="$2" + shift 2 + ;; + -v) + MYARGS="${MYARGS} -v" + shift + ;; + -h) + help + exit 2 + ;; + -j) + MYARGS="${MYARGS} -j $2" + shift 2 + ;; + --) + shift + break + ;; + -*) + echo "Error: Unsupported flag $1" >&2 + echo + usage + exit 1 + ;; + *) + PARAMS="${PARAMS} $1" + shift + ;; + esac +done + +if [ ! -f "${WORKDIR}/CMakeCache.txt" ] ; then + echo "Must execute in a CMake build directory or use -C flag to select one" >&2 + exit 3 +fi + +eval set -- "${PARAMS} $@" +exec cmake --build "${WORKDIR}" ${MYARGS} --target "$@" diff --git a/tools/singularity/centos8.def b/tools/singularity/centos8.def index b48979cab1..e0a14c4156 100644 --- a/tools/singularity/centos8.def +++ b/tools/singularity/centos8.def @@ -2,12 +2,12 @@ BootStrap: docker From: centos:8 %post - dnf -y install epel-release dnf-utils + dnf -y install epel-release dnf-utils dnf config-manager --set-enabled PowerTools dnf -y update - dnf -y install vim-enhanced ccache gcc-c++ gcc-gfortran clang gdb make cmake patch which file git libpng-devel libjpeg-devel openmpi-devel mpich-devel fftw-devel voro++-devel gsl-devel enchant platform-python-devel python3-virtualenv valgrind openblas ninja-build eigen3-devel + dnf -y install vim-enhanced ccache gcc-c++ gcc-gfortran clang gdb make cmake patch which file git libpng-devel libjpeg-devel openmpi-devel mpich-devel fftw-devel voro++-devel gsl-devel enchant platform-python-devel python3-virtualenv valgrind openblas ninja-build eigen3-devel libubsan libasan libtsan #No match for argument: valgrind-openmpi %labels - Author akohlmey + Author akohlmey