MDescriptor 1.0.6__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.
- mdescriptor-1.0.6/CMakeLists.txt +53 -0
- mdescriptor-1.0.6/PKG-INFO +357 -0
- mdescriptor-1.0.6/README.md +334 -0
- mdescriptor-1.0.6/cpp/include/mdescriptor/descriptor.hpp +247 -0
- mdescriptor-1.0.6/cpp/include/mdescriptor/extra.hpp +178 -0
- mdescriptor-1.0.6/cpp/include/mdescriptor/featomic.hpp +73 -0
- mdescriptor-1.0.6/cpp/include/mdescriptor/mtp4.hpp +48 -0
- mdescriptor-1.0.6/cpp/include/mdescriptor/mtp_cinf_coeffs.hpp +120 -0
- mdescriptor-1.0.6/cpp/include/mdescriptor/neighbor.hpp +62 -0
- mdescriptor-1.0.6/cpp/include/mdescriptor/nep.hpp +49 -0
- mdescriptor-1.0.6/cpp/src/acsf.cpp +319 -0
- mdescriptor-1.0.6/cpp/src/atomic_composition.cpp +42 -0
- mdescriptor-1.0.6/cpp/src/bindings.cpp +869 -0
- mdescriptor-1.0.6/cpp/src/c00ps_mlff.cpp +513 -0
- mdescriptor-1.0.6/cpp/src/compute_control.cpp +17 -0
- mdescriptor-1.0.6/cpp/src/coulomb_matrix.cpp +132 -0
- mdescriptor-1.0.6/cpp/src/descriptor_common.hpp +155 -0
- mdescriptor-1.0.6/cpp/src/ead.cpp +92 -0
- mdescriptor-1.0.6/cpp/src/ewald_sum_matrix.cpp +185 -0
- mdescriptor-1.0.6/cpp/src/extra_common.hpp +189 -0
- mdescriptor-1.0.6/cpp/src/featomic_common.hpp +76 -0
- mdescriptor-1.0.6/cpp/src/featomic_spherical_common.hpp +1018 -0
- mdescriptor-1.0.6/cpp/src/matrix_common.hpp +205 -0
- mdescriptor-1.0.6/cpp/src/matrix_dispatch.cpp +74 -0
- mdescriptor-1.0.6/cpp/src/mbtr.cpp +330 -0
- mdescriptor-1.0.6/cpp/src/mtp.cpp +761 -0
- mdescriptor-1.0.6/cpp/src/mtp4.cpp +1306 -0
- mdescriptor-1.0.6/cpp/src/neighbor.cpp +503 -0
- mdescriptor-1.0.6/cpp/src/neighbor_list.cpp +58 -0
- mdescriptor-1.0.6/cpp/src/nep.cpp +894 -0
- mdescriptor-1.0.6/cpp/src/pyxtal.cpp +649 -0
- mdescriptor-1.0.6/cpp/src/sine_matrix.cpp +40 -0
- mdescriptor-1.0.6/cpp/src/soap.cpp +1271 -0
- mdescriptor-1.0.6/cpp/src/soap_turbo.cpp +764 -0
- mdescriptor-1.0.6/cpp/src/sorted_distances.cpp +90 -0
- mdescriptor-1.0.6/cpp/src/spherical_expansion.cpp +163 -0
- mdescriptor-1.0.6/cpp/src/spherical_expansion_by_pair.cpp +95 -0
- mdescriptor-1.0.6/mdescriptor/__init__.py +88 -0
- mdescriptor-1.0.6/mdescriptor/_periodic_graph.py +79 -0
- mdescriptor-1.0.6/mdescriptor/_version.py +24 -0
- mdescriptor-1.0.6/mdescriptor/descriptor_catalog.py +64 -0
- mdescriptor-1.0.6/mdescriptor/descriptors.py +686 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_c00ps_mlff.py +165 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_dpa4.py +240 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_dpa4c.py +331 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_extra.py +251 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_featomic.py +172 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_mtp.py +225 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_nep.py +120 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_pyxtal.py +189 -0
- mdescriptor-1.0.6/mdescriptor/descriptors_soap_turbo.py +237 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/__init__.py +5 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/NOTICE.md +10 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/__init__.py +2 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/base_descriptor.py +17 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4.py +2883 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/__init__.py +202 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/activation.py +299 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/attention.py +179 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/attn_res.py +270 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/block.py +1143 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/cartesian.py +762 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/edge_cache.py +653 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/embedding.py +1290 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/ffn.py +367 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/grid_net.py +1258 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/indexing.py +457 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/lora.py +993 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/mlp.py +247 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/norm.py +591 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/projection.py +608 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/radial.py +597 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/so2.py +2801 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/so3.py +514 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/utils.py +105 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpa4_nn/wignerd.py +1843 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/__init__.py +20 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/array_api.py +477 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/common.py +256 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/descriptor/__init__.py +5 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/descriptor/base_descriptor.py +8 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/descriptor/make_base_descriptor.py +29 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/__init__.py +19 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/env_mat.py +266 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/exclude_mask.py +207 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/lebedev.py +87 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/lebedev_rules.npz +0 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/neighbor_graph/__init__.py +45 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/neighbor_graph/builder.py +467 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/neighbor_graph/csr.py +219 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/neighbor_graph/graph.py +542 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/neighbor_graph/segment.py +451 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/neighbor_stat.py +5 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/network.py +1439 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/safe_gradient.py +16 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/seed.py +38 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/spherical_harmonics.py +135 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/type_embed.py +370 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/dpmodel/utils/update_sel.py +16 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/utils/__init__.py +1 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/utils/charge_state.py +144 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/utils/finetune.py +17 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/utils/random.py +8 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/utils/update_sel.py +5 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/_official_core/utils/version.py +27 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/model.py +534 -0
- mdescriptor-1.0.6/mdescriptor/dpa4/official.py +175 -0
- mdescriptor-1.0.6/mdescriptor/dpa4c/__init__.py +8 -0
- mdescriptor-1.0.6/mdescriptor/dpa4c/model.py +821 -0
- mdescriptor-1.0.6/mdescriptor/models/DPA4-Air-OMat24-v20260704.pt +0 -0
- mdescriptor-1.0.6/mdescriptor/models/DPA4C-Air-OMat24-v20260819.pt +0 -0
- mdescriptor-1.0.6/mdescriptor/models/__init__.py +12 -0
- mdescriptor-1.0.6/mdescriptor/models/nep89_20250409.txt +976373 -0
- mdescriptor-1.0.6/pyproject.toml +64 -0
- mdescriptor-1.0.6/tests/__init__.py +0 -0
- mdescriptor-1.0.6/tests/data/dpa4c_air_h2o_golden.json +1432 -0
- mdescriptor-1.0.6/tests/data/mlip4_test_mtp.json +1 -0
- mdescriptor-1.0.6/tests/self_check.py +32 -0
- mdescriptor-1.0.6/tests/test_all_descriptors.py +357 -0
- mdescriptor-1.0.6/tests/test_c00ps_mlff.py +118 -0
- mdescriptor-1.0.6/tests/test_descriptor_symmetry.py +248 -0
- mdescriptor-1.0.6/tests/test_dpa4.py +86 -0
- mdescriptor-1.0.6/tests/test_dpa4c.py +88 -0
- mdescriptor-1.0.6/tests/test_mtp.py +138 -0
- mdescriptor-1.0.6/tests/test_neighbor_graph.py +65 -0
- mdescriptor-1.0.6/tests/test_nep.py +45 -0
- mdescriptor-1.0.6/tests/test_reference.py +16 -0
- mdescriptor-1.0.6/tests/test_soap_acsf_advanced.py +111 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15...4.0)
|
|
2
|
+
project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(PYBIND11_FINDPYTHON ON)
|
|
5
|
+
find_package(pybind11 CONFIG REQUIRED)
|
|
6
|
+
|
|
7
|
+
if(MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
|
|
8
|
+
set(OpenMP_RUNTIME_MSVC experimental)
|
|
9
|
+
endif()
|
|
10
|
+
find_package(OpenMP)
|
|
11
|
+
|
|
12
|
+
set(MDESCRIPTOR_CPP_SOURCES
|
|
13
|
+
cpp/src/compute_control.cpp
|
|
14
|
+
cpp/src/soap.cpp
|
|
15
|
+
cpp/src/soap_turbo.cpp
|
|
16
|
+
cpp/src/acsf.cpp
|
|
17
|
+
cpp/src/c00ps_mlff.cpp
|
|
18
|
+
cpp/src/coulomb_matrix.cpp
|
|
19
|
+
cpp/src/sine_matrix.cpp
|
|
20
|
+
cpp/src/ewald_sum_matrix.cpp
|
|
21
|
+
cpp/src/matrix_dispatch.cpp
|
|
22
|
+
cpp/src/mbtr.cpp
|
|
23
|
+
cpp/src/ead.cpp
|
|
24
|
+
cpp/src/mtp.cpp
|
|
25
|
+
cpp/src/mtp4.cpp
|
|
26
|
+
cpp/src/pyxtal.cpp
|
|
27
|
+
cpp/src/neighbor.cpp
|
|
28
|
+
cpp/src/nep.cpp
|
|
29
|
+
cpp/src/atomic_composition.cpp
|
|
30
|
+
cpp/src/sorted_distances.cpp
|
|
31
|
+
cpp/src/neighbor_list.cpp
|
|
32
|
+
cpp/src/spherical_expansion.cpp
|
|
33
|
+
cpp/src/spherical_expansion_by_pair.cpp
|
|
34
|
+
cpp/src/bindings.cpp
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
pybind11_add_module(_descriptor_cpp ${MDESCRIPTOR_CPP_SOURCES})
|
|
38
|
+
target_compile_features(_descriptor_cpp PRIVATE cxx_std_17)
|
|
39
|
+
target_include_directories(_descriptor_cpp PRIVATE cpp/include)
|
|
40
|
+
if(OpenMP_CXX_FOUND)
|
|
41
|
+
if(MSVC AND CMAKE_VERSION VERSION_LESS 3.30)
|
|
42
|
+
# /openmp:experimental subsumes /openmp and enables omp simd.
|
|
43
|
+
target_compile_options(_descriptor_cpp PRIVATE /openmp:experimental)
|
|
44
|
+
else()
|
|
45
|
+
target_link_libraries(_descriptor_cpp PRIVATE OpenMP::OpenMP_CXX)
|
|
46
|
+
endif()
|
|
47
|
+
endif()
|
|
48
|
+
|
|
49
|
+
install(
|
|
50
|
+
TARGETS _descriptor_cpp
|
|
51
|
+
LIBRARY DESTINATION mdescriptor
|
|
52
|
+
RUNTIME DESTINATION mdescriptor
|
|
53
|
+
)
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: MDescriptor
|
|
3
|
+
Version: 1.0.6
|
|
4
|
+
Summary: Batch-oriented periodic atomic descriptors with C++17 kernels
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Requires-Dist: numpy>=1.23
|
|
7
|
+
Requires-Dist: array-api-compat>=1.8
|
|
8
|
+
Provides-Extra: ase
|
|
9
|
+
Requires-Dist: ase>=3.22; extra == "ase"
|
|
10
|
+
Provides-Extra: torch
|
|
11
|
+
Requires-Dist: torch>=2.0; extra == "torch"
|
|
12
|
+
Provides-Extra: sparse
|
|
13
|
+
Requires-Dist: sparse>=0.14; extra == "sparse"
|
|
14
|
+
Provides-Extra: test
|
|
15
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
16
|
+
Requires-Dist: ase>=3.22; extra == "test"
|
|
17
|
+
Requires-Dist: sparse>=0.14; extra == "test"
|
|
18
|
+
Provides-Extra: all
|
|
19
|
+
Requires-Dist: ase>=3.22; extra == "all"
|
|
20
|
+
Requires-Dist: sparse>=0.14; extra == "all"
|
|
21
|
+
Requires-Dist: torch>=2.0; extra == "all"
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# MDescriptor
|
|
25
|
+
|
|
26
|
+
MDescriptor is a batch-oriented periodic atomic-descriptor library. Its numerical
|
|
27
|
+
kernels are implemented in C++17 and exposed through a small Python API. The
|
|
28
|
+
library accepts one or more fully periodic structures and returns labeled
|
|
29
|
+
descriptor arrays together with structure and atom boundary information.
|
|
30
|
+
|
|
31
|
+
MDescriptor 是一个面向批量周期性结构的原子描述符库。数值计算核心使用
|
|
32
|
+
C++17 实现,并通过简洁的 Python API 调用。库接收一个或多个完整周期结构,
|
|
33
|
+
返回带有标签的描述符数组,以及结构边界和原子边界信息。
|
|
34
|
+
|
|
35
|
+
## Features / 特性
|
|
36
|
+
|
|
37
|
+
- Native C++17 kernels with optional OpenMP parallelism.
|
|
38
|
+
- One input contract for all descriptors.
|
|
39
|
+
- Atom-level, structure-level, and pair-level outputs.
|
|
40
|
+
- Stable feature labels and metadata for every result.
|
|
41
|
+
- Optional ASE input conversion and optional sparse.COO output.
|
|
42
|
+
- 25 entries in DESCRIPTOR_CATALOG: native descriptors, the C00PS-MLFF
|
|
43
|
+
C00/PS descriptor, and bundled model-backed DPA4/DPA4C/NEP descriptors.
|
|
44
|
+
|
|
45
|
+
- 原生 C++17 计算核心,可选 OpenMP 并行。
|
|
46
|
+
- 所有描述符统一使用同一种输入契约。
|
|
47
|
+
- 支持原子级、结构级和邻居对级输出。
|
|
48
|
+
- 每个结果都包含稳定的特征标签和元数据。
|
|
49
|
+
- 可选使用 ASE 构造输入,也可选输出 sparse.COO。
|
|
50
|
+
- DESCRIPTOR_CATALOG 中包含 25 个入口:原生描述符、C00PS-MLFF
|
|
51
|
+
C00/PS 描述符,以及内置模型驱动的 DPA4/DPA4C/NEP 描述符。
|
|
52
|
+
|
|
53
|
+
## Installation / 安装
|
|
54
|
+
|
|
55
|
+
The core runtime requires Python 3.10 or newer, NumPy 1.23 or newer, and
|
|
56
|
+
array-api-compat 1.8 or newer. PyTorch is only required by the DPA4/DPA4C model
|
|
57
|
+
descriptors. Installing from source requires a C++17 compiler; the build
|
|
58
|
+
backend supplies the CMake and pybind11 build dependencies automatically.
|
|
59
|
+
|
|
60
|
+
核心运行环境需要 Python 3.10 及以上版本、NumPy 1.23 及以上版本和
|
|
61
|
+
array-api-compat 1.8 及以上版本。只有使用 DPA4/DPA4C 模型描述符时才需要
|
|
62
|
+
PyTorch。源码安装需要 C++17 编译器;CMake 和 pybind11 构建依赖由构建后端自动
|
|
63
|
+
提供。
|
|
64
|
+
|
|
65
|
+
~~~bash
|
|
66
|
+
# Development install: builds the C++ extension through CMake.
|
|
67
|
+
python -m pip install -e .
|
|
68
|
+
|
|
69
|
+
# Optional integrations.
|
|
70
|
+
python -m pip install ".[ase]"
|
|
71
|
+
python -m pip install ".[torch]"
|
|
72
|
+
python -m pip install ".[all]"
|
|
73
|
+
~~~
|
|
74
|
+
|
|
75
|
+
ASE is only required for StructureBatch.from_ase or when passing ASE Atoms
|
|
76
|
+
objects directly. Install it with pip install ase. Install sparse when using
|
|
77
|
+
sparse=True on a calculator that supports sparse output.
|
|
78
|
+
|
|
79
|
+
只有使用 StructureBatch.from_ase,或直接传入 ASE Atoms 对象时才需要 ASE,
|
|
80
|
+
可通过 pip install ase 安装。需要 sparse=True 时,请安装 sparse。
|
|
81
|
+
|
|
82
|
+
### Build and release / 构建与发布
|
|
83
|
+
|
|
84
|
+
The project uses `scikit-build-core` as the PEP 517 backend. The C++17 core is
|
|
85
|
+
configured by `CMakeLists.txt`, and the extension is installed next to the
|
|
86
|
+
Python package as `mdescriptor._descriptor_cpp`. To build distributions locally:
|
|
87
|
+
Package versions are read from Git tags by `setuptools-scm`: tag `v1.2.3`
|
|
88
|
+
produces version `1.2.3`. Untagged source builds use a development version
|
|
89
|
+
derived from the fallback and Git state.
|
|
90
|
+
|
|
91
|
+
项目使用 `scikit-build-core` 作为 PEP 517 构建后端。C++17 核心由
|
|
92
|
+
`CMakeLists.txt` 配置,扩展模块会与 Python 包一起安装为
|
|
93
|
+
`mdescriptor._descriptor_cpp`。版本号由 `setuptools-scm` 从 Git tag 读取:
|
|
94
|
+
tag `v1.2.3` 会生成版本 `1.2.3`;没有 tag 的源码构建会根据 fallback 和 Git
|
|
95
|
+
状态生成开发版本。本地构建发布产物:
|
|
96
|
+
|
|
97
|
+
~~~bash
|
|
98
|
+
python -m pip install build
|
|
99
|
+
python -m build
|
|
100
|
+
~~~
|
|
101
|
+
|
|
102
|
+
Pushing a tag such as `v0.1.0` starts
|
|
103
|
+
`.github/workflows/release.yml`. `cibuildwheel` builds CPython 3.10–3.14
|
|
104
|
+
wheels for Linux x86_64, Windows x86_64, macOS Intel, and macOS arm64; a source
|
|
105
|
+
distribution is built in parallel. The final job publishes all artifacts to
|
|
106
|
+
PyPI using GitHub OIDC Trusted Publishing and creates a matching GitHub Release
|
|
107
|
+
with all wheels and the sdist attached, so no long-lived `PYPI_TOKEN` is stored
|
|
108
|
+
in GitHub Secrets.
|
|
109
|
+
|
|
110
|
+
推送 `v0.1.0` 之类的 tag 后会触发 `.github/workflows/release.yml`。
|
|
111
|
+
`cibuildwheel` 会为 Linux x86_64、Windows x86_64、macOS Intel 和 macOS arm64
|
|
112
|
+
构建 CPython 3.10–3.14 的 wheel,并同时构建源码包。随后通过 GitHub OIDC
|
|
113
|
+
Trusted Publishing 发布到 PyPI,并创建对应的 GitHub Release,将所有 wheel 和
|
|
114
|
+
源码包作为附件上传;不需要在 GitHub Secrets 中保存长期有效的 `PYPI_TOKEN`。
|
|
115
|
+
|
|
116
|
+
Before the first release, configure a PyPI Trusted Publisher with the actual
|
|
117
|
+
GitHub owner, repository, workflow `release.yml`, and GitHub environment `pypi`.
|
|
118
|
+
Create the `pypi` environment in the repository and add required reviewers if
|
|
119
|
+
manual release approval is desired.
|
|
120
|
+
|
|
121
|
+
首次发布前,需要在 PyPI Trusted Publisher 中填写实际的 GitHub 用户/组织、仓库、
|
|
122
|
+
workflow `release.yml`,以及 GitHub 环境 `pypi`。在仓库中创建 `pypi` environment;
|
|
123
|
+
如果希望人工审批发布,可以为该环境配置 required reviewers。
|
|
124
|
+
|
|
125
|
+
## Input contract / 输入结构
|
|
126
|
+
|
|
127
|
+
All calculators accept one of the following:
|
|
128
|
+
|
|
129
|
+
所有计算器都接受以下输入之一:
|
|
130
|
+
|
|
131
|
+
1. A StructureBatch instance.
|
|
132
|
+
2. A single ASE Atoms object.
|
|
133
|
+
3. A sequence of ASE Atoms objects.
|
|
134
|
+
|
|
135
|
+
1. StructureBatch 实例。
|
|
136
|
+
2. 单个 ASE Atoms 对象。
|
|
137
|
+
3. ASE Atoms 对象序列。
|
|
138
|
+
|
|
139
|
+
### StructureBatch
|
|
140
|
+
|
|
141
|
+
StructureBatch stores all structures in contiguous arrays:
|
|
142
|
+
|
|
143
|
+
StructureBatch 使用连续数组存储多个结构:
|
|
144
|
+
|
|
145
|
+
| Field / 字段 | Shape / 形状 | Dtype / 类型 | Meaning / 含义 |
|
|
146
|
+
|---|---:|---|---|
|
|
147
|
+
| numbers | (N,) | int32 | Atomic numbers for all atoms / 所有原子的原子序数 |
|
|
148
|
+
| positions | (N, 3) | float64 | Cartesian positions / 笛卡尔坐标 |
|
|
149
|
+
| cells | (S, 3, 3) | float64 | Unit-cell matrices / 各结构晶胞矩阵 |
|
|
150
|
+
| pbc | (S, 3) | int32 | Periodic flags; all values must be 1 / 周期标志,所有值必须为 1 |
|
|
151
|
+
| offsets | (S + 1,) | int64 | Atom ranges for each structure / 每个结构的原子范围 |
|
|
152
|
+
| ids | length S | tuple[str, ...] | Structure identifiers / 结构标识符 |
|
|
153
|
+
|
|
154
|
+
Here S is the number of structures and N is the total number of atoms. The
|
|
155
|
+
atoms belonging to structure s are in the half-open range
|
|
156
|
+
offsets[s]:offsets[s + 1]. Cells must be nonsingular, positions and cells must
|
|
157
|
+
be finite, and only fully periodic structures (pbc == (1, 1, 1)) are supported.
|
|
158
|
+
|
|
159
|
+
其中 S 是结构数量,N 是所有结构的原子总数。第 s 个结构的原子位于
|
|
160
|
+
offsets[s]:offsets[s + 1] 半开区间内。晶胞必须非奇异,位置和晶胞必须为有限值,
|
|
161
|
+
当前只支持完整周期结构(pbc == (1, 1, 1))。
|
|
162
|
+
|
|
163
|
+
### Constructing an input / 构造输入
|
|
164
|
+
|
|
165
|
+
~~~python
|
|
166
|
+
from ase import Atoms
|
|
167
|
+
from mdescriptor import StructureBatch
|
|
168
|
+
|
|
169
|
+
systems = [
|
|
170
|
+
Atoms(
|
|
171
|
+
"Si2",
|
|
172
|
+
positions=[[0.0, 0.0, 0.0], [1.4, 1.4, 1.4]],
|
|
173
|
+
cell=[[8.0, 0.0, 0.0], [0.0, 8.0, 0.0], [0.0, 0.0, 8.0]],
|
|
174
|
+
pbc=True,
|
|
175
|
+
),
|
|
176
|
+
]
|
|
177
|
+
batch = StructureBatch.from_ase(systems, ids=["si-cell-0"])
|
|
178
|
+
~~~
|
|
179
|
+
|
|
180
|
+
The same object can be passed to every calculator. Atomic numbers in species
|
|
181
|
+
arguments must be positive, unique, and cover every atomic number in the batch.
|
|
182
|
+
|
|
183
|
+
同一个 batch 可以传给所有计算器。计算器的 species 参数必须是正数、无重复,
|
|
184
|
+
并且覆盖输入中出现的全部原子序数。
|
|
185
|
+
|
|
186
|
+
## Output contract / 输出结构
|
|
187
|
+
|
|
188
|
+
Every compute(...) call returns a DescriptorResult. The create(...) method is a
|
|
189
|
+
convenience wrapper that returns only result.values.
|
|
190
|
+
|
|
191
|
+
每次调用 compute(...) 都返回 DescriptorResult。create(...) 是便捷接口,
|
|
192
|
+
只返回 result.values。
|
|
193
|
+
|
|
194
|
+
| Field / 字段 | Description / 说明 |
|
|
195
|
+
|---|---|
|
|
196
|
+
| values | A two-dimensional dense numpy.ndarray by default. Selected calculators can return sparse.COO when sparse=True. / 默认是二维 numpy.ndarray;部分计算器支持 sparse=True 返回 sparse.COO。 |
|
|
197
|
+
| level | atom, structure, or pair. / 原子级、结构级或邻居对级。 |
|
|
198
|
+
| structure_ids | The input batch.ids. / 输入的 batch.ids。 |
|
|
199
|
+
| atom_offsets | batch.offsets for atom-level results; per-structure row offsets for pair-level results; None for structure-level results. / 原子级结果使用 batch.offsets;邻居对级结果使用每个结构的行偏移;结构级结果为 None。 |
|
|
200
|
+
| labels | One stable label per feature column; len(labels) == values.shape[1]. / 每个特征列一个稳定标签。 |
|
|
201
|
+
| metadata | Descriptor name, backend, configuration, and descriptor-specific information. / 描述符名称、后端、配置及描述符专属信息。 |
|
|
202
|
+
|
|
203
|
+
For a batch with N atoms, S structures, P neighbor-pair rows, and F features,
|
|
204
|
+
the standard shapes are:
|
|
205
|
+
|
|
206
|
+
对于包含 N 个原子、S 个结构、P 条邻居对记录和 F 个特征的批次,标准形状为:
|
|
207
|
+
|
|
208
|
+
| Level / 层级 | values shape / values 形状 | atom_offsets |
|
|
209
|
+
|---|---:|---:|
|
|
210
|
+
| Atom / 原子级 | (N, F) | (S + 1,) |
|
|
211
|
+
| Structure / 结构级 | (S, F) | None |
|
|
212
|
+
| Pair / 邻居对级 | (P, F) | (S + 1,) |
|
|
213
|
+
|
|
214
|
+
All native descriptor results report metadata["backend"] == "mdescriptor-cpp".
|
|
215
|
+
The default numeric type is float64; SOAP, SOAPTurbo, ACSF, MTP, and NEP also
|
|
216
|
+
accept dtype="float32".
|
|
217
|
+
|
|
218
|
+
所有原生描述符结果都满足 metadata["backend"] == "mdescriptor-cpp"。
|
|
219
|
+
默认数值类型为 float64;SOAP、SOAPTurbo、ACSF、MTP 和 NEP 也支持
|
|
220
|
+
dtype="float32"。
|
|
221
|
+
|
|
222
|
+
## Descriptor outputs / 所有描述符输出
|
|
223
|
+
|
|
224
|
+
K is the number of configured species, R = max_radial + 1, A = max_angular + 1,
|
|
225
|
+
Nmax is the matrix padding size, and F denotes a descriptor-dependent feature
|
|
226
|
+
count. The exact feature count is also available as calculator.feature_count
|
|
227
|
+
after species or a model has been resolved.
|
|
228
|
+
|
|
229
|
+
其中 K 是配置的元素种类数,R = max_radial + 1,A = max_angular + 1,
|
|
230
|
+
Nmax 是矩阵补齐尺寸,F 表示由描述符参数决定的特征数。元素种类或模型解析后,
|
|
231
|
+
也可以通过 calculator.feature_count 获取精确特征数。
|
|
232
|
+
|
|
233
|
+
| Descriptor / 描述符 | Public entry / Python 入口 | Level / 层级 | Output / 输出 |
|
|
234
|
+
|---|---|---|---|
|
|
235
|
+
| SOAP | SoapCalculator | Atom or structure / 原子级或结构级 | average="off": (N, F); average="inner" or "outer": (S, F). Without compression, F = (K·n_max)(K·n_max + 1)(l_max + 1)/2. / 不压缩时的特征数如左。 |
|
|
236
|
+
| SOAPTurbo | SoapTurboCalculator | Atom / 原子级 | (N, F). Without compression, F = C(C + 1)(l_max + 1)/2, where C = sum(alpha_max). / 不压缩时的特征数如左。 |
|
|
237
|
+
| ACSF | AcsfCalculator | Atom / 原子级 | (N, F), F = (1 + G2 + G3)K + (G4 + G5)K(K + 1)/2. G1 contributes one channel per species. / G1 为每种元素提供一列。 |
|
|
238
|
+
| Coulomb matrix | CoulombMatrixCalculator | Structure / 结构级 | (S, Nmax²) for none/sorted_l2; (S, Nmax) for eigenspectrum. / none/sorted_l2 为矩阵展平,eigenspectrum 为特征值。 |
|
|
239
|
+
| Sine matrix | SineMatrixCalculator | Structure / 结构级 | Same layout as Coulomb matrix: (S, Nmax²) or (S, Nmax). / 与 Coulomb matrix 相同。 |
|
|
240
|
+
| Ewald sum matrix | EwaldSumMatrixCalculator | Structure / 结构级 | Same layout as Coulomb matrix: (S, Nmax²) or (S, Nmax). / 与 Coulomb matrix 相同。 |
|
|
241
|
+
| MBTR | MBTRCalculator | Structure / 结构级 | (S, F), a flattened grid of geometry channels. / (S, F),几何通道展平后的网格直方图。 |
|
|
242
|
+
| LMBTR | LMBTRCalculator | Atom / 原子级 | (N, F), a local flattened grid. / (N, F),局部几何通道展平后的网格。 |
|
|
243
|
+
| Valle–Oganov | ValleOganovCalculator | Structure / 结构级 | (S, F), a normalized MBTR-style histogram. / (S, F),归一化的 MBTR 风格直方图。 |
|
|
244
|
+
| Atomic composition | AtomicCompositionCalculator | Structure or atom / 结构级或原子级 | per_system=True: (S, K); per_system=False: (N, K). / 根据 per_system 选择结构级或原子级。 |
|
|
245
|
+
| Sorted distances | SortedDistancesCalculator | Atom / 原子级 | (N, F), padded and sorted neighbor distances; F is controlled by max_neighbors and separate_neighbor_types. / (N, F),补齐并排序后的邻居距离。 |
|
|
246
|
+
| Neighbor list | NeighborListCalculator | Pair / 邻居对级 | (P, 9). Columns: first, second, cell_shift_a, cell_shift_b, cell_shift_c, dx, dy, dz, distance. / 九列依次为原子索引、晶胞平移、位移和距离。 |
|
|
247
|
+
| Spherical expansion | SphericalExpansionCalculator | Atom / 原子级 | (N, K²RA²). / (N, K²RA²)。 |
|
|
248
|
+
| Spherical expansion by pair | SphericalExpansionByPairCalculator | Pair / 邻居对级 | (P, RA²), plus metadata["pair_records"] with shape (P, 9). / (P, RA²),并提供 (P, 9) 的邻居对记录。 |
|
|
249
|
+
| SOAP radial spectrum | SoapRadialSpectrumCalculator | Atom / 原子级 | (N, K²R). / (N, K²R)。 |
|
|
250
|
+
| SOAP power spectrum | SoapPowerSpectrumCalculator | Atom / 原子级 | (N, K · K(K + 1)/2 · A · R²). / 与物种对、角向和径向通道组合对应。 |
|
|
251
|
+
| LODE spherical expansion | LodeSphericalExpansionCalculator | Atom / 原子级 | (N, K²RA²), using reciprocal-space channels. / (N, K²RA²),使用倒空间通道。 |
|
|
252
|
+
| EAD | EadCalculator | Atom / 原子级 | (N, (L + 1)|eta||Rs|). / (N, (L + 1)|eta||Rs|)。 |
|
|
253
|
+
| SO3 | So3Calculator | Atom / 原子级 | (N, (l_max + 1)n_max(n_max + 1)/2). / (N, (l_max + 1)n_max(n_max + 1)/2)。 |
|
|
254
|
+
| SO4 | So4Calculator | Atom / 原子级 | (N, F), bispectrum components determined by lmax. / (N, F),双谱分量由 lmax 决定。 |
|
|
255
|
+
| SNAP | SnapCalculator | Atom / 原子级 | (N, F), determined by lmax, weights, and normalization. / (N, F),由 lmax、权重和归一化参数决定。 |
|
|
256
|
+
| LAMMPS bispectrum | LbispectrumCalculator | Atom / 原子级 | (N, F), determined by twojmax and diagonal. / (N, F),由 twojmax 和 diagonal 决定。 |
|
|
257
|
+
| MTP | MtpCalculator or MTP | Atom / 原子级 | (N, F). Generic mode emits traces and contractions; MLIP-2 emits mlip2:* columns; MLIP-4 JSON emits mlip4:basis=* columns. / 通用模式输出 trace 和 contraction,MLIP-2 输出 mlip2:*,MLIP-4 JSON 输出 mlip4:basis=*。 |
|
|
258
|
+
| C00PS-MLFF | C00PSMlffCalculator / C00PSMLFF | Atom / 原子级 | (N, F), local C00 radial channels plus PS angular power-spectrum channels. / (N, F),局部 C00 径向通道和 PS 角向 power-spectrum 通道。 |
|
|
259
|
+
| NEP | NepCalculator, NEPCalculator, or NEP | Atom / 原子级 | (N, F), the model-defined per-atom q vector with labels nep:q1, nep:q2, ... / (N, F),模型定义的逐原子 q 向量。 |
|
|
260
|
+
|
|
261
|
+
## Bundled model descriptors / 内置模型描述符
|
|
262
|
+
|
|
263
|
+
DPA4 and DPA4C are project-owned PyTorch model-backed descriptors. Install the
|
|
264
|
+
optional `torch` extra before constructing them. The DPA4 entry is a project-local port of the official
|
|
265
|
+
inference core: it accepts only official DPA4 `.pt` files and does not import
|
|
266
|
+
or require the upstream training package. The default models are bundled under
|
|
267
|
+
`mdescriptor/models/`; users may pass their own compatible model path.
|
|
268
|
+
|
|
269
|
+
DPA4 和 DPA4C 是项目内置的 PyTorch 模型驱动描述符。构造它们前请先安装可选的
|
|
270
|
+
`torch` extra。DPA4 入口使用项目内移植的官方推理核心,只接受官方 DPA4 `.pt`
|
|
271
|
+
文件,不导入也不依赖上游训练包。默认模型位于 `mdescriptor/models/`,用户也可以
|
|
272
|
+
传入自己的兼容模型路径。
|
|
273
|
+
|
|
274
|
+
DPA4 和 DPA4C 是项目自有的 PyTorch 模型驱动描述符。它们是可选功能,因为原生
|
|
275
|
+
描述符目录的运行不依赖 PyTorch。它们的特征维度和标签由输入检查点决定;独立的
|
|
276
|
+
DPA4 适配器只接受项目自有的 `mdescriptor.dpa4.v1` 检查点格式。
|
|
277
|
+
|
|
278
|
+
| Descriptor / 描述符 | Entry / 入口 | Level / 层级 | Output / 输出 |
|
|
279
|
+
|---|---|---|---|
|
|
280
|
+
| DPA4C | Dpa4cCalculator / DPA4C | Atom / 原子级 | (N, F), a checkpoint-defined calibrated invariant descriptor; metadata backend is `mdescriptor-torch`. / (N, F),由检查点决定维度的校准不变量描述符;元数据后端为 `mdescriptor-torch`。 |
|
|
281
|
+
| DPA4 | Dpa4Calculator / DPA4 | Atom / 原子级 | (N, 64) for the bundled model, official checkpoint-defined scalar channels; metadata backend is `mdescriptor-dpa4-official-native`. / 内置模型输出 (N, 64),通道由官方检查点定义;元数据后端为 `mdescriptor-dpa4-official-native`。 |
|
|
282
|
+
|
|
283
|
+
### Example: atom-level output / 原子级输出示例
|
|
284
|
+
|
|
285
|
+
~~~python
|
|
286
|
+
from mdescriptor import SoapCalculator
|
|
287
|
+
|
|
288
|
+
calculator = SoapCalculator(
|
|
289
|
+
species=[1, 8],
|
|
290
|
+
r_cut=4.5,
|
|
291
|
+
n_max=4,
|
|
292
|
+
l_max=3,
|
|
293
|
+
average="off",
|
|
294
|
+
)
|
|
295
|
+
result = calculator.compute(batch)
|
|
296
|
+
|
|
297
|
+
assert result.level == "atom"
|
|
298
|
+
assert result.values.shape == (batch.atoms, calculator.feature_count)
|
|
299
|
+
assert result.atom_offsets.shape == (batch.structures + 1,)
|
|
300
|
+
assert len(result.labels) == result.values.shape[1]
|
|
301
|
+
~~~
|
|
302
|
+
|
|
303
|
+
### Example: structure-level output / 结构级输出示例
|
|
304
|
+
|
|
305
|
+
~~~python
|
|
306
|
+
from mdescriptor import CoulombMatrixCalculator
|
|
307
|
+
|
|
308
|
+
result = CoulombMatrixCalculator(
|
|
309
|
+
n_atoms_max=16,
|
|
310
|
+
permutation="eigenspectrum",
|
|
311
|
+
).compute(batch)
|
|
312
|
+
|
|
313
|
+
assert result.level == "structure"
|
|
314
|
+
assert result.values.shape == (batch.structures, 16)
|
|
315
|
+
assert result.atom_offsets is None
|
|
316
|
+
~~~
|
|
317
|
+
|
|
318
|
+
### Example: pair-level output / 邻居对级输出示例
|
|
319
|
+
|
|
320
|
+
~~~python
|
|
321
|
+
from mdescriptor import NeighborListCalculator
|
|
322
|
+
|
|
323
|
+
result = NeighborListCalculator(cutoff=5.0).compute(batch)
|
|
324
|
+
|
|
325
|
+
assert result.level == "pair"
|
|
326
|
+
assert result.values.shape[1] == 9
|
|
327
|
+
assert result.atom_offsets.shape == (batch.structures + 1,)
|
|
328
|
+
first_structure_pairs = result.values[
|
|
329
|
+
result.atom_offsets[0] : result.atom_offsets[1]
|
|
330
|
+
]
|
|
331
|
+
~~~
|
|
332
|
+
|
|
333
|
+
## Public catalog / 公共目录
|
|
334
|
+
|
|
335
|
+
DESCRIPTOR_CATALOG contains 25 entries: the 24 native descriptors and the
|
|
336
|
+
DPA4C model-backed descriptor. DPA4 and NEP are intentionally separate because
|
|
337
|
+
their feature dimensions and parameters come from a model checkpoint.
|
|
338
|
+
|
|
339
|
+
DESCRIPTOR_CATALOG 包含 25 个入口:24 个原生描述符和 DPA4C 模型驱动描述符。
|
|
340
|
+
DPA4 和 NEP 没有加入目录,因为它们的特征维度和参数由模型检查点决定。
|
|
341
|
+
|
|
342
|
+
~~~python
|
|
343
|
+
from mdescriptor import DESCRIPTOR_CATALOG, descriptor_inventory
|
|
344
|
+
|
|
345
|
+
print(descriptor_inventory())
|
|
346
|
+
calculator_class = DESCRIPTOR_CATALOG["SOAP"]
|
|
347
|
+
~~~
|
|
348
|
+
|
|
349
|
+
## Scope / 范围
|
|
350
|
+
|
|
351
|
+
MDescriptor implements native descriptor kernels and compatibility-oriented
|
|
352
|
+
Python adapters. Reference package names in class names or metadata describe
|
|
353
|
+
the supported mathematical conventions; those reference packages are not
|
|
354
|
+
required at runtime for the native calculation path.
|
|
355
|
+
|
|
356
|
+
MDescriptor 包含原生描述符计算核心和面向兼容性的 Python 适配器。类名或元数据中
|
|
357
|
+
出现的参考包名称表示所支持的数学约定;原生计算路径运行时不要求安装这些参考包。
|