lammps-analysis-tools 1.0.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.
- lammps-analysis-tools-1.0.0/LICENSE +14 -0
- lammps-analysis-tools-1.0.0/MANIFEST.in +12 -0
- lammps-analysis-tools-1.0.0/PKG-INFO +231 -0
- lammps-analysis-tools-1.0.0/README.md +198 -0
- lammps-analysis-tools-1.0.0/pyproject.toml +62 -0
- lammps-analysis-tools-1.0.0/setup.cfg +4 -0
- lammps-analysis-tools-1.0.0/src/lammps_analysis_tools.egg-info/PKG-INFO +231 -0
- lammps-analysis-tools-1.0.0/src/lammps_analysis_tools.egg-info/SOURCES.txt +78 -0
- lammps-analysis-tools-1.0.0/src/lammps_analysis_tools.egg-info/dependency_links.txt +1 -0
- lammps-analysis-tools-1.0.0/src/lammps_analysis_tools.egg-info/entry_points.txt +2 -0
- lammps-analysis-tools-1.0.0/src/lammps_analysis_tools.egg-info/requires.txt +6 -0
- lammps-analysis-tools-1.0.0/src/lammps_analysis_tools.egg-info/top_level.txt +1 -0
- lammps-analysis-tools-1.0.0/src/lat/__init__.py +3 -0
- lammps-analysis-tools-1.0.0/src/lat/__main__.py +6 -0
- lammps-analysis-tools-1.0.0/src/lat/cli.py +270 -0
- lammps-analysis-tools-1.0.0/src/lat/config.py +106 -0
- lammps-analysis-tools-1.0.0/src/lat/core/__init__.py +6 -0
- lammps-analysis-tools-1.0.0/src/lat/core/context.py +155 -0
- lammps-analysis-tools-1.0.0/src/lat/core/correlate.py +67 -0
- lammps-analysis-tools-1.0.0/src/lat/core/errors.py +60 -0
- lammps-analysis-tools-1.0.0/src/lat/core/frame.py +74 -0
- lammps-analysis-tools-1.0.0/src/lat/core/grid.py +59 -0
- lammps-analysis-tools-1.0.0/src/lat/core/io/__init__.py +184 -0
- lammps-analysis-tools-1.0.0/src/lat/core/io/gmx.py +223 -0
- lammps-analysis-tools-1.0.0/src/lat/core/io/lammps_data.py +210 -0
- lammps-analysis-tools-1.0.0/src/lat/core/io/lammps_dump.py +81 -0
- lammps-analysis-tools-1.0.0/src/lat/core/neighbor.py +104 -0
- lammps-analysis-tools-1.0.0/src/lat/core/output.py +133 -0
- lammps-analysis-tools-1.0.0/src/lat/core/pbc.py +140 -0
- lammps-analysis-tools-1.0.0/src/lat/core/periodic.py +694 -0
- lammps-analysis-tools-1.0.0/src/lat/core/selection.py +216 -0
- lammps-analysis-tools-1.0.0/src/lat/core/table.py +90 -0
- lammps-analysis-tools-1.0.0/src/lat/core/topology.py +145 -0
- lammps-analysis-tools-1.0.0/src/lat/core/unwrap.py +68 -0
- lammps-analysis-tools-1.0.0/src/lat/data/lat.yaml +259 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/README.md +44 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/agg.md +57 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/cluster.md +56 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/common.md +111 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/contact.md +54 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/density.md +55 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/describe.md +47 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/freevol.md +60 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/gyrate.md +49 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/hbond.md +61 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/msd.md +55 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/occupancy.md +54 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/pistack.md +55 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/plot1d.md +50 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/plot2d.md +45 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/rdf.md +55 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/residence.md +56 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/rms.md +54 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/sasa.md +53 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/select.md +52 -0
- lammps-analysis-tools-1.0.0/src/lat/data/manual/transport.md +55 -0
- lammps-analysis-tools-1.0.0/src/lat/docs.py +55 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/__init__.py +54 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/_graph.py +130 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/agg.py +162 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/base.py +58 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/cluster.py +89 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/contact.py +106 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/density.py +164 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/describe.py +42 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/freevol.py +328 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/gyrate.py +88 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/hbond.py +374 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/msd.py +144 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/occupancy.py +179 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/pistack.py +129 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/rdf.py +175 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/residence.py +188 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/rms.py +158 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/sasa.py +78 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/select.py +67 -0
- lammps-analysis-tools-1.0.0/src/lat/modules/transport.py +187 -0
- lammps-analysis-tools-1.0.0/src/lat/plotting/__init__.py +6 -0
- lammps-analysis-tools-1.0.0/src/lat/plotting/plot1d.py +161 -0
- lammps-analysis-tools-1.0.0/src/lat/plotting/plot2d.py +78 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright (c) 2026 tgraphite. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its accompanying documentation (the "Software") are
|
|
4
|
+
proprietary. No permission is granted to use, copy, modify, merge, publish,
|
|
5
|
+
distribute, sublicense, or sell copies of the Software without the prior
|
|
6
|
+
written permission of the copyright holder.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
9
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
10
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
11
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
12
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
13
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
14
|
+
SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include pyproject.toml
|
|
4
|
+
|
|
5
|
+
# only the runtime package and its data ship in the sdist/wheel
|
|
6
|
+
recursive-include src/lat/data *.yaml *.md
|
|
7
|
+
|
|
8
|
+
# development material never ships
|
|
9
|
+
prune tests
|
|
10
|
+
prune docs
|
|
11
|
+
prune config
|
|
12
|
+
global-exclude __pycache__ *.py[cod] *.egg-info
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: lammps-analysis-tools
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Trajectory analysis for LAMMPS data/dump files, with GROMACS-compatible commands
|
|
5
|
+
Author: tgraphite
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Project-URL: Homepage, https://github.com/tgraphite/LammpsAnalysisTools
|
|
8
|
+
Project-URL: Documentation, https://github.com/tgraphite/LammpsAnalysisTools/tree/main/docs/manual
|
|
9
|
+
Project-URL: Repository, https://github.com/tgraphite/LammpsAnalysisTools
|
|
10
|
+
Project-URL: Issues, https://github.com/tgraphite/LammpsAnalysisTools/issues
|
|
11
|
+
Keywords: molecular dynamics,LAMMPS,GROMACS,trajectory analysis,RDF,hydrogen bonds,free volume,SASA
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: Other/Proprietary License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: numpy>=1.22
|
|
28
|
+
Requires-Dist: scipy>=1.8
|
|
29
|
+
Requires-Dist: pyyaml>=5.4
|
|
30
|
+
Requires-Dist: matplotlib>=3.5
|
|
31
|
+
Requires-Dist: MDAnalysis>=2.4
|
|
32
|
+
Requires-Dist: ase>=3.22
|
|
33
|
+
|
|
34
|
+
# lat — LAMMPS Analysis Tool
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/lammps-analysis-tools/)
|
|
37
|
+
[](https://pypi.org/project/lammps-analysis-tools/)
|
|
38
|
+
|
|
39
|
+
面向 LAMMPS `data` / `lammpstrj` 的轨迹分析工具。命令风格对齐 GROMACS(`-s` 拓扑、`-f` 轨迹、单横线参数),
|
|
40
|
+
输出统一为带审计头的 CSV,适合脚本批处理、回归与作图。
|
|
41
|
+
|
|
42
|
+
## 特性
|
|
43
|
+
|
|
44
|
+
- **直接读 LAMMPS**:`*.data` / `*.lmp` + `*.lammpstrj`,自动识别 `atom_style`,按质量推断元素。
|
|
45
|
+
- **GROMACS 兼容输入**:`.tpr/.gro/.pdb` + `.xtc/.trr/.gro` 可直接分析,便于交叉验证。
|
|
46
|
+
- **周期几何一致性**:所有距离、质心、整分子复原、网格与曲面都走同一套最小镜像实现。
|
|
47
|
+
- **可复现输出**:文件名即意图;CSV 头记录命令、选择、参数、警告与标量;同名输出自动备份。
|
|
48
|
+
- **自解释**:`lat --help` 列出模块,`lat <module> -h` 给出参数与默认值,`lat describe -module <name>` 给出完整契约。
|
|
49
|
+
|
|
50
|
+
## 安装
|
|
51
|
+
|
|
52
|
+
需要 Python ≥ 3.9。
|
|
53
|
+
|
|
54
|
+
pip install lammps-analysis-tools
|
|
55
|
+
|
|
56
|
+
安装后命令是 `lat`:
|
|
57
|
+
|
|
58
|
+
lat --version
|
|
59
|
+
lat --help
|
|
60
|
+
|
|
61
|
+
升级:
|
|
62
|
+
|
|
63
|
+
pip install --upgrade lammps-analysis-tools
|
|
64
|
+
|
|
65
|
+
从源码或离线安装:
|
|
66
|
+
|
|
67
|
+
git clone https://github.com/tgraphite/LammpsAnalysisTools.git
|
|
68
|
+
cd LammpsAnalysisTools
|
|
69
|
+
bash install.sh
|
|
70
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
71
|
+
|
|
72
|
+
`install.sh` 会建独立虚拟环境、安装依赖,并把 `lat` 放到 `~/.local/bin`;系统 Python < 3.9 时会用
|
|
73
|
+
`uv` 引导一个私有 Python 3.11。也可以直接 `pip install .`。
|
|
74
|
+
|
|
75
|
+
依赖:numpy、scipy、pyyaml、matplotlib、MDAnalysis、ase。
|
|
76
|
+
|
|
77
|
+
## 快速开始
|
|
78
|
+
|
|
79
|
+
# 径向分布函数 + 配位数
|
|
80
|
+
lat rdf -s system.data -f run.lammpstrj -sel1 "type 2" -sel2 "type 5" -cutoff 10 -o out
|
|
81
|
+
|
|
82
|
+
# 沿 z 的密度剖面
|
|
83
|
+
lat density -s system.data -f run.lammpstrj -axis z -nbins 200 -o out
|
|
84
|
+
|
|
85
|
+
# 均方位移与扩散系数
|
|
86
|
+
lat msd -s system.data -f run.lammpstrj -sel "type 2" -o out
|
|
87
|
+
|
|
88
|
+
# 画图(输入是上一步的 CSV)
|
|
89
|
+
lat plot1d -f out.rdf.out.csv -o rdf.png
|
|
90
|
+
|
|
91
|
+
结果写入当前目录或 `-o` 指定的基名:
|
|
92
|
+
|
|
93
|
+
out.rdf.out.csv
|
|
94
|
+
out.rdf.cn.out.csv
|
|
95
|
+
|
|
96
|
+
## 支持输入
|
|
97
|
+
|
|
98
|
+
| | 拓扑 | 轨迹 |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| LAMMPS(首选) | `.data` / `.lmp`:Masses、Atoms;含 Bonds 才能做氢键/整分子分析 | `.lammpstrj`(dump) |
|
|
101
|
+
| GROMACS | `.tpr` / `.gro` / `.pdb` | `.xtc` / `.trr` / `.gro` |
|
|
102
|
+
|
|
103
|
+
- 自动识别 `atomic`、`charge`、`molecular`、`full`,支持 `full/kk` 等加速器后缀;六列歧义时用 `-style`。
|
|
104
|
+
- 类型→元素默认按质量 ±0.2% 匹配;不确定时用 `-types` 显式指定,或让 dump 带 `element` 列。
|
|
105
|
+
- 坐标支持 `x/y/z`、`xu/yu/zu`、`xs/ys/zs`、`xsu/ysu/zsu`;带 `ix/iy/iz` 可解包。
|
|
106
|
+
- 反应轨迹原子数逐帧变化时会报错,并提示用 `-frame_range` / `-stride` 限定到一致窗口。
|
|
107
|
+
|
|
108
|
+
## 模块总览
|
|
109
|
+
|
|
110
|
+
| 模块 | 用途 | 手册 |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| `rdf` | 径向分布函数 g(r) 与配位数 | [rdf](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/rdf.md) |
|
|
113
|
+
| `density` | 一维/二维密度剖面 | [density](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/density.md) |
|
|
114
|
+
| `msd` | 均方位移与扩散系数 | [msd](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/msd.md) |
|
|
115
|
+
| `gyrate` | 回转半径 Rg | [gyrate](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/gyrate.md) |
|
|
116
|
+
| `rms` | RMSD / RMSF | [rms](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/rms.md) |
|
|
117
|
+
| `contact` | 两组间接触数与距离 | [contact](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/contact.md) |
|
|
118
|
+
| `hbond` | 氢键数量、寿命与空间分布 | [hbond](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/hbond.md) |
|
|
119
|
+
| `agg` | SSIP / CIP / AGG 离子聚合形态 | [agg](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/agg.md) |
|
|
120
|
+
| `cluster` | 配位数与团簇尺寸分布 | [cluster](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/cluster.md) |
|
|
121
|
+
| `pistack` | π–π 堆积 | [pistack](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/pistack.md) |
|
|
122
|
+
| `freevol` | 自由体积、孔径分布、连通性 | [freevol](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/freevol.md) |
|
|
123
|
+
| `sasa` | 溶剂可及表面积 | [sasa](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/sasa.md) |
|
|
124
|
+
| `residence` | 配体滞留时间 | [residence](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/residence.md) |
|
|
125
|
+
| `transport` | 扩散、Nernst–Einstein、Green–Kubo | [transport](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/transport.md) |
|
|
126
|
+
| `occupancy` | 区域占据、穿越、首次通过 | [occupancy](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/occupancy.md) |
|
|
127
|
+
| `select` | 检查选择、导出 .ndx | [select](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/select.md) |
|
|
128
|
+
| `describe` | 模块清单与契约 | [describe](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/describe.md) |
|
|
129
|
+
| `plot1d` | 一维 CSV 绘图 | [plot1d](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/plot1d.md) |
|
|
130
|
+
| `plot2d` | 二维 CSV 绘图 | [plot2d](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/plot2d.md) |
|
|
131
|
+
|
|
132
|
+
完整手册(公共参数、输入、选择语法、输出契约):[docs/manual](https://github.com/tgraphite/LammpsAnalysisTools/tree/main/docs/manual)。
|
|
133
|
+
|
|
134
|
+
## 公共参数
|
|
135
|
+
|
|
136
|
+
| 参数 | 说明 |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `-s, -topo` | 拓扑文件(分析模块必填) |
|
|
139
|
+
| `-f, -traj` | 轨迹文件 |
|
|
140
|
+
| `-o` | 输出基名;缺省用拓扑文件名 |
|
|
141
|
+
| `-unit` | 长度单位:`real`、`metal`、`lj`;缺省用配置 |
|
|
142
|
+
| `-style` | 强制 LAMMPS `atom_style` |
|
|
143
|
+
| `-types` | type→元素映射文件,每行 `type element` |
|
|
144
|
+
| `-index, -n` | GROMACS `.ndx`,为选择提供命名组 |
|
|
145
|
+
| `-frame_range` | 帧窗口 `start:stop[:stride]`,stop 不含 |
|
|
146
|
+
| `-stride` | 每隔多少帧取一帧 |
|
|
147
|
+
| `-v` | 显示 INFO 进度 |
|
|
148
|
+
| `-debug` | 额外写 JSON 审计 |
|
|
149
|
+
| `-h` | 模块帮助(含默认值) |
|
|
150
|
+
| `-V, --version` | 版本号 |
|
|
151
|
+
|
|
152
|
+
PBC 始终开启,所有距离使用最小镜像。时间轴是帧号,不解析文件中的物理时间。
|
|
153
|
+
|
|
154
|
+
## 选择语法
|
|
155
|
+
|
|
156
|
+
MDAnalysis 风格子集,支持 `and`、`or`、`not` 与括号;相邻关键字隐含 `and`。
|
|
157
|
+
|
|
158
|
+
| 关键字 | 含义 | LAMMPS | GROMACS |
|
|
159
|
+
|---|---|---|---|
|
|
160
|
+
| `all` | 全部原子 | 是 | 是 |
|
|
161
|
+
| `type` | 原子类型 | 是 | 是 |
|
|
162
|
+
| `element` | 元素符号 | 是(需推断或 `-types`) | 是 |
|
|
163
|
+
| `mol` | 分子 ID | 是(需分子信息) | 是 |
|
|
164
|
+
| `id` | 原子 id | 是 | 是 |
|
|
165
|
+
| `index` | 0-based 原子序号 | 是 | 是 |
|
|
166
|
+
| `name` | 原子名 | 否 | 是 |
|
|
167
|
+
| `resname` | 残基名 | 否 | 是 |
|
|
168
|
+
| `resid` | 残基号 | 否 | 是 |
|
|
169
|
+
|
|
170
|
+
-sel "type 2"
|
|
171
|
+
-sel "type 2 or type 5"
|
|
172
|
+
-sel1 "resname LI" -sel2 "resname FSI"
|
|
173
|
+
-sel "all and not type 1"
|
|
174
|
+
|
|
175
|
+
单选择模块用 `-sel`;双选择模块用 `-sel1`/`-sel2`。先运行 `lat select` 验证命中。
|
|
176
|
+
|
|
177
|
+
## 输出
|
|
178
|
+
|
|
179
|
+
- 结果全部写入 CSV;stdout 为空,进度/警告/错误走 stderr。
|
|
180
|
+
- 文件名:`<basename>.<tag>[.<mode>].out.csv`。
|
|
181
|
+
- 文件头以 `#` 开头,包含 program、module、command、selections、definitions、frame_range、
|
|
182
|
+
scalars、warning、title、xlabel、ylabel、columns,最后是 `# --- data ---`。
|
|
183
|
+
- 标量(首壳配位数、D、R²、寿命、积分等)在 `# scalars:` 行,分号分隔。
|
|
184
|
+
- 同名文件先备份为 `.bak.1`、`.bak.2`……,不会静默覆盖。
|
|
185
|
+
- 退出码:0 成功,1 参数/输入/计算错误,130 中断;警告不改变退出码。
|
|
186
|
+
|
|
187
|
+
## 绘图
|
|
188
|
+
|
|
189
|
+
`plot1d` / `plot2d` 只读 CSV,计算与绘图解耦。
|
|
190
|
+
|
|
191
|
+
lat plot1d -f out.rdf.out.csv -o rdf.png
|
|
192
|
+
lat plot1d -f out.agg.labels.out.csv -columns A_SSIP,A_CIP,A_AGG -o spec.png
|
|
193
|
+
lat plot1d -f out.agg.labels.out.csv -stack -o spec_stack.png
|
|
194
|
+
lat plot2d -f out.density.2d.out.csv -o density2d.png
|
|
195
|
+
|
|
196
|
+
`-smooth`(`none`/`gaussian`/`savgol`)只在绘图阶段生效,CSV 始终是原始值;
|
|
197
|
+
`-bar` 与 `-stack` 互斥,且不做平滑。
|
|
198
|
+
|
|
199
|
+
## 配置
|
|
200
|
+
|
|
201
|
+
默认值来自 `lat.yaml`:源码树是 `config/lat.yaml`,安装后是包内 `data/lat.yaml`。
|
|
202
|
+
命令行覆盖配置。
|
|
203
|
+
|
|
204
|
+
| 环境变量 | 作用 |
|
|
205
|
+
|---|---|
|
|
206
|
+
| `LAT_CONFIG` | 使用自定义配置文件 |
|
|
207
|
+
| `LAT_VENV` | `install.sh` 创建的虚拟环境路径 |
|
|
208
|
+
| `LAT_BIN` | `install.sh` 放置 `lat` 的目录 |
|
|
209
|
+
| `PYTHON` | `install.sh` 使用的解释器 |
|
|
210
|
+
|
|
211
|
+
## 文档
|
|
212
|
+
|
|
213
|
+
- 逐模块手册:[docs/manual](https://github.com/tgraphite/LammpsAnalysisTools/tree/main/docs/manual)
|
|
214
|
+
- 公共参数与输出契约:[common.md](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/common.md)
|
|
215
|
+
- 版本变更:[CHANGELOG.md](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/CHANGELOG.md)
|
|
216
|
+
|
|
217
|
+
## 常见问题
|
|
218
|
+
|
|
219
|
+
**选择命中 0 个原子?** 用 `lat select` 检查表达式;LAMMPS 拓扑通常没有 `resname`/`name`。
|
|
220
|
+
|
|
221
|
+
**元素推断失败?** 补 `Masses`,或让 dump 带 `element` 列,或用 `-types`。
|
|
222
|
+
|
|
223
|
+
**氢键报 “no donor”?** 给体只认 N/O/F/S/Cl/Br/I 上的 H;C–H 不是给体。
|
|
224
|
+
|
|
225
|
+
**MSD 提示没有 image flags?** 轨迹只有 wrapped 坐标,MSD 可能饱和;改用带 `xu/yu/zu` 或 `ix/iy/iz` 的 dump。
|
|
226
|
+
|
|
227
|
+
**freevol 报三斜盒?** 体素网格只支持正交且固定的盒子;改用分子/原子对分析或正交化盒子。
|
|
228
|
+
|
|
229
|
+
## 许可
|
|
230
|
+
|
|
231
|
+
Proprietary。详见 [LICENSE](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/LICENSE)。
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# lat — LAMMPS Analysis Tool
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/lammps-analysis-tools/)
|
|
4
|
+
[](https://pypi.org/project/lammps-analysis-tools/)
|
|
5
|
+
|
|
6
|
+
面向 LAMMPS `data` / `lammpstrj` 的轨迹分析工具。命令风格对齐 GROMACS(`-s` 拓扑、`-f` 轨迹、单横线参数),
|
|
7
|
+
输出统一为带审计头的 CSV,适合脚本批处理、回归与作图。
|
|
8
|
+
|
|
9
|
+
## 特性
|
|
10
|
+
|
|
11
|
+
- **直接读 LAMMPS**:`*.data` / `*.lmp` + `*.lammpstrj`,自动识别 `atom_style`,按质量推断元素。
|
|
12
|
+
- **GROMACS 兼容输入**:`.tpr/.gro/.pdb` + `.xtc/.trr/.gro` 可直接分析,便于交叉验证。
|
|
13
|
+
- **周期几何一致性**:所有距离、质心、整分子复原、网格与曲面都走同一套最小镜像实现。
|
|
14
|
+
- **可复现输出**:文件名即意图;CSV 头记录命令、选择、参数、警告与标量;同名输出自动备份。
|
|
15
|
+
- **自解释**:`lat --help` 列出模块,`lat <module> -h` 给出参数与默认值,`lat describe -module <name>` 给出完整契约。
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
需要 Python ≥ 3.9。
|
|
20
|
+
|
|
21
|
+
pip install lammps-analysis-tools
|
|
22
|
+
|
|
23
|
+
安装后命令是 `lat`:
|
|
24
|
+
|
|
25
|
+
lat --version
|
|
26
|
+
lat --help
|
|
27
|
+
|
|
28
|
+
升级:
|
|
29
|
+
|
|
30
|
+
pip install --upgrade lammps-analysis-tools
|
|
31
|
+
|
|
32
|
+
从源码或离线安装:
|
|
33
|
+
|
|
34
|
+
git clone https://github.com/tgraphite/LammpsAnalysisTools.git
|
|
35
|
+
cd LammpsAnalysisTools
|
|
36
|
+
bash install.sh
|
|
37
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
38
|
+
|
|
39
|
+
`install.sh` 会建独立虚拟环境、安装依赖,并把 `lat` 放到 `~/.local/bin`;系统 Python < 3.9 时会用
|
|
40
|
+
`uv` 引导一个私有 Python 3.11。也可以直接 `pip install .`。
|
|
41
|
+
|
|
42
|
+
依赖:numpy、scipy、pyyaml、matplotlib、MDAnalysis、ase。
|
|
43
|
+
|
|
44
|
+
## 快速开始
|
|
45
|
+
|
|
46
|
+
# 径向分布函数 + 配位数
|
|
47
|
+
lat rdf -s system.data -f run.lammpstrj -sel1 "type 2" -sel2 "type 5" -cutoff 10 -o out
|
|
48
|
+
|
|
49
|
+
# 沿 z 的密度剖面
|
|
50
|
+
lat density -s system.data -f run.lammpstrj -axis z -nbins 200 -o out
|
|
51
|
+
|
|
52
|
+
# 均方位移与扩散系数
|
|
53
|
+
lat msd -s system.data -f run.lammpstrj -sel "type 2" -o out
|
|
54
|
+
|
|
55
|
+
# 画图(输入是上一步的 CSV)
|
|
56
|
+
lat plot1d -f out.rdf.out.csv -o rdf.png
|
|
57
|
+
|
|
58
|
+
结果写入当前目录或 `-o` 指定的基名:
|
|
59
|
+
|
|
60
|
+
out.rdf.out.csv
|
|
61
|
+
out.rdf.cn.out.csv
|
|
62
|
+
|
|
63
|
+
## 支持输入
|
|
64
|
+
|
|
65
|
+
| | 拓扑 | 轨迹 |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| LAMMPS(首选) | `.data` / `.lmp`:Masses、Atoms;含 Bonds 才能做氢键/整分子分析 | `.lammpstrj`(dump) |
|
|
68
|
+
| GROMACS | `.tpr` / `.gro` / `.pdb` | `.xtc` / `.trr` / `.gro` |
|
|
69
|
+
|
|
70
|
+
- 自动识别 `atomic`、`charge`、`molecular`、`full`,支持 `full/kk` 等加速器后缀;六列歧义时用 `-style`。
|
|
71
|
+
- 类型→元素默认按质量 ±0.2% 匹配;不确定时用 `-types` 显式指定,或让 dump 带 `element` 列。
|
|
72
|
+
- 坐标支持 `x/y/z`、`xu/yu/zu`、`xs/ys/zs`、`xsu/ysu/zsu`;带 `ix/iy/iz` 可解包。
|
|
73
|
+
- 反应轨迹原子数逐帧变化时会报错,并提示用 `-frame_range` / `-stride` 限定到一致窗口。
|
|
74
|
+
|
|
75
|
+
## 模块总览
|
|
76
|
+
|
|
77
|
+
| 模块 | 用途 | 手册 |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `rdf` | 径向分布函数 g(r) 与配位数 | [rdf](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/rdf.md) |
|
|
80
|
+
| `density` | 一维/二维密度剖面 | [density](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/density.md) |
|
|
81
|
+
| `msd` | 均方位移与扩散系数 | [msd](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/msd.md) |
|
|
82
|
+
| `gyrate` | 回转半径 Rg | [gyrate](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/gyrate.md) |
|
|
83
|
+
| `rms` | RMSD / RMSF | [rms](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/rms.md) |
|
|
84
|
+
| `contact` | 两组间接触数与距离 | [contact](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/contact.md) |
|
|
85
|
+
| `hbond` | 氢键数量、寿命与空间分布 | [hbond](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/hbond.md) |
|
|
86
|
+
| `agg` | SSIP / CIP / AGG 离子聚合形态 | [agg](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/agg.md) |
|
|
87
|
+
| `cluster` | 配位数与团簇尺寸分布 | [cluster](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/cluster.md) |
|
|
88
|
+
| `pistack` | π–π 堆积 | [pistack](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/pistack.md) |
|
|
89
|
+
| `freevol` | 自由体积、孔径分布、连通性 | [freevol](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/freevol.md) |
|
|
90
|
+
| `sasa` | 溶剂可及表面积 | [sasa](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/sasa.md) |
|
|
91
|
+
| `residence` | 配体滞留时间 | [residence](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/residence.md) |
|
|
92
|
+
| `transport` | 扩散、Nernst–Einstein、Green–Kubo | [transport](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/transport.md) |
|
|
93
|
+
| `occupancy` | 区域占据、穿越、首次通过 | [occupancy](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/occupancy.md) |
|
|
94
|
+
| `select` | 检查选择、导出 .ndx | [select](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/select.md) |
|
|
95
|
+
| `describe` | 模块清单与契约 | [describe](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/describe.md) |
|
|
96
|
+
| `plot1d` | 一维 CSV 绘图 | [plot1d](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/plot1d.md) |
|
|
97
|
+
| `plot2d` | 二维 CSV 绘图 | [plot2d](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/plot2d.md) |
|
|
98
|
+
|
|
99
|
+
完整手册(公共参数、输入、选择语法、输出契约):[docs/manual](https://github.com/tgraphite/LammpsAnalysisTools/tree/main/docs/manual)。
|
|
100
|
+
|
|
101
|
+
## 公共参数
|
|
102
|
+
|
|
103
|
+
| 参数 | 说明 |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `-s, -topo` | 拓扑文件(分析模块必填) |
|
|
106
|
+
| `-f, -traj` | 轨迹文件 |
|
|
107
|
+
| `-o` | 输出基名;缺省用拓扑文件名 |
|
|
108
|
+
| `-unit` | 长度单位:`real`、`metal`、`lj`;缺省用配置 |
|
|
109
|
+
| `-style` | 强制 LAMMPS `atom_style` |
|
|
110
|
+
| `-types` | type→元素映射文件,每行 `type element` |
|
|
111
|
+
| `-index, -n` | GROMACS `.ndx`,为选择提供命名组 |
|
|
112
|
+
| `-frame_range` | 帧窗口 `start:stop[:stride]`,stop 不含 |
|
|
113
|
+
| `-stride` | 每隔多少帧取一帧 |
|
|
114
|
+
| `-v` | 显示 INFO 进度 |
|
|
115
|
+
| `-debug` | 额外写 JSON 审计 |
|
|
116
|
+
| `-h` | 模块帮助(含默认值) |
|
|
117
|
+
| `-V, --version` | 版本号 |
|
|
118
|
+
|
|
119
|
+
PBC 始终开启,所有距离使用最小镜像。时间轴是帧号,不解析文件中的物理时间。
|
|
120
|
+
|
|
121
|
+
## 选择语法
|
|
122
|
+
|
|
123
|
+
MDAnalysis 风格子集,支持 `and`、`or`、`not` 与括号;相邻关键字隐含 `and`。
|
|
124
|
+
|
|
125
|
+
| 关键字 | 含义 | LAMMPS | GROMACS |
|
|
126
|
+
|---|---|---|---|
|
|
127
|
+
| `all` | 全部原子 | 是 | 是 |
|
|
128
|
+
| `type` | 原子类型 | 是 | 是 |
|
|
129
|
+
| `element` | 元素符号 | 是(需推断或 `-types`) | 是 |
|
|
130
|
+
| `mol` | 分子 ID | 是(需分子信息) | 是 |
|
|
131
|
+
| `id` | 原子 id | 是 | 是 |
|
|
132
|
+
| `index` | 0-based 原子序号 | 是 | 是 |
|
|
133
|
+
| `name` | 原子名 | 否 | 是 |
|
|
134
|
+
| `resname` | 残基名 | 否 | 是 |
|
|
135
|
+
| `resid` | 残基号 | 否 | 是 |
|
|
136
|
+
|
|
137
|
+
-sel "type 2"
|
|
138
|
+
-sel "type 2 or type 5"
|
|
139
|
+
-sel1 "resname LI" -sel2 "resname FSI"
|
|
140
|
+
-sel "all and not type 1"
|
|
141
|
+
|
|
142
|
+
单选择模块用 `-sel`;双选择模块用 `-sel1`/`-sel2`。先运行 `lat select` 验证命中。
|
|
143
|
+
|
|
144
|
+
## 输出
|
|
145
|
+
|
|
146
|
+
- 结果全部写入 CSV;stdout 为空,进度/警告/错误走 stderr。
|
|
147
|
+
- 文件名:`<basename>.<tag>[.<mode>].out.csv`。
|
|
148
|
+
- 文件头以 `#` 开头,包含 program、module、command、selections、definitions、frame_range、
|
|
149
|
+
scalars、warning、title、xlabel、ylabel、columns,最后是 `# --- data ---`。
|
|
150
|
+
- 标量(首壳配位数、D、R²、寿命、积分等)在 `# scalars:` 行,分号分隔。
|
|
151
|
+
- 同名文件先备份为 `.bak.1`、`.bak.2`……,不会静默覆盖。
|
|
152
|
+
- 退出码:0 成功,1 参数/输入/计算错误,130 中断;警告不改变退出码。
|
|
153
|
+
|
|
154
|
+
## 绘图
|
|
155
|
+
|
|
156
|
+
`plot1d` / `plot2d` 只读 CSV,计算与绘图解耦。
|
|
157
|
+
|
|
158
|
+
lat plot1d -f out.rdf.out.csv -o rdf.png
|
|
159
|
+
lat plot1d -f out.agg.labels.out.csv -columns A_SSIP,A_CIP,A_AGG -o spec.png
|
|
160
|
+
lat plot1d -f out.agg.labels.out.csv -stack -o spec_stack.png
|
|
161
|
+
lat plot2d -f out.density.2d.out.csv -o density2d.png
|
|
162
|
+
|
|
163
|
+
`-smooth`(`none`/`gaussian`/`savgol`)只在绘图阶段生效,CSV 始终是原始值;
|
|
164
|
+
`-bar` 与 `-stack` 互斥,且不做平滑。
|
|
165
|
+
|
|
166
|
+
## 配置
|
|
167
|
+
|
|
168
|
+
默认值来自 `lat.yaml`:源码树是 `config/lat.yaml`,安装后是包内 `data/lat.yaml`。
|
|
169
|
+
命令行覆盖配置。
|
|
170
|
+
|
|
171
|
+
| 环境变量 | 作用 |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `LAT_CONFIG` | 使用自定义配置文件 |
|
|
174
|
+
| `LAT_VENV` | `install.sh` 创建的虚拟环境路径 |
|
|
175
|
+
| `LAT_BIN` | `install.sh` 放置 `lat` 的目录 |
|
|
176
|
+
| `PYTHON` | `install.sh` 使用的解释器 |
|
|
177
|
+
|
|
178
|
+
## 文档
|
|
179
|
+
|
|
180
|
+
- 逐模块手册:[docs/manual](https://github.com/tgraphite/LammpsAnalysisTools/tree/main/docs/manual)
|
|
181
|
+
- 公共参数与输出契约:[common.md](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/manual/common.md)
|
|
182
|
+
- 版本变更:[CHANGELOG.md](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/docs/CHANGELOG.md)
|
|
183
|
+
|
|
184
|
+
## 常见问题
|
|
185
|
+
|
|
186
|
+
**选择命中 0 个原子?** 用 `lat select` 检查表达式;LAMMPS 拓扑通常没有 `resname`/`name`。
|
|
187
|
+
|
|
188
|
+
**元素推断失败?** 补 `Masses`,或让 dump 带 `element` 列,或用 `-types`。
|
|
189
|
+
|
|
190
|
+
**氢键报 “no donor”?** 给体只认 N/O/F/S/Cl/Br/I 上的 H;C–H 不是给体。
|
|
191
|
+
|
|
192
|
+
**MSD 提示没有 image flags?** 轨迹只有 wrapped 坐标,MSD 可能饱和;改用带 `xu/yu/zu` 或 `ix/iy/iz` 的 dump。
|
|
193
|
+
|
|
194
|
+
**freevol 报三斜盒?** 体素网格只支持正交且固定的盒子;改用分子/原子对分析或正交化盒子。
|
|
195
|
+
|
|
196
|
+
## 许可
|
|
197
|
+
|
|
198
|
+
Proprietary。详见 [LICENSE](https://github.com/tgraphite/LammpsAnalysisTools/blob/main/LICENSE)。
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lammps-analysis-tools"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Trajectory analysis for LAMMPS data/dump files, with GROMACS-compatible commands"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "Proprietary"}
|
|
12
|
+
authors = [{name = "tgraphite"}]
|
|
13
|
+
keywords = [
|
|
14
|
+
"molecular dynamics",
|
|
15
|
+
"LAMMPS",
|
|
16
|
+
"GROMACS",
|
|
17
|
+
"trajectory analysis",
|
|
18
|
+
"RDF",
|
|
19
|
+
"hydrogen bonds",
|
|
20
|
+
"free volume",
|
|
21
|
+
"SASA",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 5 - Production/Stable",
|
|
25
|
+
"Environment :: Console",
|
|
26
|
+
"Intended Audience :: Science/Research",
|
|
27
|
+
"License :: Other/Proprietary License",
|
|
28
|
+
"Operating System :: OS Independent",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.9",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Topic :: Scientific/Engineering :: Chemistry",
|
|
35
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
36
|
+
]
|
|
37
|
+
dependencies = [
|
|
38
|
+
"numpy>=1.22",
|
|
39
|
+
"scipy>=1.8",
|
|
40
|
+
"pyyaml>=5.4",
|
|
41
|
+
"matplotlib>=3.5",
|
|
42
|
+
"MDAnalysis>=2.4",
|
|
43
|
+
"ase>=3.22",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Homepage = "https://github.com/tgraphite/LammpsAnalysisTools"
|
|
48
|
+
Documentation = "https://github.com/tgraphite/LammpsAnalysisTools/tree/main/docs/manual"
|
|
49
|
+
Repository = "https://github.com/tgraphite/LammpsAnalysisTools"
|
|
50
|
+
Issues = "https://github.com/tgraphite/LammpsAnalysisTools/issues"
|
|
51
|
+
|
|
52
|
+
[project.scripts]
|
|
53
|
+
lat = "lat.cli:main"
|
|
54
|
+
|
|
55
|
+
[tool.setuptools]
|
|
56
|
+
include-package-data = true
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.packages.find]
|
|
59
|
+
where = ["src"]
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.package-data]
|
|
62
|
+
lat = ["data/*.yaml", "data/manual/*.md"]
|