# MD 轨迹分析脚本
`mdtool` 提供了多种工具, 安装脚本:
```bash
pip install mdtool --upgrade
```
### 密度分布
### 氢键
#### 单个水分子
#### 氢键分布
### 角度
#### 与表面法向量夹角分布
#### ion - O - ion 夹角分布
#### $\cos \phi \rho_{H_2 O}$ 分布
### RDF
### 位置归一化
`wrap`用于将轨迹文件中的原子位置进行归一化处理, 如将`[FILENAME]`中的原子位置归一化到晶胞中, 并输出为`wrapped.xyz`, 默认从`cp2k`的输出文件`input_inp`中读取`ABC`和`ALPHA_BETA_GAMMA`信息作为晶胞参数:
```bash
mdtool wrap [FILENAME]
```
或指定`cp2k`的输入文件:
```bash
mdtool wrap [FILENAME] --cp2k_input_file setting.inp
```
或指定晶胞参数:
```bash
mdtool wrap [FILENAME] --cell 10,10,10
```
默认的`[FILENAME]`为`*-pos-1.xyz`
## DFT 性质分析脚本
### PDOS
### 静电势
### 电荷差分
## 其他
### 轨迹提取
`extract`用于提取轨迹文件中的特定的帧, 如从`frames.xyz`中提取第 1000 帧到第 2000 帧的轨迹文件, 并输出为`1000-2000.xyz`, `-r`选项的参数与`Python`的切片语法一致:
```bash
mdtool extract frames.xyz -r 1000:2000 -o 1000-2000.xyz
```
或从`cp2k`的默认输出的轨迹文件`*-pos-1.xyz`文件中提取最后一帧输出为`extracted.xyz`(`extract`的默认行为):
```bash
mdtool extract
```
或每50帧输出一个结构到`./coord`目录中, 同时调整输出格式为`cp2k`的`@INCLUDE coord.xyz`的形式:
```bash
mdtool extract -cr ::50
```
### 结构文件转换
`convert`用于将结构文件从一种格式转换为另一种格式, 如将`structure.xyz`转换为`out.cif`(默认文件名为`out`), 对于不储存周期性边界条件的文件, 可以使用`--cell`选项指定`PBC`:
```bash
mdtool convert -c structure.xyz --cell 10,10,10
```
将`structure.cif`转换为`POSCAR`:
```bash
mdtool convert -v structure.cif
```
将`structure.cif`转换为`structure_xyz.xyz`:
```bash
mdtool convert -c structure.cif -o structure_xyz
```
### 数据处理
`data`用于对数据进行处理如:
1. `--nor`: 对数据进行归一化处理
2. `--gaus`: 对数据进行高斯过滤
3. `--fold`: 堆数据进行折叠平均
4. `--err`: 计算数据的误差棒
等
### 绘图工具
`plot`用于绘制数据图, `plot`需要读取`yaml`格式的配置文件进行绘图, `yaml`文件的形式如下:
```yaml
# plot mode 1
figure1:
data:
legend1: ./data1.dat
legend2: ./data2.dat
x:
0: x-axis
y:
1: y-axis
x_range:
- 5
- 15
# plot mode 2
figure2:
data:
y-xais: ./data.dat
x:
0: x-axis
y:
1: legend1
2: legend2
3: legend3
4: legend4
5: legend5
y_range:
- 0.5
- 6
legend_fontsize: 12
# plot mode error
12_dp_e_error:
data:
legend: ./error.dat
x:
0: x-axis
y:
1: y-axis
fold: dp
legend_fontsize: 12
```
如上`plot`支持三种绘图模式, `mode 1`, `mode 2`和`mode error`. `mode 1`用于绘制多组数据文件的同一列数据对比, `mode 2`用于绘制同一数据文件的不同列数据对比, `mode error`用于绘制均方根误差图.
`plot`可以同时处理多个`yaml`文件, 每个`yaml`文件可以包含多个绘图配置, `mode 1`和`mode 2`的绘图配置可以自动识别, 但是`error`模式需要而外指定, 如:
```bash
mdtool plot *.yaml
```
和:
```bash
mdtool plot *.yaml --error
```
Raw data
{
"_id": null,
"home_page": "https://github.com/jxxcr/mdtool",
"name": "mdtool",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "molecular dynamics, density functional theory",
"author": "jxxcr",
"author_email": "jixxcr@qq.com",
"download_url": "https://files.pythonhosted.org/packages/d6/d4/7acbae4f3fb8f748b2c533a1935ddd9fffd1948d68e968701332c8b0576a/mdtool-0.1.10.tar.gz",
"platform": null,
"description": "# MD \u8f68\u8ff9\u5206\u6790\u811a\u672c\n`mdtool` \u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177, \u5b89\u88c5\u811a\u672c:\n```bash\npip install mdtool --upgrade\n```\n### \u5bc6\u5ea6\u5206\u5e03\n\n### \u6c22\u952e\n\n#### \u5355\u4e2a\u6c34\u5206\u5b50\n\n#### \u6c22\u952e\u5206\u5e03\n\n### \u89d2\u5ea6\n\n#### \u4e0e\u8868\u9762\u6cd5\u5411\u91cf\u5939\u89d2\u5206\u5e03\n\n#### ion - O - ion \u5939\u89d2\u5206\u5e03\n\n#### $\\cos \\phi \\rho_{H_2 O}$ \u5206\u5e03\n\n### RDF\n\n### \u4f4d\u7f6e\u5f52\u4e00\u5316\n`wrap`\u7528\u4e8e\u5c06\u8f68\u8ff9\u6587\u4ef6\u4e2d\u7684\u539f\u5b50\u4f4d\u7f6e\u8fdb\u884c\u5f52\u4e00\u5316\u5904\u7406, \u5982\u5c06`[FILENAME]`\u4e2d\u7684\u539f\u5b50\u4f4d\u7f6e\u5f52\u4e00\u5316\u5230\u6676\u80de\u4e2d, \u5e76\u8f93\u51fa\u4e3a`wrapped.xyz`, \u9ed8\u8ba4\u4ece`cp2k`\u7684\u8f93\u51fa\u6587\u4ef6`input_inp`\u4e2d\u8bfb\u53d6`ABC`\u548c`ALPHA_BETA_GAMMA`\u4fe1\u606f\u4f5c\u4e3a\u6676\u80de\u53c2\u6570:\n```bash\nmdtool wrap [FILENAME] \n```\n\u6216\u6307\u5b9a`cp2k`\u7684\u8f93\u5165\u6587\u4ef6:\n```bash\nmdtool wrap [FILENAME] --cp2k_input_file setting.inp\n```\n\u6216\u6307\u5b9a\u6676\u80de\u53c2\u6570:\n```bash\nmdtool wrap [FILENAME] --cell 10,10,10\n```\n\u9ed8\u8ba4\u7684`[FILENAME]`\u4e3a`*-pos-1.xyz`\n\n## DFT \u6027\u8d28\u5206\u6790\u811a\u672c\n### PDOS\n\n### \u9759\u7535\u52bf\n\n### \u7535\u8377\u5dee\u5206\n\n## \u5176\u4ed6\n### \u8f68\u8ff9\u63d0\u53d6\n`extract`\u7528\u4e8e\u63d0\u53d6\u8f68\u8ff9\u6587\u4ef6\u4e2d\u7684\u7279\u5b9a\u7684\u5e27, \u5982\u4ece`frames.xyz`\u4e2d\u63d0\u53d6\u7b2c 1000 \u5e27\u5230\u7b2c 2000 \u5e27\u7684\u8f68\u8ff9\u6587\u4ef6, \u5e76\u8f93\u51fa\u4e3a`1000-2000.xyz`, `-r`\u9009\u9879\u7684\u53c2\u6570\u4e0e`Python`\u7684\u5207\u7247\u8bed\u6cd5\u4e00\u81f4:\n```bash\nmdtool extract frames.xyz -r 1000:2000 -o 1000-2000.xyz\n```\n\u6216\u4ece`cp2k`\u7684\u9ed8\u8ba4\u8f93\u51fa\u7684\u8f68\u8ff9\u6587\u4ef6`*-pos-1.xyz`\u6587\u4ef6\u4e2d\u63d0\u53d6\u6700\u540e\u4e00\u5e27\u8f93\u51fa\u4e3a`extracted.xyz`(`extract`\u7684\u9ed8\u8ba4\u884c\u4e3a):\n```bash\nmdtool extract\n```\n\u6216\u6bcf50\u5e27\u8f93\u51fa\u4e00\u4e2a\u7ed3\u6784\u5230`./coord`\u76ee\u5f55\u4e2d, \u540c\u65f6\u8c03\u6574\u8f93\u51fa\u683c\u5f0f\u4e3a`cp2k`\u7684`@INCLUDE coord.xyz`\u7684\u5f62\u5f0f:\n```bash\nmdtool extract -cr ::50\n```\n\n### \u7ed3\u6784\u6587\u4ef6\u8f6c\u6362\n`convert`\u7528\u4e8e\u5c06\u7ed3\u6784\u6587\u4ef6\u4ece\u4e00\u79cd\u683c\u5f0f\u8f6c\u6362\u4e3a\u53e6\u4e00\u79cd\u683c\u5f0f, \u5982\u5c06`structure.xyz`\u8f6c\u6362\u4e3a`out.cif`(\u9ed8\u8ba4\u6587\u4ef6\u540d\u4e3a`out`), \u5bf9\u4e8e\u4e0d\u50a8\u5b58\u5468\u671f\u6027\u8fb9\u754c\u6761\u4ef6\u7684\u6587\u4ef6, \u53ef\u4ee5\u4f7f\u7528`--cell`\u9009\u9879\u6307\u5b9a`PBC`:\n```bash\nmdtool convert -c structure.xyz --cell 10,10,10\n```\n\u5c06`structure.cif`\u8f6c\u6362\u4e3a`POSCAR`:\n```bash\nmdtool convert -v structure.cif\n```\n\u5c06`structure.cif`\u8f6c\u6362\u4e3a`structure_xyz.xyz`:\n```bash\nmdtool convert -c structure.cif -o structure_xyz\n```\n\n### \u6570\u636e\u5904\u7406\n`data`\u7528\u4e8e\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u5982:\n1. `--nor`: \u5bf9\u6570\u636e\u8fdb\u884c\u5f52\u4e00\u5316\u5904\u7406\n2. `--gaus`: \u5bf9\u6570\u636e\u8fdb\u884c\u9ad8\u65af\u8fc7\u6ee4\n3. `--fold`: \u5806\u6570\u636e\u8fdb\u884c\u6298\u53e0\u5e73\u5747\n4. `--err`: \u8ba1\u7b97\u6570\u636e\u7684\u8bef\u5dee\u68d2\n\u7b49\n\n### \u7ed8\u56fe\u5de5\u5177\n`plot`\u7528\u4e8e\u7ed8\u5236\u6570\u636e\u56fe, `plot`\u9700\u8981\u8bfb\u53d6`yaml`\u683c\u5f0f\u7684\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u7ed8\u56fe, `yaml`\u6587\u4ef6\u7684\u5f62\u5f0f\u5982\u4e0b:\n```yaml\n# plot mode 1\nfigure1:\n data:\n legend1: ./data1.dat\n legend2: ./data2.dat\n x:\n 0: x-axis\n y:\n 1: y-axis\n x_range: \n - 5\n - 15\n\n# plot mode 2\nfigure2:\n data:\n y-xais: ./data.dat\n x:\n 0: x-axis\n y:\n 1: legend1\n 2: legend2\n 3: legend3\n 4: legend4\n 5: legend5\n y_range:\n - 0.5\n - 6\n legend_fontsize: 12\n\n# plot mode error\n12_dp_e_error:\n data:\n legend: ./error.dat\n x:\n 0: x-axis\n y:\n 1: y-axis\n fold: dp\n legend_fontsize: 12\n```\n\u5982\u4e0a`plot`\u652f\u6301\u4e09\u79cd\u7ed8\u56fe\u6a21\u5f0f, `mode 1`, `mode 2`\u548c`mode error`. `mode 1`\u7528\u4e8e\u7ed8\u5236\u591a\u7ec4\u6570\u636e\u6587\u4ef6\u7684\u540c\u4e00\u5217\u6570\u636e\u5bf9\u6bd4, `mode 2`\u7528\u4e8e\u7ed8\u5236\u540c\u4e00\u6570\u636e\u6587\u4ef6\u7684\u4e0d\u540c\u5217\u6570\u636e\u5bf9\u6bd4, `mode error`\u7528\u4e8e\u7ed8\u5236\u5747\u65b9\u6839\u8bef\u5dee\u56fe.\n\n`plot`\u53ef\u4ee5\u540c\u65f6\u5904\u7406\u591a\u4e2a`yaml`\u6587\u4ef6, \u6bcf\u4e2a`yaml`\u6587\u4ef6\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u7ed8\u56fe\u914d\u7f6e, `mode 1`\u548c`mode 2`\u7684\u7ed8\u56fe\u914d\u7f6e\u53ef\u4ee5\u81ea\u52a8\u8bc6\u522b, \u4f46\u662f`error`\u6a21\u5f0f\u9700\u8981\u800c\u5916\u6307\u5b9a, \u5982:\n```bash\nmdtool plot *.yaml\n```\n\u548c:\n```bash\nmdtool plot *.yaml --error\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "tools for md or dft",
"version": "0.1.10",
"project_urls": {
"Homepage": "https://github.com/jxxcr/mdtool",
"Repository": "https://github.com/jxxcr/mdtool"
},
"split_keywords": [
"molecular dynamics",
" density functional theory"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8f8d01425b39b74f6655e4f6701ffd1e6f23e5cd289873b69e307327bbe5cbfb",
"md5": "3fb89e3275542d48a2ad2b05c788fc49",
"sha256": "7f9693203c995c25e6d621071d9f425aaafccca35ff74b0a8304f69ba88198b2"
},
"downloads": -1,
"filename": "mdtool-0.1.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3fb89e3275542d48a2ad2b05c788fc49",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 44221,
"upload_time": "2025-04-18T07:01:38",
"upload_time_iso_8601": "2025-04-18T07:01:38.069480Z",
"url": "https://files.pythonhosted.org/packages/8f/8d/01425b39b74f6655e4f6701ffd1e6f23e5cd289873b69e307327bbe5cbfb/mdtool-0.1.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d6d47acbae4f3fb8f748b2c533a1935ddd9fffd1948d68e968701332c8b0576a",
"md5": "1176469a7762eaaf8a67a436d39128a4",
"sha256": "340c66bfc7c553caa0b9985b1dcecd698cce6e41dbba9f07f226824093efcaa4"
},
"downloads": -1,
"filename": "mdtool-0.1.10.tar.gz",
"has_sig": false,
"md5_digest": "1176469a7762eaaf8a67a436d39128a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 29556,
"upload_time": "2025-04-18T07:01:39",
"upload_time_iso_8601": "2025-04-18T07:01:39.628003Z",
"url": "https://files.pythonhosted.org/packages/d6/d4/7acbae4f3fb8f748b2c533a1935ddd9fffd1948d68e968701332c8b0576a/mdtool-0.1.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-04-18 07:01:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jxxcr",
"github_project": "mdtool",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "mdtool"
}