Skip to content

Commit a592e5e

Browse files
authored
Merge branch 'develop' into saip-TMDC-Metal
2 parents 25532ae + 532dcf5 commit a592e5e

24 files changed

+773
-63
lines changed

cmake/CMakeLists.txt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -779,16 +779,17 @@ if(_index GREATER -1)
779779
target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
780780
endif()
781781
set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h command.h compute.h dihedral.h domain.h
782-
error.h exceptions.h fix.h force.h group.h improper.h input.h info.h kspace.h lammps.h lattice.h
783-
library.h lmppython.h lmptype.h memory.h modify.h neighbor.h neigh_list.h output.h pair.h
784-
platform.h pointers.h region.h timer.h universe.h update.h utils.h variable.h)
782+
error.h exceptions.h fix.h force.h group.h improper.h input.h info.h json.h json_fwd.h kspace.h
783+
lammps.h lattice.h library.h lmppython.h lmptype.h memory.h modify.h neighbor.h neigh_list.h
784+
output.h pair.h platform.h pointers.h region.h timer.h universe.h update.h utils.h variable.h)
785785
set(LAMMPS_FMT_HEADERS core.h format.h)
786+
set(LAMMPS_JSON_HEADERS json_fwd.hpp json.hpp)
786787

787788
set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_MACHINE})
788789
set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION})
789790
set_target_properties(lammps PROPERTIES PREFIX "lib")
790-
target_include_directories(lammps PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lammps>)
791-
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/fmt)
791+
target_include_directories(lammps PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
792+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/fmt ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/nlohmann)
792793
foreach(_HEADER ${LAMMPS_CXX_HEADERS})
793794
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_SOURCE_DIR}/${_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} DEPENDS ${LAMMPS_SOURCE_DIR}/${_HEADER})
794795
add_custom_target(${_HEADER} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER})
@@ -805,6 +806,14 @@ foreach(_HEADER ${LAMMPS_FMT_HEADERS})
805806
install(FILES ${LAMMPS_SOURCE_DIR}/fmt/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps/fmt)
806807
endif()
807808
endforeach()
809+
foreach(_HEADER ${LAMMPS_JSON_HEADERS})
810+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/nlohmann/${_HEADER} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_SOURCE_DIR}/nlohmann/${_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/nlohmann/${_HEADER} DEPENDS ${LAMMPS_SOURCE_DIR}/nlohmann/${_HEADER})
811+
add_custom_target(json_${_HEADER} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/nlohmann/${_HEADER})
812+
add_dependencies(lammps json_${_HEADER})
813+
if(BUILD_SHARED_LIBS)
814+
install(FILES ${LAMMPS_SOURCE_DIR}/nlohmann/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps/nlohmann)
815+
endif()
816+
endforeach()
808817
target_include_directories(lammps INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/includes>)
809818
add_library(LAMMPS::lammps ALIAS lammps)
810819
get_target_property(LAMMPS_DEFINES lammps INTERFACE_COMPILE_DEFINITIONS)
@@ -827,7 +836,7 @@ if(BUILD_SHARED_LIBS)
827836
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
828837
install(EXPORT LAMMPS_Targets FILE LAMMPS_Targets.cmake NAMESPACE LAMMPS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
829838
include(CMakePackageConfigHelpers)
830-
configure_file(LAMMPSConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake @ONLY)
839+
configure_file(LAMMPSConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" @ONLY)
831840
write_basic_package_version_file("LAMMPSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion)
832841
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
833842
endif()

cmake/LAMMPSConfig.cmake.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
# created by cmake version @CMAKE_VERSION@ for LAMMPS version @PROJECT_VERSION@
2+
13
include(CMakeFindDependencyMacro)
24
if(@BUILD_MPI@)
35
find_dependency(MPI REQUIRED CXX)
46
endif()
7+
if(@BUILD_OMP@)
8+
find_dependency(OpenMP REQUIRED CXX)
9+
endif()
510
include("${CMAKE_CURRENT_LIST_DIR}/LAMMPS_Targets.cmake")
11+
add_library(LAMMPS::LAMMPS ALIAS LAMMPS::lammps)
12+
13+
get_target_property(LAMMPS_CONFIG LAMMPS::lammps IMPORTED_CONFIGURATIONS)
14+
get_target_property(LAMMPS_LIBRARY LAMMPS::lammps IMPORTED_LOCATION_${LAMMPS_CONFIG})
15+
get_target_property(LAMMPS_INCLUDE_DIR LAMMPS::lammps INTERFACE_INCLUDE_DIRECTORIES)
16+
17+
include(FindPackageHandleStandardArgs)
18+
find_package_handle_standard_args(LAMMPS
19+
REQUIRED_VARS LAMMPS_LIBRARY LAMMPS_INCLUDE_DIR
20+
VERSION_VAR PACKAGE_VERSION
21+
HANDLE_VERSION_RANGE
22+
)

doc/src/Build_cmake.rst

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,78 @@ defaults to ``${HOME}/.local``.
126126
root) the `ldconfig` program to update the cache file for fast lookup
127127
of system shared libraries.
128128

129+
.. admonition:: Using the installed library
130+
:class: Hint
131+
132+
The CMake installation functionality is an experimental work in
133+
progress and thus not without problems, especially when writing your
134+
own program that is trying to use the LAMMPS C++ classes directly.
135+
136+
While there is a well-defined :ref:`C-language interface
137+
<lammps_c_api>` with the ``library.h`` header file, there is no
138+
equivalent for the C++ interface yet. When installing LAMMPS,
139+
only the core header files are copied into the installation folder
140+
and thus only high-level access to C++ features is available.
141+
142+
The following is a minimal CMake example file for using the installed
143+
LAMMPS package which represents the current state of development:
144+
145+
.. code-block:: cmake
146+
147+
cmake_minimum_required(VERSION 3.20)
148+
project(simpleCC CXX)
149+
# set this to the LAMMPS installation location
150+
if(NOT CMAKE_PREFIX_PATH)
151+
set(CMAKE_PREFIX_PATH $ENV{HOME}/.local)
152+
endif()
153+
find_package(LAMMPS REQUIRED)
154+
add_executable(simpleCC simple.cpp)
155+
target_link_libraries(simpleCC PRIVATE LAMMPS::LAMMPS)
156+
157+
The ``CMAKE_PREFIX_PATH`` setting tells CMake where to find the
158+
generated CMake configuration files for the `find_package()
159+
<https://cmake.org/cmake/help/latest/command/find_package.html>`_
160+
CMake command. You can also specify a required minimal version or
161+
version range. For that a numeric representation in the "YYYY.MM.DD"
162+
format has to be used: the 10 September 2025 release thus becomes
163+
version 2025.09.10. The include statements in the ``simple.cpp``
164+
source file have to be prefixed with ``lammps/`` as follows:
165+
166+
.. code-block:: C++
167+
168+
#include <lammps/lammps.h>
169+
#include <lammps/input.h>
170+
#include <lammps/atom.h>
171+
#include <lammps/library.h>
172+
173+
Using the ``LAMMPS::LAMMPS`` target imported from the installed
174+
LAMMPS CMake configuration files should set up the include and linker
175+
flags and folders automatically. Below is the output for an example
176+
session (note how it checks for and includes MPI and OpenMP support
177+
since that specific LAMMPS library was set up this way):
178+
179+
.. code-block:: console
180+
181+
$ cmake -S . -B build -D CMAKE_PREFIX_PATH=$HOME/Downloads/test-install
182+
-- The CXX compiler identification is GNU 15.2.1
183+
-- Detecting CXX compiler ABI info
184+
-- Detecting CXX compiler ABI info - done
185+
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
186+
-- Detecting CXX compile features
187+
-- Detecting CXX compile features - done
188+
-- Found MPI_CXX: /usr/lib64/mpich/lib/libmpicxx.so (found version "4.1")
189+
-- Found MPI: TRUE (found version "4.1") found components: CXX
190+
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
191+
-- Found OpenMP: TRUE (found version "4.5") found components: CXX
192+
-- Found LAMMPS: /home/akohlmey/Downloads/test-install/lib64/liblammps.so.0
193+
-- Configuring done (0.9s)
194+
-- Generating done (0.0s)
195+
-- Build files have been written to: /home/akohlmey/Downloads/test-simple/build
196+
$ cmake --build build
197+
[ 50%] Building CXX object CMakeFiles/simpleCC.dir/simple.cpp.o
198+
[100%] Linking CXX executable simpleCC
199+
[100%] Built target simpleCC
200+
129201
.. _cmake_options:
130202

131203
Configuration and build options

doc/src/Commands_compute.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ KOKKOS, o = OPENMP, t = OPT.
161161
* :doc:`temp/asphere <compute_temp_asphere>`
162162
* :doc:`temp/body <compute_temp_body>`
163163
* :doc:`temp/chunk <compute_temp_chunk>`
164-
* :doc:`temp/com <compute_temp_com>`
164+
* :doc:`temp/com (k) <compute_temp_com>`
165165
* :doc:`temp/cs <compute_temp_cs>`
166166
* :doc:`temp/deform (k) <compute_temp_deform>`
167167
* :doc:`temp/deform/eff <compute_temp_deform_eff>`

doc/src/Run_formats.rst

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ For floating point numbers in scientific notation, the Fortran double
7878
precision notation "1.1d3" is not accepted; you have to use "1100",
7979
"1100.0" or "1.1e3".
8080

81-
Input file
81+
Input File
8282
^^^^^^^^^^
8383

8484
A LAMMPS input file is a text file with commands. It is read
@@ -161,7 +161,7 @@ recommended to always have an empty line at the end of an input file.
161161
The specific details describing how LAMMPS input is processed and parsed
162162
are explained in :doc:`Commands_parse`.
163163

164-
Data file
164+
Data File
165165
^^^^^^^^^
166166

167167
A LAMMPS data file contains a description of a system suitable for
@@ -302,7 +302,7 @@ Molecule-ID', one for each atom in the system. For adding charges to
302302
atom style molecular with fix property/atom, the "Atoms" section is now
303303
formatted according to the atom style and a "Charges" section is added.
304304

305-
Molecule file
305+
Molecule File
306306
^^^^^^^^^^^^^
307307

308308
Molecule files for use with the :doc:`molecule command <molecule>` look
@@ -376,7 +376,7 @@ if the molecule command is issued *before* the simulation box is
376376
defined. Otherwise, the molecule command can derive the required
377377
settings internally.
378378

379-
Restart file
379+
Restart File
380380
^^^^^^^^^^^^
381381

382382
LAMMPS restart files are binary files and not available in text format.
@@ -409,6 +409,69 @@ are in the ``lmprestart.h`` header file.
409409
LAMMPS restart files are not expected to be portable between platforms
410410
or LAMMPS versions, but changes to the file format are rare.
411411

412+
.. _json-dump-files:
413+
414+
JSON Dump Files
415+
^^^^^^^^^^^^^^^
416+
417+
LAMMPS can print information about molecules and other sets of atoms during
418+
a run, in JSON format. Several fixes currently support dumping JSON files
419+
in the 'molecules' style, including :doc:`fix bond/react <fix_bond_react>`
420+
and the *delete* keyword of :doc:`fix reaxff/species <fix_reaxff_species>`.
421+
The JSON 'dump molecules' format lists sets of atoms in the style of the
422+
:doc:`JSON molecule file <molecule>`, where more discussion of JSON schema
423+
can be found. Here is an generic example of a JSON output file that dumped
424+
one water molecule on the first timestep:
425+
426+
.. code-block:: json
427+
428+
{
429+
"application": "LAMMPS",
430+
"units": "real",
431+
"format": "dump",
432+
"style": "molecules",
433+
"revision": 1,
434+
"timesteps": [
435+
{
436+
"timestep": 1,
437+
"molecules": [
438+
{
439+
"types": {
440+
"format": ["atom-id", "type"],
441+
"data": [
442+
[1368, "H"],
443+
[1366, "O"],
444+
[1367, "H"]
445+
]
446+
},
447+
"coords": {
448+
"format": ["atom-id", "x", "y", "z"],
449+
"data": [
450+
[1368, 26.787767440427466, 29.785528640296768, 25.85197353660144],
451+
[1366, 26.641801222582824, 29.868106247702887, 24.91285138212243],
452+
[1367, 25.69611192416744, 30.093425787807448, 24.914380215672846]
453+
]
454+
}
455+
}
456+
]
457+
}
458+
]
459+
}
460+
461+
The required first-level keys of the JSON format output are "application",
462+
"format", "style", "revision", and "timesteps", and optional keys are
463+
"units" and "title". The value of the "timesteps" key is an array of
464+
objects that contain data for each timestep on which a molecule was dumped,
465+
and the other first-level keys identify this JSON schema. The objects in
466+
"timesteps" contains two mandatory keys, "timestep" and "molecules". The
467+
"molecules" key is an array of :doc:`LAMMPS molecule JSON <molecule>`
468+
objects, and may contain other keys that contain metadata for each
469+
molecule. The "format" keys within molecule JSON objects are only printed
470+
once per output file, for brevity. The "atom-id" values are atom IDs from
471+
the simulation, and the "type" values are atom types. In the above
472+
example, the types were reported as strings corresponding to elements using
473+
:doc:`type labels <labelmap>`.
474+
412475
.. Native Dump file
413476
.. ^^^^^^^^^^^^^^^^
414477
..

doc/src/compute_temp_com.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
.. index:: compute temp/com
2+
.. index:: compute temp/com/kk
23

34
compute temp/com command
45
========================
56

7+
Accelerator Variants: *temp/com/kk*
8+
69
Syntax
710
""""""
811

@@ -82,6 +85,12 @@ See the :doc:`Howto thermostat <Howto_thermostat>` page for a
8285
discussion of different ways to compute temperature and perform
8386
thermostatting.
8487

88+
----------
89+
90+
.. include:: accel_styles.rst
91+
92+
----------
93+
8594
Output info
8695
"""""""""""
8796

doc/src/fix_bond_react.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Syntax
4141
Nlimit = maximum total number of reactions allowed to occur
4242
*shuffle_seed* value = seed
4343
seed = random # seed (positive integer) for choosing between eligible reactions
44+
*file* value = filename
45+
filename = name of the JSON file that records reaction occurrences
4446
4547
* react = mandatory argument indicating new reaction specification
4648
* react-ID = user-assigned name for the reaction
@@ -244,6 +246,52 @@ if available; reactions are chosen deterministically if a positive integer
244246
is specified for the 'shuffle_seed' keyword. Multiple *max_rxn* keywords
245247
can be specified.
246248

249+
The *file* keyword can be used to dump information about each reaction that
250+
occurs during the simulation. The atom IDs, types, and coordinates of all
251+
atoms in the reaction site are printed out on the timestep that the
252+
reaction is initiated. The output file follows the :ref:`JSON dump
253+
molecules format <json-dump-files>`, with one extra key added to each
254+
molecule object to identify the reaction. The added key is "reaction" and
255+
its value is the reaction name (react-ID). Here is an example output for a
256+
hypothetical reaction involving one water molecule:
257+
258+
.. code-block:: json
259+
260+
{
261+
"application": "LAMMPS",
262+
"units": "real",
263+
"format": "dump",
264+
"style": "molecules",
265+
"revision": 1,
266+
"title": "fix bond/react",
267+
"timesteps": [
268+
{
269+
"timestep": 1,
270+
"molecules": [
271+
{
272+
"reaction": "water_dissociation",
273+
"types": {
274+
"format": ["atom-id", "type"],
275+
"data": [
276+
[1368, "H"],
277+
[1366, "O"],
278+
[1367, "H"]
279+
]
280+
},
281+
"coords": {
282+
"format": ["atom-id", "x", "y", "z"],
283+
"data": [
284+
[1368, 26.787767440427466, 29.785528640296768, 25.85197353660144],
285+
[1366, 26.641801222582824, 29.868106247702887, 24.91285138212243],
286+
[1367, 25.69611192416744, 30.093425787807448, 24.914380215672846]
287+
]
288+
}
289+
}
290+
]
291+
}
292+
]
293+
}
294+
247295
The following comments pertain to each *react* argument (in other
248296
words, they can be customized for each reaction, or reaction step):
249297

src/KOKKOS/Install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ action compute_sna_grid_local_kokkos.h compute_sna_grid_local.h
114114
action compute_sna_grid_local_kokkos_impl.h compute_sna_grid_local.cpp
115115
action compute_gaussian_grid_local_kokkos.cpp compute_gaussian_grid_local.cpp
116116
action compute_gaussian_grid_local_kokkos.h compute_gaussian_grid_local.h
117+
action compute_temp_com_kokkos.cpp
118+
action compute_temp_com_kokkos.h
117119
action compute_temp_deform_kokkos.cpp
118120
action compute_temp_deform_kokkos.h
119121
action compute_temp_kokkos.cpp

0 commit comments

Comments
 (0)