vesin-torch 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vesin_torch-0.2.0/MANIFEST.in +6 -0
- vesin_torch-0.2.0/PKG-INFO +106 -0
- vesin_torch-0.2.0/README.md +79 -0
- vesin_torch-0.2.0/VERSION +1 -0
- vesin_torch-0.2.0/build-backend/backend.py +29 -0
- vesin_torch-0.2.0/lib/CMakeLists.txt +76 -0
- vesin_torch-0.2.0/lib/VERSION +1 -0
- vesin_torch-0.2.0/lib/include/vesin.h +156 -0
- vesin_torch-0.2.0/lib/src/cpu_cell_list.cpp +425 -0
- vesin_torch-0.2.0/lib/src/cpu_cell_list.hpp +97 -0
- vesin_torch-0.2.0/lib/src/math.hpp +115 -0
- vesin_torch-0.2.0/lib/src/types.hpp +108 -0
- vesin_torch-0.2.0/lib/src/vesin.cpp +109 -0
- vesin_torch-0.2.0/lib/tests/CMakeLists.txt +37 -0
- vesin_torch-0.2.0/lib/tests/memory.cpp +87 -0
- vesin_torch-0.2.0/lib/tests/neighbors.cpp +289 -0
- vesin_torch-0.2.0/lib/torch/CMakeLists.txt +32 -0
- vesin_torch-0.2.0/lib/torch/include/vesin_torch.hpp +64 -0
- vesin_torch-0.2.0/lib/torch/src/vesin_torch.cpp +419 -0
- vesin_torch-0.2.0/pyproject.toml +52 -0
- vesin_torch-0.2.0/setup.cfg +4 -0
- vesin_torch-0.2.0/setup.py +145 -0
- vesin_torch-0.2.0/tests/test_autograd.py +28 -0
- vesin_torch-0.2.0/tests/test_neighbors.py +132 -0
- vesin_torch-0.2.0/vesin/torch/__init__.py +9 -0
- vesin_torch-0.2.0/vesin/torch/_c_lib.py +120 -0
- vesin_torch-0.2.0/vesin/torch/_neighbors.py +56 -0
- vesin_torch-0.2.0/vesin_torch.egg-info/PKG-INFO +106 -0
- vesin_torch-0.2.0/vesin_torch.egg-info/SOURCES.txt +31 -0
- vesin_torch-0.2.0/vesin_torch.egg-info/dependency_links.txt +1 -0
- vesin_torch-0.2.0/vesin_torch.egg-info/not-zip-safe +1 -0
- vesin_torch-0.2.0/vesin_torch.egg-info/requires.txt +1 -0
- vesin_torch-0.2.0/vesin_torch.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vesin-torch
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Computing neighbor lists for atomistic system, in TorchScript
|
|
5
|
+
Author-email: Guillaume Fraux <guillaume.fraux@epfl.ch>
|
|
6
|
+
License: BSD-3-Clause
|
|
7
|
+
Project-URL: homepage, https://github.com/Luthaf/vesin/
|
|
8
|
+
Project-URL: documentation, https://luthaf.fr/vesin/
|
|
9
|
+
Project-URL: repository, https://github.com/Luthaf/vesin/
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
13
|
+
Classifier: Operating System :: POSIX
|
|
14
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
Requires-Dist: torch>=2.3
|
|
27
|
+
|
|
28
|
+
# Vesin: fast neighbor lists for atomistic systems
|
|
29
|
+
|
|
30
|
+
[](http://luthaf.fr/vesin/)
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
| English 🇺🇸/🇬🇧 | Occitan <img src="./docs/src/static/images/Occitan.png" width=18> | French 🇫🇷 | Arpitan <img src="./docs/src/static/images/Arpitan.png" width=18> | Gallo‑Italic <img src="./docs/src/static/images/Lombardy.png" width=18> | Catalan <img src="./docs/src/static/images/Catalan.png" width=18> | Spanish 🇪🇸 | Italian 🇮🇹 |
|
|
34
|
+
|------------------|----------|-----------|----------|--------------|---------|------------|------------|
|
|
35
|
+
| neighbo(u)r | vesin | voisin | vesin | visin | veí | vecino | vicino |
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Vesin is a C library that computes neighbor lists for atomistic system, and tries
|
|
39
|
+
to be fast and easy to use. We also provide a Python package to call the C
|
|
40
|
+
library.
|
|
41
|
+
|
|
42
|
+
### Installation
|
|
43
|
+
|
|
44
|
+
To use the code from Python, you can install it with `pip`:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
pip install vesin
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
See the [documentation](https://luthaf.fr/vesin/latest/index.html#installation)
|
|
51
|
+
for more information on how to install the code to use it from C or C++.
|
|
52
|
+
|
|
53
|
+
### Usage instruction
|
|
54
|
+
|
|
55
|
+
You can either use the `NeighborList` calculator class:
|
|
56
|
+
|
|
57
|
+
```py
|
|
58
|
+
import numpy as np
|
|
59
|
+
from vesin import NeighborList
|
|
60
|
+
|
|
61
|
+
# positions can be anything compatible with numpy's ndarray
|
|
62
|
+
positions = [
|
|
63
|
+
(0, 0, 0),
|
|
64
|
+
(0, 1.3, 1.3),
|
|
65
|
+
]
|
|
66
|
+
box = 3.2 * np.eye(3)
|
|
67
|
+
|
|
68
|
+
calculator = NeighborList(cutoff=4.2, full_list=True)
|
|
69
|
+
i, j, S, d = calculator.compute(
|
|
70
|
+
points=points,
|
|
71
|
+
box=box,
|
|
72
|
+
periodic=True,
|
|
73
|
+
quantities="ijSd"
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
We also provide a function with drop-in compatibility to ASE's neighbor list:
|
|
78
|
+
|
|
79
|
+
```py
|
|
80
|
+
import ase
|
|
81
|
+
from vesin import ase_neighbor_list
|
|
82
|
+
|
|
83
|
+
atoms = ase.Atoms(...)
|
|
84
|
+
|
|
85
|
+
i, j, S, d = ase_neighbor_list("ijSd", atoms, cutoff=4.2)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
See the [documentation](https://luthaf.fr/vesin/latest/c-api.html) for more
|
|
89
|
+
information on how to use the code from C or C++.
|
|
90
|
+
|
|
91
|
+
### Benchmarks
|
|
92
|
+
|
|
93
|
+
You can find below benchmark result computing neighbor lists for increasingly
|
|
94
|
+
large diamond supercells, using an AMD 3955WX CPU and an NVIDIA 4070 Ti SUPER
|
|
95
|
+
GPU. You can run this benchmark on your system with the script at
|
|
96
|
+
`benchmarks/benchmark.py`. Missing points indicate that a specific code could
|
|
97
|
+
not run the calculation (for example, NNPOps requires the cell to be twice the
|
|
98
|
+
cutoff in size, and can't run with large cutoffs and small cells).
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
Vesin is is distributed under the [3 clauses BSD license](LICENSE). By
|
|
105
|
+
contributing to this code, you agree to distribute your contributions under the
|
|
106
|
+
same license.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Vesin: fast neighbor lists for atomistic systems
|
|
2
|
+
|
|
3
|
+
[](http://luthaf.fr/vesin/)
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
| English 🇺🇸/🇬🇧 | Occitan <img src="./docs/src/static/images/Occitan.png" width=18> | French 🇫🇷 | Arpitan <img src="./docs/src/static/images/Arpitan.png" width=18> | Gallo‑Italic <img src="./docs/src/static/images/Lombardy.png" width=18> | Catalan <img src="./docs/src/static/images/Catalan.png" width=18> | Spanish 🇪🇸 | Italian 🇮🇹 |
|
|
7
|
+
|------------------|----------|-----------|----------|--------------|---------|------------|------------|
|
|
8
|
+
| neighbo(u)r | vesin | voisin | vesin | visin | veí | vecino | vicino |
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Vesin is a C library that computes neighbor lists for atomistic system, and tries
|
|
12
|
+
to be fast and easy to use. We also provide a Python package to call the C
|
|
13
|
+
library.
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
To use the code from Python, you can install it with `pip`:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pip install vesin
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
See the [documentation](https://luthaf.fr/vesin/latest/index.html#installation)
|
|
24
|
+
for more information on how to install the code to use it from C or C++.
|
|
25
|
+
|
|
26
|
+
### Usage instruction
|
|
27
|
+
|
|
28
|
+
You can either use the `NeighborList` calculator class:
|
|
29
|
+
|
|
30
|
+
```py
|
|
31
|
+
import numpy as np
|
|
32
|
+
from vesin import NeighborList
|
|
33
|
+
|
|
34
|
+
# positions can be anything compatible with numpy's ndarray
|
|
35
|
+
positions = [
|
|
36
|
+
(0, 0, 0),
|
|
37
|
+
(0, 1.3, 1.3),
|
|
38
|
+
]
|
|
39
|
+
box = 3.2 * np.eye(3)
|
|
40
|
+
|
|
41
|
+
calculator = NeighborList(cutoff=4.2, full_list=True)
|
|
42
|
+
i, j, S, d = calculator.compute(
|
|
43
|
+
points=points,
|
|
44
|
+
box=box,
|
|
45
|
+
periodic=True,
|
|
46
|
+
quantities="ijSd"
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
We also provide a function with drop-in compatibility to ASE's neighbor list:
|
|
51
|
+
|
|
52
|
+
```py
|
|
53
|
+
import ase
|
|
54
|
+
from vesin import ase_neighbor_list
|
|
55
|
+
|
|
56
|
+
atoms = ase.Atoms(...)
|
|
57
|
+
|
|
58
|
+
i, j, S, d = ase_neighbor_list("ijSd", atoms, cutoff=4.2)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
See the [documentation](https://luthaf.fr/vesin/latest/c-api.html) for more
|
|
62
|
+
information on how to use the code from C or C++.
|
|
63
|
+
|
|
64
|
+
### Benchmarks
|
|
65
|
+
|
|
66
|
+
You can find below benchmark result computing neighbor lists for increasingly
|
|
67
|
+
large diamond supercells, using an AMD 3955WX CPU and an NVIDIA 4070 Ti SUPER
|
|
68
|
+
GPU. You can run this benchmark on your system with the script at
|
|
69
|
+
`benchmarks/benchmark.py`. Missing points indicate that a specific code could
|
|
70
|
+
not run the calculation (for example, NNPOps requires the cell to be twice the
|
|
71
|
+
cutoff in size, and can't run with large cutoffs and small cells).
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
Vesin is is distributed under the [3 clauses BSD license](LICENSE). By
|
|
78
|
+
contributing to this code, you agree to distribute your contributions under the
|
|
79
|
+
same license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.0
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# This is a custom Python build backend wrapping setuptool's to add a build-time
|
|
2
|
+
# dependencies on torch/cmake when building the wheel and not the sdist
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from setuptools import build_meta
|
|
6
|
+
|
|
7
|
+
ROOT = os.path.realpath(os.path.dirname(__file__))
|
|
8
|
+
|
|
9
|
+
FORCED_TORCH_VERSION = os.environ.get("VESIN_TORCH_BUILD_WITH_TORCH_VERSION")
|
|
10
|
+
if FORCED_TORCH_VERSION is not None:
|
|
11
|
+
TORCH_DEP = f"torch =={FORCED_TORCH_VERSION}"
|
|
12
|
+
else:
|
|
13
|
+
TORCH_DEP = "torch >=2.3"
|
|
14
|
+
|
|
15
|
+
# ==================================================================================== #
|
|
16
|
+
# Build backend functions definition #
|
|
17
|
+
# ==================================================================================== #
|
|
18
|
+
|
|
19
|
+
# Use the default version of these
|
|
20
|
+
prepare_metadata_for_build_wheel = build_meta.prepare_metadata_for_build_wheel
|
|
21
|
+
get_requires_for_build_sdist = build_meta.get_requires_for_build_sdist
|
|
22
|
+
build_wheel = build_meta.build_wheel
|
|
23
|
+
build_sdist = build_meta.build_sdist
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Special dependencies to build the wheels
|
|
27
|
+
def get_requires_for_build_wheel(config_settings=None):
|
|
28
|
+
defaults = build_meta.get_requires_for_build_wheel(config_settings)
|
|
29
|
+
return defaults + ["cmake", TORCH_DEP]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.16)
|
|
2
|
+
|
|
3
|
+
file(READ "VERSION" VESIN_VERSION)
|
|
4
|
+
string(STRIP ${VESIN_VERSION} VESIN_VERSION)
|
|
5
|
+
|
|
6
|
+
project(vesin LANGUAGES C CXX VERSION ${VESIN_VERSION})
|
|
7
|
+
|
|
8
|
+
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
|
9
|
+
set(VESIN_MAIN_PROJECT ON)
|
|
10
|
+
else()
|
|
11
|
+
set(VESIN_MAIN_PROJECT OFF)
|
|
12
|
+
endif()
|
|
13
|
+
|
|
14
|
+
if (VESIN_MAIN_PROJECT)
|
|
15
|
+
if("${CMAKE_BUILD_TYPE}" STREQUAL "" AND "${CMAKE_CONFIGURATION_TYPES}" STREQUAL "")
|
|
16
|
+
message(STATUS "Setting build type to 'release' as none was specified.")
|
|
17
|
+
set(
|
|
18
|
+
CMAKE_BUILD_TYPE "release"
|
|
19
|
+
CACHE STRING
|
|
20
|
+
"Choose the type of build, options are: none(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) debug release relwithdebinfo minsizerel."
|
|
21
|
+
FORCE
|
|
22
|
+
)
|
|
23
|
+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS release debug relwithdebinfo minsizerel none)
|
|
24
|
+
endif()
|
|
25
|
+
endif()
|
|
26
|
+
|
|
27
|
+
option(BUILD_SHARED_LIBS "Build shared libraries instead of static ones" OFF)
|
|
28
|
+
option(VESIN_BUILD_TESTS "Build and run Vesin's unit tests" OFF)
|
|
29
|
+
option(VESIN_INSTALL "Install Vesin's headers and libraries" ${VESIN_MAIN_PROJECT})
|
|
30
|
+
option(VESIN_TORCH "Build the vesin_torch library" OFF)
|
|
31
|
+
|
|
32
|
+
set(VESIN_SOURCES
|
|
33
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/vesin.cpp
|
|
34
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/cpu_cell_list.cpp
|
|
35
|
+
)
|
|
36
|
+
add_library(vesin ${VESIN_SOURCES})
|
|
37
|
+
|
|
38
|
+
target_include_directories(vesin PUBLIC
|
|
39
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
40
|
+
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
target_compile_features(vesin PRIVATE cxx_std_17)
|
|
44
|
+
|
|
45
|
+
set_target_properties(vesin PROPERTIES
|
|
46
|
+
# hide non-exported symbols by default
|
|
47
|
+
CXX_VISIBILITY_PRESET hidden
|
|
48
|
+
VISIBILITY_INLINES_HIDDEN ON
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
target_compile_definitions(vesin PRIVATE VESIN_EXPORTS)
|
|
52
|
+
if (BUILD_SHARED_LIBS)
|
|
53
|
+
target_compile_definitions(vesin PUBLIC VESIN_SHARED)
|
|
54
|
+
endif()
|
|
55
|
+
|
|
56
|
+
if (VESIN_BUILD_TESTS)
|
|
57
|
+
enable_testing()
|
|
58
|
+
add_subdirectory(tests)
|
|
59
|
+
endif()
|
|
60
|
+
|
|
61
|
+
if (VESIN_TORCH)
|
|
62
|
+
add_subdirectory(torch)
|
|
63
|
+
endif()
|
|
64
|
+
|
|
65
|
+
#------------------------------------------------------------------------------#
|
|
66
|
+
# Installation configuration
|
|
67
|
+
#------------------------------------------------------------------------------#
|
|
68
|
+
if (VESIN_INSTALL)
|
|
69
|
+
install(TARGETS vesin
|
|
70
|
+
ARCHIVE DESTINATION "lib"
|
|
71
|
+
LIBRARY DESTINATION "lib"
|
|
72
|
+
RUNTIME DESTINATION "bin"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
install(FILES "include/vesin.h" DESTINATION "include")
|
|
76
|
+
endif()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.0
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#ifndef VESIN_H
|
|
2
|
+
#define VESIN_H
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
|
|
7
|
+
#if defined(VESIN_SHARED)
|
|
8
|
+
#if defined(VESIN_EXPORTS)
|
|
9
|
+
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
|
10
|
+
#define VESIN_API __attribute__((visibility("default")))
|
|
11
|
+
#elif defined(_MSC_VER)
|
|
12
|
+
#define VESIN_API __declspec(dllexport)
|
|
13
|
+
#else
|
|
14
|
+
#define VESIN_API
|
|
15
|
+
#endif
|
|
16
|
+
#else
|
|
17
|
+
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
|
18
|
+
#define VESIN_API __attribute__((visibility("default")))
|
|
19
|
+
#elif defined(_MSC_VER)
|
|
20
|
+
#define VESIN_API __declspec(dllimport)
|
|
21
|
+
#else
|
|
22
|
+
#define VESIN_API
|
|
23
|
+
#endif
|
|
24
|
+
#endif
|
|
25
|
+
#else
|
|
26
|
+
#define VESIN_API
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#ifdef __cplusplus
|
|
30
|
+
extern "C" {
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
/// Options for a neighbor list calculation
|
|
34
|
+
struct VesinOptions {
|
|
35
|
+
/// Spherical cutoff, only pairs below this cutoff will be included
|
|
36
|
+
double cutoff;
|
|
37
|
+
/// Should the returned neighbor list be a full list (include both `i -> j`
|
|
38
|
+
/// and `j -> i` pairs) or a half list (include only `i -> j`)?
|
|
39
|
+
bool full;
|
|
40
|
+
// TODO: sort option?
|
|
41
|
+
|
|
42
|
+
/// Should the returned `VesinNeighborList` contain `shifts`?
|
|
43
|
+
bool return_shifts;
|
|
44
|
+
/// Should the returned `VesinNeighborList` contain `distances`?
|
|
45
|
+
bool return_distances;
|
|
46
|
+
/// Should the returned `VesinNeighborList` contain `vector`?
|
|
47
|
+
bool return_vectors;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/// Device on which the data can be
|
|
51
|
+
enum VesinDevice {
|
|
52
|
+
/// Unknown device, used for default initialization and to indicate no
|
|
53
|
+
/// allocated data.
|
|
54
|
+
VesinUnknownDevice = 0,
|
|
55
|
+
/// CPU device
|
|
56
|
+
VesinCPU = 1,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/// The actual neighbor list
|
|
61
|
+
///
|
|
62
|
+
/// This is organized as a list of pairs, where each pair can contain the
|
|
63
|
+
/// following data:
|
|
64
|
+
///
|
|
65
|
+
/// - indices of the points in the pair;
|
|
66
|
+
/// - distance between points in the pair, accounting for periodic boundary
|
|
67
|
+
/// conditions;
|
|
68
|
+
/// - vector between points in the pair, accounting for periodic boundary
|
|
69
|
+
/// conditions;
|
|
70
|
+
/// - periodic shift that created the pair. This is only relevant when using
|
|
71
|
+
/// periodic boundary conditions, and contains the number of bounding box we
|
|
72
|
+
/// need to cross to create the pair. If the positions of the points are `r_i`
|
|
73
|
+
/// and `r_j`, the bounding box is described by a matrix of three vectors `H`,
|
|
74
|
+
/// and the periodic shift is `S`, the distance vector for a given pair will
|
|
75
|
+
/// be given by `r_ij = r_j - r_i + S @ H`.
|
|
76
|
+
///
|
|
77
|
+
/// Under periodic boundary conditions, two atoms can be part of multiple pairs,
|
|
78
|
+
/// each pair having a different periodic shift.
|
|
79
|
+
struct VESIN_API VesinNeighborList {
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
VesinNeighborList():
|
|
82
|
+
length(0),
|
|
83
|
+
device(VesinUnknownDevice),
|
|
84
|
+
pairs(nullptr),
|
|
85
|
+
shifts(nullptr),
|
|
86
|
+
distances(nullptr),
|
|
87
|
+
vectors(nullptr)
|
|
88
|
+
{}
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
/// Number of pairs in this neighbor list
|
|
92
|
+
size_t length;
|
|
93
|
+
/// Device used for the data allocations
|
|
94
|
+
VesinDevice device;
|
|
95
|
+
/// Array of pairs (storing the indices of the first and second point in the
|
|
96
|
+
/// pair), containing `length` elements.
|
|
97
|
+
size_t (*pairs)[2];
|
|
98
|
+
/// Array of box shifts, one for each `pair`. This is only set if
|
|
99
|
+
/// `options.return_pairs` was `true` during the calculation.
|
|
100
|
+
int32_t (*shifts)[3];
|
|
101
|
+
/// Array of pair distance (i.e. distance between the two points), one for
|
|
102
|
+
/// each pair. This is only set if `options.return_distances` was `true`
|
|
103
|
+
/// during the calculation.
|
|
104
|
+
double *distances;
|
|
105
|
+
/// Array of pair vector (i.e. vector between the two points), one for
|
|
106
|
+
/// each pair. This is only set if `options.return_vector` was `true`
|
|
107
|
+
/// during the calculation.
|
|
108
|
+
double (*vectors)[3];
|
|
109
|
+
|
|
110
|
+
// TODO: custom memory allocators?
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/// Free all allocated memory inside a `VesinNeighborList`, according the it's
|
|
114
|
+
/// `device`.
|
|
115
|
+
void VESIN_API vesin_free(struct VesinNeighborList* neighbors);
|
|
116
|
+
|
|
117
|
+
/// Compute a neighbor list.
|
|
118
|
+
///
|
|
119
|
+
/// The data is returned in a `VesinNeighborList`. For an initial call, the
|
|
120
|
+
/// `VesinNeighborList` should be zero-initialized (or default-initalized in
|
|
121
|
+
/// C++). The `VesinNeighborList` can be re-used across calls to this functions
|
|
122
|
+
/// to re-use memory allocations, and once it is no longer needed, users should
|
|
123
|
+
/// call `vesin_free` to release the corresponding memory.
|
|
124
|
+
///
|
|
125
|
+
/// @param points positions of all points in the system;
|
|
126
|
+
/// @param n_points number of elements in the `points` array
|
|
127
|
+
/// @param box bounding box for the system. If the system is non-periodic,
|
|
128
|
+
/// this is ignored. This should contain the three vectors of the bounding
|
|
129
|
+
/// box, one vector per row of the matrix.
|
|
130
|
+
/// @param periodic is the system using periodic boundary conditions?
|
|
131
|
+
/// @param device device where the `points` and `box` data is allocated.
|
|
132
|
+
/// @param options options for the calculation
|
|
133
|
+
/// @param neighbors non-NULL pointer to `VesinNeighborList` that will be used
|
|
134
|
+
/// to store the computed list of neighbors.
|
|
135
|
+
/// @param error_message Pointer to a `char*` that wil be set to the error
|
|
136
|
+
/// message if this function fails. This does not need to be freed when no
|
|
137
|
+
/// longer needed.
|
|
138
|
+
int VESIN_API vesin_neighbors(
|
|
139
|
+
const double (*points)[3],
|
|
140
|
+
size_t n_points,
|
|
141
|
+
const double box[3][3],
|
|
142
|
+
bool periodic,
|
|
143
|
+
VesinDevice device,
|
|
144
|
+
struct VesinOptions options,
|
|
145
|
+
struct VesinNeighborList* neighbors,
|
|
146
|
+
const char** error_message
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
#ifdef __cplusplus
|
|
151
|
+
|
|
152
|
+
} // extern "C"
|
|
153
|
+
|
|
154
|
+
#endif
|
|
155
|
+
|
|
156
|
+
#endif
|