Bohrium
robot
新建

空间站广场

论文
Notebooks
比赛
课程
Apps
我的主页
我的Notebooks
我的论文库
我的足迹

我的工作空间

任务
节点
文件
数据集
镜像
项目
数据库
公开
GROMACS水分子模拟
中文
中文
Letian
更新于 2024-09-12
推荐镜像 :gromacs:2022.6-cuda12.1
推荐机型 :c4_m30_1 * NVIDIA P100
赞 3
9
GROMACS 水分子模拟
1. 可视化模块安装
2. GROMACS教程:水
2.1 输入文件设置
2.1.1 拓扑文件
2.1.2 结构文件
2.1.3参数文件
2.2 模拟计算
2.2.1 能量最小化
2.2.2 预平衡1(NVT)
2.2.3 预平衡2(NPT)
2.2.4 成品模拟
2.3 分析
2.3.1 结果可视化
3. 总结

🏃🏻 快速开始
您可以直接在 Bohrium Notebook 上执行此文档。首先,请点击位于界面顶部的 开始连接 按钮,然后选择 GROMACS:2022.6-cuda12.1 镜像并选择 c4_m15_1 * NVIDIA T4 机器配置,稍等片刻即可开始运行。

📖 来源
本 Notebook 内容来自 https://jerkwin.github.io/2018/11/24/Barnett_GROMACS教程,由陈乐天 📨 修改搬运至 Bohrium Notebook。

代码
文本

GROMACS 水分子模拟

镜像中已经提前安装了GROMACS软件

安装的版本是GROMACS 2022.6

代码
文本

1. 可视化模块安装

安装分子动力学分析工具 MDAnalysis 以及notebook的可视化扩展工具 NGLview

代码
文本
[1]
! pip install --upgrade MDAnalysis
! pip install nglview && jupyter-nbextension enable nglview --py --sys-prefix
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting MDAnalysis
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/55/22/bbca0189de20e3db885fea4489b4566454402639d4c9d8897c4b7d221775/MDAnalysis-2.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 34.7 MB/s eta 0:00:0000:010:01
Collecting joblib>=0.12
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/91/29/df4b9b42f2be0b623cbd5e2140cafcaa2bef0759a00b7b70104dcfe2fb51/joblib-1.4.2-py3-none-any.whl (301 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 301.8/301.8 kB 51.2 MB/s eta 0:00:00
Requirement already satisfied: tqdm>=4.43.0 in /opt/mamba/lib/python3.10/site-packages (from MDAnalysis) (4.64.1)
Requirement already satisfied: packaging in /opt/mamba/lib/python3.10/site-packages (from MDAnalysis) (23.2)
Requirement already satisfied: numpy<2.0,>=1.22.3 in /opt/mamba/lib/python3.10/site-packages (from MDAnalysis) (1.26.2)
Collecting mda-xdrlib
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4f/4b/5fe3a00833a9f9775b3c237624a6212798167278ffe10fe0de04f58612d0/mda_xdrlib-0.2.0-py3-none-any.whl (14 kB)
Requirement already satisfied: scipy>=1.5.0 in /opt/mamba/lib/python3.10/site-packages (from MDAnalysis) (1.11.4)
Collecting fasteners
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/bf/fd60001b3abc5222d8eaa4a204cd8c0ae78e75adc688f33ce4bf25b7fafa/fasteners-0.19-py3-none-any.whl (18 kB)
Requirement already satisfied: matplotlib>=1.5.1 in /opt/mamba/lib/python3.10/site-packages (from MDAnalysis) (3.9.0)
Collecting threadpoolctl
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4b/2c/ffbf7a134b9ab11a67b0cf0726453cedd9c5043a4fe7a35d1cefa9a1bcfb/threadpoolctl-3.5.0-py3-none-any.whl (18 kB)
Collecting GridDataFormats>=0.4.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/89/ab/9cae972ca177f7c64017f4b76f3780c832da52737b95c3e39ed0701af7a7/GridDataFormats-1.0.2-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 36.4 MB/s eta 0:00:00a 0:00:01
Collecting mmtf-python>=1.0.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3c/f1/efea3da858043ed9c078f507ab744b6d00933c7bc8a75a24821937600178/mmtf_python-1.1.3-py2.py3-none-any.whl (25 kB)
Collecting mrcfile
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9f/c6/cdc67e91c1cac23dd788ebe487d09a61206018bc0a71d576a69603bc91c2/mrcfile-1.5.3-py2.py3-none-any.whl (44 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.8/44.8 kB 12.8 MB/s eta 0:00:00
Requirement already satisfied: fonttools>=4.22.0 in /opt/mamba/lib/python3.10/site-packages (from matplotlib>=1.5.1->MDAnalysis) (4.53.0)
Requirement already satisfied: python-dateutil>=2.7 in /opt/mamba/lib/python3.10/site-packages (from matplotlib>=1.5.1->MDAnalysis) (2.8.2)
Requirement already satisfied: cycler>=0.10 in /opt/mamba/lib/python3.10/site-packages (from matplotlib>=1.5.1->MDAnalysis) (0.12.1)
Requirement already satisfied: contourpy>=1.0.1 in /opt/mamba/lib/python3.10/site-packages (from matplotlib>=1.5.1->MDAnalysis) (1.2.1)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/mamba/lib/python3.10/site-packages (from matplotlib>=1.5.1->MDAnalysis) (3.1.2)
Requirement already satisfied: kiwisolver>=1.3.1 in /opt/mamba/lib/python3.10/site-packages (from matplotlib>=1.5.1->MDAnalysis) (1.4.5)
Requirement already satisfied: pillow>=8 in /opt/mamba/lib/python3.10/site-packages (from matplotlib>=1.5.1->MDAnalysis) (10.3.0)
Collecting msgpack>=1.0.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ff/75/09081792db60470bef19d9c2be89f024d366b1e1973c197bb59e6aabc647/msgpack-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (378 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 378.0/378.0 kB 55.7 MB/s eta 0:00:00
Requirement already satisfied: six>=1.5 in /opt/mamba/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib>=1.5.1->MDAnalysis) (1.16.0)
Installing collected packages: threadpoolctl, msgpack, mrcfile, mda-xdrlib, joblib, fasteners, mmtf-python, GridDataFormats, MDAnalysis
Successfully installed GridDataFormats-1.0.2 MDAnalysis-2.7.0 fasteners-0.19 joblib-1.4.2 mda-xdrlib-0.2.0 mmtf-python-1.1.3 mrcfile-1.5.3 msgpack-1.1.0 threadpoolctl-3.5.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting nglview
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/db/6e/f26f3350b49c1d813106a497e3e9089cc2b62e845f67d95bf82ed27d0539/nglview-3.1.2.tar.gz (5.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.5/5.5 MB 32.6 MB/s eta 0:00:00a 0:00:01
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting jupyterlab-widgets
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a9/93/858e87edc634d628e5d752ba944c2833133a28fa87bb093e6832ced36a3e/jupyterlab_widgets-3.0.13-py3-none-any.whl (214 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 214.4/214.4 kB 44.6 MB/s eta 0:00:00
Collecting ipywidgets>=8
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/22/2d/9c0b76f2f9cc0ebede1b9371b6f317243028ed60b90705863d493bae622e/ipywidgets-8.1.5-py3-none-any.whl (139 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 139.8/139.8 kB 36.3 MB/s eta 0:00:00
Collecting notebook>=7
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/46/77/53732fbf48196af9e51c2a61833471021c1d77d335d57b96ee3588c0c53d/notebook-7.2.2-py3-none-any.whl (5.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.0/5.0 MB 50.5 MB/s eta 0:00:0000:0100:01
Requirement already satisfied: numpy in /opt/mamba/lib/python3.10/site-packages (from nglview) (1.26.2)
Requirement already satisfied: ipython>=6.1.0 in /opt/mamba/lib/python3.10/site-packages (from ipywidgets>=8->nglview) (8.18.1)
Requirement already satisfied: traitlets>=4.3.1 in /opt/mamba/lib/python3.10/site-packages (from ipywidgets>=8->nglview) (5.14.0)
Collecting widgetsnbextension~=4.0.12
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/21/02/88b65cc394961a60c43c70517066b6b679738caf78506a5da7b88ffcb643/widgetsnbextension-4.0.13-py3-none-any.whl (2.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 MB 55.8 MB/s eta 0:00:0000:01
Requirement already satisfied: comm>=0.1.3 in /opt/mamba/lib/python3.10/site-packages (from ipywidgets>=8->nglview) (0.2.0)
Requirement already satisfied: notebook-shim<0.3,>=0.2 in /opt/mamba/lib/python3.10/site-packages (from notebook>=7->nglview) (0.2.3)
Collecting jupyterlab-server<3,>=2.27.1
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/54/09/2032e7d15c544a0e3cd831c51d77a8ca57f7555b2e1b2922142eddb02a84/jupyterlab_server-2.27.3-py3-none-any.whl (59 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.7/59.7 kB 18.2 MB/s eta 0:00:00
Requirement already satisfied: tornado>=6.2.0 in /opt/mamba/lib/python3.10/site-packages (from notebook>=7->nglview) (6.4)
Collecting jupyterlab<4.3,>=4.2.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fd/3f/24a0f0ce60959cfd9756a3291cd3a5581e51cbd6f7b4aa121f5bba5320e3/jupyterlab-4.2.5-py3-none-any.whl (11.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.6/11.6 MB 37.5 MB/s eta 0:00:0000:0100:01
Requirement already satisfied: jupyter-server<3,>=2.4.0 in /opt/mamba/lib/python3.10/site-packages (from notebook>=7->nglview) (2.12.1)
Requirement already satisfied: decorator in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (5.1.1)
Requirement already satisfied: pygments>=2.4.0 in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (2.17.2)
Requirement already satisfied: matplotlib-inline in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (0.1.6)
Requirement already satisfied: stack-data in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (0.6.3)
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (3.0.42)
Requirement already satisfied: pexpect>4.3 in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (4.9.0)
Requirement already satisfied: jedi>=0.16 in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (0.19.1)
Requirement already satisfied: exceptiongroup in /opt/mamba/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets>=8->nglview) (1.2.0)
Requirement already satisfied: pyzmq>=24 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (25.1.2)
Requirement already satisfied: jupyter-client>=7.4.4 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (8.6.0)
Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (5.5.0)
Requirement already satisfied: terminado>=0.8.3 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.18.0)
Requirement already satisfied: jinja2 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (3.1.2)
Requirement already satisfied: jupyter-server-terminals in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.5.0)
Requirement already satisfied: nbconvert>=6.4.4 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (7.12.0)
Requirement already satisfied: send2trash>=1.8.2 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (1.8.2)
Requirement already satisfied: overrides in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (7.4.0)
Requirement already satisfied: websocket-client in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (1.7.0)
Requirement already satisfied: jupyter-events>=0.9.0 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.9.0)
Requirement already satisfied: packaging in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (23.2)
Requirement already satisfied: prometheus-client in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.19.0)
Requirement already satisfied: anyio>=3.1.0 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (4.1.0)
Requirement already satisfied: nbformat>=5.3.0 in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (5.9.2)
Requirement already satisfied: argon2-cffi in /opt/mamba/lib/python3.10/site-packages (from jupyter-server<3,>=2.4.0->notebook>=7->nglview) (23.1.0)
Collecting httpx>=0.25.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/56/95/9377bcb415797e44274b51d46e3249eba641711cf3348050f76ee7b15ffc/httpx-0.27.2-py3-none-any.whl (76 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 76.4/76.4 kB 23.9 MB/s eta 0:00:00
Requirement already satisfied: jupyter-lsp>=2.0.0 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (2.2.1)
Requirement already satisfied: async-lru>=1.0.0 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (2.0.4)
Requirement already satisfied: setuptools>=40.1.0 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (65.5.0)
Requirement already satisfied: tomli>=1.2.2 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (2.0.1)
Requirement already satisfied: ipykernel>=6.5.0 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (6.27.1)
Requirement already satisfied: jsonschema>=4.18.0 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (4.20.0)
Requirement already satisfied: json5>=0.9.0 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (0.9.14)
Requirement already satisfied: requests>=2.31 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (2.31.0)
Requirement already satisfied: babel>=2.10 in /opt/mamba/lib/python3.10/site-packages (from jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (2.14.0)
Requirement already satisfied: sniffio>=1.1 in /opt/mamba/lib/python3.10/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (1.3.0)
Requirement already satisfied: idna>=2.8 in /opt/mamba/lib/python3.10/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (3.4)
Requirement already satisfied: typing-extensions>=4.0.0 in /opt/mamba/lib/python3.10/site-packages (from async-lru>=1.0.0->jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (4.9.0)
Requirement already satisfied: certifi in /opt/mamba/lib/python3.10/site-packages (from httpx>=0.25.0->jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (2022.9.24)
Collecting httpcore==1.*
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/78/d4/e5d7e4f2174f8a4d63c8897d79eb8fe2503f7ecc03282fee1fa2719c2704/httpcore-1.0.5-py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.9/77.9 kB 23.9 MB/s eta 0:00:00
Collecting h11<0.15,>=0.13
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 18.4 MB/s eta 0:00:00
Requirement already satisfied: nest-asyncio in /opt/mamba/lib/python3.10/site-packages (from ipykernel>=6.5.0->jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (1.5.8)
Requirement already satisfied: psutil in /opt/mamba/lib/python3.10/site-packages (from ipykernel>=6.5.0->jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (5.9.6)
Requirement already satisfied: debugpy>=1.6.5 in /opt/mamba/lib/python3.10/site-packages (from ipykernel>=6.5.0->jupyterlab<4.3,>=4.2.0->notebook>=7->nglview) (1.8.0)
Requirement already satisfied: parso<0.9.0,>=0.8.3 in /opt/mamba/lib/python3.10/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets>=8->nglview) (0.8.3)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/mamba/lib/python3.10/site-packages (from jinja2->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (2.1.3)
Requirement already satisfied: rpds-py>=0.7.1 in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (0.13.2)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (2023.11.2)
Requirement already satisfied: referencing>=0.28.4 in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (0.32.0)
Requirement already satisfied: attrs>=22.2.0 in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (23.1.0)
Requirement already satisfied: python-dateutil>=2.8.2 in /opt/mamba/lib/python3.10/site-packages (from jupyter-client>=7.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (2.8.2)
Requirement already satisfied: platformdirs>=2.5 in /opt/mamba/lib/python3.10/site-packages (from jupyter-core!=5.0.*,>=4.12->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (4.1.0)
Requirement already satisfied: rfc3339-validator in /opt/mamba/lib/python3.10/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.1.4)
Requirement already satisfied: python-json-logger>=2.0.4 in /opt/mamba/lib/python3.10/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (2.0.7)
Requirement already satisfied: pyyaml>=5.3 in /opt/mamba/lib/python3.10/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (6.0.1)
Requirement already satisfied: rfc3986-validator>=0.1.1 in /opt/mamba/lib/python3.10/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.1.1)
Requirement already satisfied: jupyterlab-pygments in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.3.0)
Requirement already satisfied: tinycss2 in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (1.2.1)
Requirement already satisfied: nbclient>=0.5.0 in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.9.0)
Requirement already satisfied: defusedxml in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.7.1)
Requirement already satisfied: mistune<4,>=2.0.3 in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (3.0.2)
Requirement already satisfied: beautifulsoup4 in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (4.12.2)
Requirement already satisfied: pandocfilters>=1.4.1 in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (1.5.0)
Requirement already satisfied: bleach!=5.0.0 in /opt/mamba/lib/python3.10/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (6.1.0)
Requirement already satisfied: fastjsonschema in /opt/mamba/lib/python3.10/site-packages (from nbformat>=5.3.0->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (2.19.0)
Requirement already satisfied: ptyprocess>=0.5 in /opt/mamba/lib/python3.10/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets>=8->nglview) (0.7.0)
Requirement already satisfied: wcwidth in /opt/mamba/lib/python3.10/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=6.1.0->ipywidgets>=8->nglview) (0.2.12)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/mamba/lib/python3.10/site-packages (from requests>=2.31->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (1.26.11)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/mamba/lib/python3.10/site-packages (from requests>=2.31->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (2.1.1)
Requirement already satisfied: argon2-cffi-bindings in /opt/mamba/lib/python3.10/site-packages (from argon2-cffi->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (21.2.0)
Requirement already satisfied: executing>=1.2.0 in /opt/mamba/lib/python3.10/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=8->nglview) (2.0.1)
Requirement already satisfied: asttokens>=2.1.0 in /opt/mamba/lib/python3.10/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=8->nglview) (2.4.1)
Requirement already satisfied: pure-eval in /opt/mamba/lib/python3.10/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=8->nglview) (0.2.2)
Requirement already satisfied: six>=1.12.0 in /opt/mamba/lib/python3.10/site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets>=8->nglview) (1.16.0)
Requirement already satisfied: webencodings in /opt/mamba/lib/python3.10/site-packages (from bleach!=5.0.0->nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (0.5.1)
Requirement already satisfied: fqdn in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (1.5.1)
Requirement already satisfied: jsonpointer>1.13 in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (2.4)
Requirement already satisfied: uri-template in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (1.3.0)
Requirement already satisfied: isoduration in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (20.11.0)
Requirement already satisfied: webcolors>=1.11 in /opt/mamba/lib/python3.10/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (1.13)
Requirement already satisfied: cffi>=1.0.1 in /opt/mamba/lib/python3.10/site-packages (from argon2-cffi-bindings->argon2-cffi->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (1.15.1)
Requirement already satisfied: soupsieve>1.2 in /opt/mamba/lib/python3.10/site-packages (from beautifulsoup4->nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (2.5)
Requirement already satisfied: pycparser in /opt/mamba/lib/python3.10/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->jupyter-server<3,>=2.4.0->notebook>=7->nglview) (2.21)
Requirement already satisfied: arrow>=0.15.0 in /opt/mamba/lib/python3.10/site-packages (from isoduration->jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (1.3.0)
Requirement already satisfied: types-python-dateutil>=2.8.10 in /opt/mamba/lib/python3.10/site-packages (from arrow>=0.15.0->isoduration->jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->notebook>=7->nglview) (2.8.19.14)
Building wheels for collected packages: nglview
  Building wheel for nglview (pyproject.toml) ... done
  Created wheel for nglview: filename=nglview-3.1.2-py3-none-any.whl size=7493364 sha256=c487de5e38e58699073f8f02c334b90cf5d838f68b65efa4defdc375f0db9716
  Stored in directory: /root/.cache/pip/wheels/1c/d6/5e/fad246784fb1e0d89794da5c9ab85dab034cb01e1250c12204
Successfully built nglview
Installing collected packages: widgetsnbextension, jupyterlab-widgets, h11, httpcore, httpx, ipywidgets, jupyterlab-server, jupyterlab, notebook, nglview
  Attempting uninstall: jupyterlab-server
    Found existing installation: jupyterlab_server 2.25.2
    Uninstalling jupyterlab_server-2.25.2:
      Successfully uninstalled jupyterlab_server-2.25.2
  Attempting uninstall: jupyterlab
    Found existing installation: jupyterlab 4.0.9
    Uninstalling jupyterlab-4.0.9:
      Successfully uninstalled jupyterlab-4.0.9
Successfully installed h11-0.14.0 httpcore-1.0.5 httpx-0.27.2 ipywidgets-8.1.5 jupyterlab-4.2.5 jupyterlab-server-2.27.3 jupyterlab-widgets-3.0.13 nglview-3.1.2 notebook-7.2.2 widgetsnbextension-4.0.13
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
/usr/bin/sh: 1: jupyter-nbextension: not found
代码
文本

2. GROMACS教程:水

在本入门教程中, 我将向您展示如何创建一个水盒子, 并在恒定的温度和压力下对其进行简单模拟. 模拟完成后我们就可以确定出水的密度.

2.1 输入文件设置

GROMACS模拟需要三个基本文件: 结构文件(.gro/.pdb), 拓扑文件(.top)参数文件(.mdp).

结构文件包含系统中每个原子的直角坐标. 拓扑文件包含每个原子如何与其他原子相互作用的信息, 这里所说的相互作用既包括非键相互作用也包括成键相互作用. 这些相互作用的信息由力场提供. 非键相互作用包括范德华相互作用和库仑相互作用. 成键相互作用包括键长, 键角和二面角. 参数文件包含模拟的运行时间, 时间步长, 温度和压力耦合等信息. 下面我们将获取/创建这些文件.

代码
文本

先从GitHub克隆一下本教程所需要的文件.

代码
文本
[2]
! git clone https://github.com/Letian88/Gromacs_Tutorials_data/
Cloning into 'Gromacs_Tutorials_data'...
remote: Enumerating objects: 51, done.
remote: Counting objects: 100% (51/51), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 51 (delta 20), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (51/51), 25.43 MiB | 3.66 MiB/s, done.
Resolving deltas: 100% (20/20), done.
代码
文本

2.1.1 拓扑文件

通常, 拓扑文件使用#include语句来引用要使用的力场. 其中包括atomtypes, bondtypes, angletypesdihedraltypes指令. 然后, 在拓扑文件中, 我们通常还会指定不同的moleculetype指令, 其中又包含了atoms, bondsdihedrals指令, 它们都来自于所引用的力场.

首先,我们需要创建一个名为topol.top的文件,本教程已经准备好top文件,其文本如下:

代码
文本
[3]
! cd /Gromacs_Tutorials_data/input/ && cat topol.top
#include "oplsaa.ff/forcefield.itp"
#include "oplsaa.ff/tip4pew.itp"

[ System ]
TIP4PEW 
[ Molecules ]
代码
文本

下面,我们对力场文件forcefield.itp 以及 tip4pew.itp文件进行展示。

代码
文本
[6]
! cat /usr/local/gromacs/share/gromacs/top/oplsaa.ff/forcefield.itp
#define _FF_OPLS
#define _FF_OPLSAA

; This force field uses a format that requires Gromacs 3.1.4 or later.
;
; References for the OPLS-AA force field: 
;
; W. L. Jorgensen, D. S. Maxwell, and J. Tirado-Rives,
; J. Am. Chem. Soc. 118, 11225-11236 (1996).
; W. L. Jorgensen and N. A. McDonald, Theochem 424, 145-155 (1998).
; W. L. Jorgensen and N. A. McDonald, J. Phys. Chem. B 102, 8049-8059 (1998).
; R. C. Rizzo and W. L. Jorgensen, J. Am. Chem. Soc. 121, 4827-4836 (1999).
; M. L. Price, D. Ostrovsky, and W. L. Jorgensen, J. Comp. Chem. (2001).
; E. K. Watkins and W. L. Jorgensen, J. Phys. Chem. A 105, 4118-4125 (2001).
; G. A. Kaminski, R.A. Friesner, J.Tirado-Rives and W.L. Jorgensen, J. Phys. Chem. B 105, 6474 (2001).
;

[ defaults ]
; nbfunc	comb-rule	gen-pairs	fudgeLJ	fudgeQQ
1		3		yes		0.5	0.5

#include "ffnonbonded.itp"
#include "ffbonded.itp"
代码
文本
[7]
! cat /usr/local/gromacs/share/gromacs/top/oplsaa.ff/tip4pew.itp
; Horn et al. (2004). J. Chem. Phys.120, 9665-9678
; http://dx.doi.org/10.1063/1.1683075

[ moleculetype ]
; molname	nrexcl
SOL		2

[ atoms ]
; id  at type     res nr  res name  at name  cg nr  charge    mass
  1   OW_tip4pew  1       SOL       OW       1       0        16.00000
  2   HW_tip4pew  1       SOL       HW1      1       0.52422   1.00800
  3   HW_tip4pew  1       SOL       HW2      1       0.52422   1.00800
  4   MW          1       SOL       MW       1      -1.04844   0.00000

#ifndef FLEXIBLE

[ settles ]
; i	funct	doh	dhh
1	1	0.09572	0.15139

#else
[ bonds ]
; i     j       funct   length  force.c.
1       2       1       0.09572 502416.0 0.09572        502416.0 
1       3       1       0.09572 502416.0 0.09572        502416.0 
        
[ angles ]
; i     j       k       funct   angle   force.c.
2       1       3       1       104.52  628.02  104.52  628.02  

#endif


[ virtual_sites3 ]
; Vsite from                    funct   a               b
4       1       2       3       1       0.106676721     0.106676721


[ exclusions ]
1	2	3	4
2	1	3	4
3	1	2	4
4	1	2	3


; The position of the virtual site is computed as follows:
;
;		O
;  	      
;	    	V
;	  
;	H		H
;
; Ewald tip4p:
; const = distance (OV) / [ cos (angle(VOH)) 	* distance (OH) ]
;	  0.0125 nm	/ [ cos (52.26 deg)	* 0.09572 nm	]
;	then a = b = 0.5 * const = 0.106676721
;
; Vsite pos x4 = x1 + a*(x2-x1) + b*(x3-x1)
代码
文本

如你所见, 我们已经引用了OPLS-AA力场. 此外, 我们还引用了TIP4PEW水模型. 紧接着是一个System指令, 其中只包含系统的名称, 可以是任意字符. 最后, 我们在Molecules下列出每种分子的类型及其数目.

2.1.2 结构文件

GROMACS在拓扑目录中提供了TIP4PEW水模型的结构文件。

拓扑目录的标准位置通常是 /usr/share/gromacs/top。 在该目录中, 您会看到几个.gro文件, 其中之一是tip4p.gro。

您还会看到上面的拓扑文件中引用的文件夹oplsaa.ff

TIP4PEW没有专用的结构文件, 因为TIP4P和TIP4PEW这两个四位点水模型的结构基本相同. 它们的不同之处在于力场参数.

要使用结构文件创建水盒子, 请执行以下操作:

代码
文本
[8]
! mkdir test && cp /Gromacs_Tutorials_data/input/topol.top ./test

# 将notebook路径切换到/test
import os
os.chdir("test")
代码
文本
[9]
! gmx solvate -cs tip4p -o conf.gro -box 2.3 2.3 2.3 -p topol.top
                     :-) GROMACS - gmx solvate, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx solvate -cs tip4p -o conf.gro -box 2.3 2.3 2.3 -p topol.top

Reading solvent configuration

Initialising inter-atomic distances...

WARNING: Masses and atomic (Van der Waals) radii will be guessed
         based on residue and atom names, since they could not be
         definitively assigned from the information in your input
         files. These guessed numbers might deviate from the mass
         and radius of the atom type. Please check the output
         files if necessary. Note, that this functionality may
         be removed in a future GROMACS version. Please, consider
         using another file format for your input.

NOTE: From version 5.0 gmx solvate uses the Van der Waals radii
from the source below. This means the results may be different
compared to previous GROMACS versions.

++++ PLEASE READ AND CITE THE FOLLOWING REFERENCE ++++
A. Bondi
van der Waals Volumes and Radii
J. Phys. Chem. 68 (1964) pp. 441-451
-------- -------- --- Thank You --- -------- --------

Generating solvent configuration
Will generate new solvent configuration of 2x2x2 boxes
Solvent box contains 2336 atoms in 584 residues
Removed 756 solvent atoms due to solvent-solvent overlap
Sorting configuration
Found 1 molecule type:
    SOL (   4 atoms):   395 residues
Generated solvent containing 1580 atoms in 395 residues
Writing generated configuration to conf.gro

Output configuration contains 1580 atoms in 395 residues
Volume                 :      12.167 (nm^3)
Density                :     971.195 (g/l)
Number of solvent molecules:    395   

Processing topology
Adding line for 395 solvent molecules with resname (SOL) to topology file (topol.top)

Back Off! I just backed up topol.top to ./#topol.top.1#

GROMACS reminds you: "If Java had true garbage collection, most programs would delete themselves upon execution." (Robert Sewell)

代码
文本

运行后你会得到一个conf.gro的结构文件.

如果你打开topol.top, 会看到文件最后添加了一行, 内容是SOL和一个数字(395).

代码
文本
[10]
! cat topol.top
#include "oplsaa.ff/forcefield.itp"
#include "oplsaa.ff/tip4pew.itp"

[ System ]
TIP4PEW in water
[ Molecules ]
SOL               395
代码
文本

SOL是在oplsaa.ff/tip4pew.itp 中定义的moleculetype的名称.

当我们运行上面的gmx solvate命令时, GROMACS会在边长为2.3 nm的盒子中添加足够的水分子.


代码
文本

2.1.3参数文件

现在我们需要一组参数文件, 这样GROMACS才能知道如何处理我们的起始结构.

模拟几乎总是包含三个主要阶段: 能量最小化, 预平衡成品模拟.

其中的能量最小化预平衡又可以分解为多个步骤.

每一步都需要单独的参数文件. 在本教程中, 我们将进行两次能量最小化, 两次预平衡和一次成品模拟.

这五个文件有一些相同的内容. 对每个选项, 我只给出了一个简短的注释. 有关每个选项的更多信息, 请参阅GROMACS网站

参数 说明
cutoff-scheme Verlet 创建邻近列表的方法. 当前GROMACS版本的默认设置, 在这里明确指定以避免GROMACS给出注意信息
coulombtype PME 对长程(k-space)静电使用Particle-Mesh Ewald方法
rcoulomb 1.0 PME计算中实空间(k空间)的截断距离, 单位nm
rvdw 1.0 VDW的截断距离, 单位nm
vdwtype Cut-off 范德华力在rvdw处截断
DispCorr EnerPress 对VDW能量和压力都进行长程校正
代码
文本

在设定截断距离时, 要考虑到力场是如何参数化的. 换句话说, 最好查看下相关力场的论文, 看它是如何创建的. 我们在这里选择1.0 nm作为截断距离, 对于OPLS来说已经足够了, 但您也可以为自己的系统选择其他值.

此外, 在每次模拟中, 我们还将输出能量文件, 日志文件压缩轨迹文件. 它们(在模拟步骤中)的输出频率分别使用nstenergy, nstlognstxout-compressed进行设置. 运行成品模拟时我们将输出更多信息.

除了第二次能量最小化之外, 对于每次模拟, 我们还将设置constraint-algorithm = lincsconstraints = h-bonds, 来使用LINCS算法约束所有涉及氢原子的键. 这样我们就可以使用更大的时间步长.

对于第一次能量最小化, 我们设置integrator = steep来使用最陡下降算法对体系能量进行最小化, 最大步数为1000步(nsteps = 1000). 如果在此之前能量收敛, 最小化将停止.

此外, 我们还使用了define = -DFLEXIBLE. 这样GROMACS会使用柔性水模型, 因为默认情况下所有的水模型都是使用SETTLE算法的刚性模型. 在我们引用的水模型的拓扑文件中, 有一个if语句, 用于查找要定义的FLEXIBLE变量. 第一次能量最小化的目的是调整分子的初始位置, 这样使用SETTLE约束算法时就不容易遇到错误了.

在第二次能量最小化的参数文件中, 我们只需要删除define = -DFLEXIBLE并将最大步数增加到50,000即可.

最后三次模拟-两次预平衡模拟和成品模拟-都设置integrator = md来使用蛙跳式积分方法. 此外, 设置dt=0.002来使用2 fs时间步长.

对于第一次预平衡, 有几点需要注意. 我增加了几个参数, 如下所示:

参数 说明
gen-vel yes 根据Maxwell-Boltzmann分布为每个原子产生速度, 这样体系的初始温度会接近于我们将要耦合的温度. 只需要为第一次预平衡步骤产生速度
gen-temp 298.15 gen-vel使用的温度, 单位K. 除非你需要做一些奇怪/有趣的事情, 否则设定值应该与ref-t相同
tcoupl Nose-Hoover 温度耦合算法. Nose-Hoover算法可以正确地生成正则系综
tc-grps System 要耦合的组. 你可以分别耦合不同的原子组, 但我们这里将整个系统耦合在一起
tau-t 2.0 耦合的时间常数. 详细信息请参阅手册
ref-t 298.15 以K为单位的温度
nhchainlength 1 蛙跳式算法只支持1, 但默认情况下为10. 这样设置是为了避免GROMACS显示警告信息
代码
文本

第一次预平衡的目的在于使得体系在加压耦合之前达到正确的温度(298.15 K)

因为如果同时添加温度和压力耦合可能会导致系统不稳定并发生崩溃. 我们不想在模拟一开始出现这种情况.

此外, 我们还设置了nSteps=50000, 使用2 fs的时间步长, 这意味着模拟将运行100 ps. 这对于本教程中的水盒子足够了, 但对于更大/更复杂系统, 你可能需要进行更长时间的预平衡.

第二次预平衡增加了压力耦合. 请注意, 我们并没有再次为原子产生速度, 因为那将使我们前面所做的预平衡失去意义. 我们还为约束设置了continuation = yes, 因为我们从第一次平衡开始继续进行模拟. 这次模拟将运行1 ns. 同样, 对于其他系统, 可能需要更长的模拟时间.

参数 说明
pcoupl Parrinello-Rahman 压力耦合算法. 当与Nose-Hoover一起使用时, Parrinello-Rahman能正确地产生等压等温系综
tau-p 2.0 耦合的时间常数. 详细信息请参阅手册
ref-p 1.0 耦合压力, 单位bar
compressibility 4.46e-5 系统压缩系数, 单位 bar-1

代码
文本

2.2 模拟计算

现在我们已经有了运行每次模拟所需的所有文件.

通常每次模拟运行时都需要先使用gmx grompp将已有的三个文件(.gro, .top.mdp)预处理为一个.tpr文件(有时也会被称为拓扑文件, 虽然这容易引起混淆).

代码
文本

2.2.1 能量最小化

首先, 我们先简单查看一下能量最小化的参数文件min.mdp,

代码
文本
[6]
! cd /Gromacs_Tutorials_data/mdp/ && cat min.mdp
define                   = -DFLEXIBLE
integrator               = steep
nsteps                   = 1000

nstenergy                = 500
nstlog                   = 500
nstxout-compressed       = 1000

constraint-algorithm     = lincs
constraints              = h-bonds

cutoff-scheme            = Verlet

coulombtype              = PME
rcoulomb                 = 1.0

vdwtype                  = Cut-off
rvdw                     = 1.0
DispCorr                 = EnerPres
代码
文本

参数文件部分已经对介绍了上述参数:

对于第一次能量最小化, 我们设置integrator = steep来使用最陡下降算法对体系能量进行最小化, 最大步数为1000步(nsteps = 1000).

我们使用了define = -DFLEXIBLE.即使用柔性水模型, 默认情况下所有的水模型都是使用SETTLE算法的刚性模型.

第一次能量最小化的目的是调整分子的初始位置, 使用SETTLE约束算法时就不容易报错.

在第二次能量最小化的参数文件中, 我们只需要删除define = -DFLEXIBLE并将最大步数增加到50,000即可.

执行以下操作来运行两次能量最小化步骤:

代码
文本
[11]
#第一次能量最小化
! gmx grompp -f /Gromacs_Tutorials_data/mdp/min.mdp -o min -pp min -po min
! gmx mdrun -deffnm min

#第二次能量最小化
! gmx grompp -f /Gromacs_Tutorials_data/mdp/min2.mdp -o min2 -pp min2 -po min2 -c min -t min
! gmx mdrun -deffnm min2
                      :-) GROMACS - gmx grompp, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx grompp -f /Gromacs_Tutorials_data/mdp/min.mdp -o min -pp min -po min

Setting the LD random seed to 469720830

Generated 330891 of the 330891 non-bonded parameter combinations
Generating 1-4 interactions: fudge = 0.5

Generated 330891 of the 330891 1-4 parameter combinations

Excluding 2 bonded neighbours molecule type 'SOL'

turning H bonds into constraints...

Cleaning up constraints and constant bonded interactions with virtual sites
Analysing residue names:
There are:   395      Water residues
Number of degrees of freedom in T-Coupling group rest is 2762.00

The largest distance between excluded atoms is 0.152 nm
Calculating fourier grid dimensions for X Y Z
Using a fourier grid of 20x20x20, spacing 0.115 0.115 0.115

Estimate for the relative computational load of the PME mesh part: 0.22

This run will generate roughly 0 Mb of data

GROMACS reminds you: "A computer without COBOL and FORTRAN is like a piece of chocolate cake without ketchup or mustard." (Unix fortune program)

                      :-) GROMACS - gmx mdrun, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx mdrun -deffnm min

Reading file min.tpr, VERSION 2022.6 (single precision)
1 GPU selected for this run.
Mapping of GPU IDs to the 1 GPU task in the 1 rank on this node:
  PP:0
PP tasks will do (non-perturbed) short-ranged interactions on the GPU
PP task will update and constrain coordinates on the CPU
Using 1 MPI thread
Using 4 OpenMP threads 


Steepest Descents:
   Tolerance (Fmax)   =  1.00000e+01
   Number of steps    =         1000

Step 8, time 0.008 (ps)  LINCS WARNING
relative constraint deviation after LINCS:
rms 0.001752, max 0.030709 (between atoms 1393 and 1395)
bonds that rotated more than 30 degrees:
 atom 1 atom 2  angle  previous, current, constraint length
   1393   1394   33.1    0.0932   0.0979      0.0957

Energy minimization reached the maximum number of steps before the forces
reached the requested precision Fmax < 10.

writing lowest energy coordinates.

Steepest Descents did not converge to Fmax < 10 in 1001 steps.
Potential Energy  = -2.1508424e+04
Maximum force     =  2.0791623e+02 on atom 359
Norm of force     =  1.7405263e+01

GROMACS reminds you: "I always think there is something foreign about jolly phrases at breakfast." (Mr. Carson in Downtown Abbey)

                      :-) GROMACS - gmx grompp, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx grompp -f /Gromacs_Tutorials_data/mdp/min2.mdp -o min2 -pp min2 -po min2 -c min -t min

Setting the LD random seed to -1108083866

Generated 330891 of the 330891 non-bonded parameter combinations
Generating 1-4 interactions: fudge = 0.5

Generated 330891 of the 330891 1-4 parameter combinations

Excluding 2 bonded neighbours molecule type 'SOL'

Cleaning up constraints and constant bonded interactions with virtual sites
Analysing residue names:
There are:   395      Water residues
Number of degrees of freedom in T-Coupling group rest is 2367.00

The largest distance between excluded atoms is 0.152 nm

Reading Coordinates and Box size from old trajectory

Will read whole trajectory
trr version: GMX_trn_file (single precision)
Last frame          0 time 1001.000   

Using frame at t = 1001 ps

Starting time for run is 0 ps
Calculating fourier grid dimensions for X Y Z
Using a fourier grid of 20x20x20, spacing 0.115 0.115 0.115

Estimate for the relative computational load of the PME mesh part: 0.22

This run will generate roughly 1 Mb of data

GROMACS reminds you: "I always think there is something foreign about jolly phrases at breakfast." (Mr. Carson in Downtown Abbey)

                      :-) GROMACS - gmx mdrun, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx mdrun -deffnm min2

Reading file min2.tpr, VERSION 2022.6 (single precision)
1 GPU selected for this run.
Mapping of GPU IDs to the 1 GPU task in the 1 rank on this node:
  PP:0
PP tasks will do (non-perturbed) short-ranged interactions on the GPU
PP task will update and constrain coordinates on the CPU
Using 1 MPI thread
Using 4 OpenMP threads 


Steepest Descents:
   Tolerance (Fmax)   =  1.00000e+01
   Number of steps    =        50000

writing lowest energy coordinates.

Steepest Descents converged to Fmax < 10 in 2163 steps
Potential Energy  = -2.1981994e+04
Maximum force     =  9.7465305e+00 on atom 1023
Norm of force     =  1.0342733e+00

GROMACS reminds you: "When using an abacus, a human can achieve about 0.1 flops/watt. Super-computers achieve about 2 gigaflops/watt." (John Linford)

代码
文本

这里对上述代码中使用的后缀进行解释:

对于每次操作, 我们都使用-f选项读取.mdp文件. 默认情况下, 如果未指定-c-p选项, GROMACS将使用conf.grotopol.top作为结构和拓扑文件. 另外, 我们使用-pp-po输出处理过的拓扑文件.top.mdp文件. 这并非必要, 但值得一看, 尤其是处理过的mdp文件, 因为里面带有注释.

在接下来的每个步骤中, 我们都使用-c-t选项读取前一步骤的最后一个结构文件或检查点文件. 默认情况下, GROMACS会每15分钟输出一次检查点文件, 最后一步也会输出检查点文件. 如果不存在检查点文件, GROMACS会使用由-c定义的结构文件, 因此最好同时指定这两个文件.

每次运行gmx mdrun时, 我们指示GROMACS为每个输入文件和输出文件使用默认名称, 因为输出文件有多个.

注意进行第二次能量最小化时我们使用了-maxwarn 1选项. 使用这个选项时要小心, 确认这一步的含义以后再使用. 对本案例的情况, GROMACS给出的是关于L-BFGS效率的警告信息, 因此我们可以安全地忽略它.


为了解能量最小化的过程, 我们使用GROMACS命令gmx energy提取这两次模拟的势能.

执行以下操作并输入Potential或其对应的数字, 在输出的最后即可看到势能计算的结果.

代码
文本
[12]
! echo "Potential\n" | gmx energy -f min.edr -o min-energy.xvg
                      :-) GROMACS - gmx energy, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx energy -f min.edr -o min-energy.xvg

Opened min.edr as single precision energy file

Select the terms you want from the following list by
selecting either (part of) the name or the number or a combination.
End your selection with an empty line or a zero.
-------------------------------------------------------------------
  1  Angle            2  LJ-(SR)          3  Disper.-corr.    4  Coulomb-(SR)  
  5  Coul.-recip.     6  Potential        7  Pres.-DC         8  Pressure      
  9  Constr.-rmsd    10  Vir-XX          11  Vir-XY          12  Vir-XZ        
 13  Vir-YX          14  Vir-YY          15  Vir-YZ          16  Vir-ZX        
 17  Vir-ZY          18  Vir-ZZ          19  Pres-XX         20  Pres-XY       
 21  Pres-XZ         22  Pres-YX         23  Pres-YY         24  Pres-YZ       
 25  Pres-ZX         26  Pres-ZY         27  Pres-ZZ         28  #Surf*SurfTen 
 29  T-rest        

Last energy frame read 789 time  999.000          

Statistics over 1000 steps [ 0.0000 through 999.0000 ps ], 1 data sets
All statistics are over 790 points (frames)

Energy                      Average   Err.Est.       RMSD  Tot-Drift
-------------------------------------------------------------------------------
Potential                  -20773.9        450    1413.38    -2847.3  (kJ/mol)

GROMACS reminds you: "There is just one thing I can promise you about the outer-space program: your tax dollar will go farther." (Wernher von Braun)

代码
文本

现在对第二次能量最小化进行相同的操作:

代码
文本
[13]
! echo "Potential\n" | gmx energy -f min2.edr -o min2-energy.xvg
                      :-) GROMACS - gmx energy, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx energy -f min2.edr -o min2-energy.xvg

Opened min2.edr as single precision energy file

Select the terms you want from the following list by
selecting either (part of) the name or the number or a combination.
End your selection with an empty line or a zero.
-------------------------------------------------------------------
  1  LJ-(SR)          2  Disper.-corr.    3  Coulomb-(SR)     4  Coul.-recip.  
  5  Potential        6  Pres.-DC         7  Pressure         8  Vir-XX        
  9  Vir-XY          10  Vir-XZ          11  Vir-YX          12  Vir-YY        
 13  Vir-YZ          14  Vir-ZX          15  Vir-ZY          16  Vir-ZZ        
 17  Pres-XX         18  Pres-XY         19  Pres-XZ         20  Pres-YX       
 21  Pres-YY         22  Pres-YZ         23  Pres-ZX         24  Pres-ZY       
 25  Pres-ZZ         26  #Surf*SurfTen   27  T-rest        

Last energy frame read 1709 time 2162.000         

Statistics over 2163 steps [ 0.0000 through 2162.0000 ps ], 1 data sets
All statistics are over 1710 points (frames)

Energy                      Average   Err.Est.       RMSD  Tot-Drift
-------------------------------------------------------------------------------
Potential                  -21781.1         77    161.964   -530.788  (kJ/mol)

GROMACS reminds you: "Computer system analysis is like child-rearing; you can do grievous damage, but you cannot ensure success." (Tom DeMarcho)

代码
文本

运行如下代码,即可画出能量最小化过程.

代码
文本
[14]
## python plot .xvg files
import re
import numpy as np
import matplotlib.pyplot as plt

class xvgfile:
def __init__(self,filename):
filename.seek(0)
length=self.getlength(filename)
self.note=[]
self.setting=[]
#only consider x-y type datas
ix=[]
iy=[]
self.x=[]
self.y=[]
for i in range(length):
line=filename.readline()
if re.search('[\#]',line):
self.note.append(line)
elif re.search('[\@]',line):
self.setting.append(line)
else:
data=line.strip().split()
ix.append(float(data[0]))
iy.append(float(data[1]))
self.x=np.array(ix)
self.y=np.array(iy)
def getlabel(self,keyword):
for i in self.setting:
if keyword in i:
return i.split('"')[-2]
def getlength(self,filename):
filename.seek(0)
length=len(filename.readlines())
filename.seek(0)
return length
def plotxvg_line(filename,l_w=1):
with open(filename,'r') as f:
xvg=xvgfile(f)
fig,ax = plt.subplots()
title=xvg.getlabel('title')
plt.title(title,fontsize='14')
xlabel=xvg.getlabel('xaxis label')
plt.xlabel(xlabel,fontsize='14')
ylabel=xvg.getlabel('s0 legend') + xvg.getlabel('yaxis label')
plt.ylabel(ylabel,fontsize='10')
name=filename.strip().split('.')[0]
plt.plot(xvg.x,xvg.y,lw=l_w,label=name)
fig.set_size_inches(6, 3)
plt.legend()
plt.savefig("%s.png" %name)
xlimlist=ax.get_xlim()
ylimlist=ax.get_ylim()
np.savetxt('%s.txt' %name,np.vstack((xvg.x,xvg.y)).T)
plt.show()
min1 = xvgfile.plotxvg_line('min-energy.xvg')
min2 = xvgfile.plotxvg_line('min2-energy.xvg')
代码
文本

2.2.2 预平衡1(NVT)

我们已经调整好了初始结构, 接下来就可以添加温度耦合进行第一次预平衡.

在运行之前还是展示一下输入参数文件eql.mdp

代码
文本
[15]
! cd /Gromacs_Tutorials_data/mdp/ && cat eql.mdp
integrator               = md        
dt                       = 0.002     ; 2 fs
nsteps                   = 50000     ; 100 ps

nstenergy                = 200
nstlog                   = 2000
nstxout-compressed       = 10000

gen-vel                  = yes
gen-temp                 = 298.15

constraint-algorithm     = lincs
constraints              = h-bonds

cutoff-scheme            = Verlet

coulombtype              = PME
rcoulomb                 = 1.0

vdwtype                  = Cut-off
rvdw                     = 1.0
DispCorr                 = EnerPres

tcoupl                   = Nose-Hoover
tc-grps                  = System
tau-t                    = 2.0
ref-t                    = 298.15
nhchainlength            = 1
代码
文本

第一次预平衡使得体系在加压耦合之前达到正确的温度(298.15 K).

同时添加温度和压力耦合可能会导致系统不稳定并发生崩溃.

设置了nSteps=50000, 使用2 fs的时间步长, 这意味着模拟将运行100 ps.

执行以下操作来运行第一次预平衡:

代码
文本
[16]
! gmx grompp -f /Gromacs_Tutorials_data/mdp/eql.mdp -o eql -pp eql -po eql -c min2 -t min2
! gmx mdrun -deffnm eql
                      :-) GROMACS - gmx grompp, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx grompp -f /Gromacs_Tutorials_data/mdp/eql.mdp -o eql -pp eql -po eql -c min2 -t min2

Setting the LD random seed to -169947459

Generated 330891 of the 330891 non-bonded parameter combinations
Generating 1-4 interactions: fudge = 0.5

Generated 330891 of the 330891 1-4 parameter combinations

Excluding 2 bonded neighbours molecule type 'SOL'

turning H bonds into constraints...

Setting gen_seed to -1066023

Velocities were taken from a Maxwell distribution at 298.15 K

Cleaning up constraints and constant bonded interactions with virtual sites
Analysing residue names:
There are:   395      Water residues
Number of degrees of freedom in T-Coupling group System is 2367.00

The largest distance between excluded atoms is 0.152 nm

Determining Verlet buffer for a tolerance of 0.005 kJ/mol/ps at 298.15 K

Calculated rlist for 1x1 atom pair-list as 1.038 nm, buffer size 0.038 nm

Set rlist, assuming 4x4 atom pair-list, to 1.001 nm, buffer size 0.001 nm

Note that mdrun will redetermine rlist based on the actual pair-list setup

Reading Coordinates and Box size from old trajectory

Will read whole trajectory

Velocities generated: ignoring velocities in input trajectory
trr version: GMX_trn_file (single precision)
Last frame          0 time 2163.000   

Using frame at t = 2163 ps

Starting time for run is 0 ps
Calculating fourier grid dimensions for X Y Z
Using a fourier grid of 20x20x20, spacing 0.115 0.115 0.115

Estimate for the relative computational load of the PME mesh part: 0.24

This run will generate roughly 1 Mb of data

GROMACS reminds you: "All Beauty Must Die" (Nick Cave)

                      :-) GROMACS - gmx mdrun, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx mdrun -deffnm eql

Reading file eql.tpr, VERSION 2022.6 (single precision)
Changing nstlist from 10 to 80, rlist from 1.001 to 1.145

1 GPU selected for this run.
Mapping of GPU IDs to the 2 GPU tasks in the 1 rank on this node:
  PP:0,PME:0
PP tasks will do (non-perturbed) short-ranged interactions on the GPU
PP task will update and constrain coordinates on the CPU
PME tasks will do all aspects on the GPU
Using 1 MPI thread
Using 2 OpenMP threads 

starting mdrun 'TIP4PEW in water'
50000 steps,    100.0 ps.

Writing final coordinates.

               Core t (s)   Wall t (s)        (%)
       Time:       13.087        6.544      200.0
                 (ns/day)    (hour/ns)
Performance:     1320.373        0.018

GROMACS reminds you: "There is just one thing I can promise you about the outer-space program: your tax dollar will go farther." (Wernher von Braun)

代码
文本

我们来看一下第一次预平衡过程中温度变化情况.

使用gmx energy检查温度, 在提示符下选择与Temperature或其相对应的数字.

在输出的最后即可看到温度计算的结果.

代码
文本
[17]
! echo -e "Temperature\n" | gmx energy -f eql.edr -o eql-temp.xvg
                      :-) GROMACS - gmx energy, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx energy -f eql.edr -o eql-temp.xvg

Opened eql.edr as single precision energy file

Select the terms you want from the following list by
selecting either (part of) the name or the number or a combination.
End your selection with an empty line or a zero.
-------------------------------------------------------------------
  1  LJ-(SR)          2  Disper.-corr.    3  Coulomb-(SR)     4  Coul.-recip.  
  5  Potential        6  Kinetic-En.      7  Total-Energy     8  Conserved-En. 
  9  Temperature     10  Pres.-DC        11  Pressure        12  Vir-XX        
 13  Vir-XY          14  Vir-XZ          15  Vir-YX          16  Vir-YY        
 17  Vir-YZ          18  Vir-ZX          19  Vir-ZY          20  Vir-ZZ        
 21  Pres-XX         22  Pres-XY         23  Pres-XZ         24  Pres-YX       
 25  Pres-YY         26  Pres-YZ         27  Pres-ZX         28  Pres-ZY       
 29  Pres-ZZ         30  #Surf*SurfTen   31  T-System      

String '-e Temperature' does not match anything
Last energy frame read 250 time  100.000          

Statistics over 50001 steps [ 0.0000 through 100.0000 ps ], 1 data sets
All statistics are over 501 points

Energy                      Average   Err.Est.       RMSD  Tot-Drift
-------------------------------------------------------------------------------
Temperature                 298.641       0.14    22.9508 -0.0768965  (K)

GROMACS reminds you: "God is a DJ" (Faithless)

代码
文本

温度随时间变化的数据会保存到 eql-temp.xvg 文件中,我们还是使用python画出变化曲线。

代码
文本
[18]
eql1 = xvgfile.plotxvg_line('eql-temp.xvg')
代码
文本

我们发现, 最初温度波动很大, 后面则趋于稳定.

代码
文本

2.2.3 预平衡2(NPT)

第二次预平衡, 我们增加压力耦合.

输入文件eql2.mdp如下:

代码
文本
[19]
! cd /Gromacs_Tutorials_data/mdp/ && cat eql2.mdp
integrator               = md        
dt                       = 0.002     ; 2 fs
nsteps                   = 500000    ; 1.0 ns

nstenergy                = 200
nstlog                   = 2000
nstxout-compressed       = 10000

continuation             = yes
constraint-algorithm     = lincs
constraints              = h-bonds

cutoff-scheme            = Verlet

coulombtype              = PME
rcoulomb                 = 1.0

vdwtype                  = Cut-off
rvdw                     = 1.0
DispCorr                 = EnerPres

tcoupl                   = Nose-Hoover
tc-grps                  = System
tau-t                    = 2.0
ref-t                    = 298.15
nhchainlength            = 1

pcoupl                   = Parrinello-Rahman 
tau_p                    = 4.0
compressibility          = 4.46e-5
ref_p                    = 1.0 
代码
文本

第二次预平衡增加了压力耦合. 没有再次产生原子速度, 防止第一次预平衡失去意义. 我们还设置了约束continuation = yes, 因为我们从第一次平衡开始继续进行模拟.

这次模拟将运行1 ns. 运行如下代码开始模拟.

代码
文本
[20]
! gmx grompp -f /Gromacs_Tutorials_data/mdp/eql2.mdp -o eql2 -pp eql2 -po eql2 -c eql -t eql
! gmx mdrun -deffnm eql2
                      :-) GROMACS - gmx grompp, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx grompp -f /Gromacs_Tutorials_data/mdp/eql2.mdp -o eql2 -pp eql2 -po eql2 -c eql -t eql

Setting the LD random seed to 1543462903

Generated 330891 of the 330891 non-bonded parameter combinations
Generating 1-4 interactions: fudge = 0.5

Generated 330891 of the 330891 1-4 parameter combinations

Excluding 2 bonded neighbours molecule type 'SOL'

turning H bonds into constraints...

Cleaning up constraints and constant bonded interactions with virtual sites
Analysing residue names:
There are:   395      Water residues
Number of degrees of freedom in T-Coupling group System is 2367.00

The largest distance between excluded atoms is 0.152 nm

Determining Verlet buffer for a tolerance of 0.005 kJ/mol/ps at 298.15 K

Calculated rlist for 1x1 atom pair-list as 1.038 nm, buffer size 0.038 nm

Set rlist, assuming 4x4 atom pair-list, to 1.001 nm, buffer size 0.001 nm

Note that mdrun will redetermine rlist based on the actual pair-list setup

Reading Coordinates, Velocities and Box size from old trajectory

Will read whole trajectory
Last frame         -1 time  100.000   

Using frame at t = 100 ps

Starting time for run is 0 ps
Calculating fourier grid dimensions for X Y Z
Using a fourier grid of 20x20x20, spacing 0.115 0.115 0.115

Estimate for the relative computational load of the PME mesh part: 0.24

This run will generate roughly 4 Mb of data

GROMACS reminds you: "Der Ball ist rund, das Spiel dauert 90 minuten, alles andere ist Theorie" (Lola rennt)

                      :-) GROMACS - gmx mdrun, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx mdrun -deffnm eql2

Reading file eql2.tpr, VERSION 2022.6 (single precision)
Changing nstlist from 10 to 80, rlist from 1.001 to 1.145

1 GPU selected for this run.
Mapping of GPU IDs to the 2 GPU tasks in the 1 rank on this node:
  PP:0,PME:0
PP tasks will do (non-perturbed) short-ranged interactions on the GPU
PP task will update and constrain coordinates on the CPU
PME tasks will do all aspects on the GPU
Using 1 MPI thread
Using 2 OpenMP threads 

starting mdrun 'TIP4PEW in water'
500000 steps,   1000.0 ps.

Writing final coordinates.

               Core t (s)   Wall t (s)        (%)
       Time:      137.599       68.800      200.0
                 (ns/day)    (hour/ns)
Performance:     1255.821        0.019

GROMACS reminds you: "All sorts of things can happen when you're open to new ideas and playing around with things." (Stephanie Kwolek, inventor of Kevlar)

代码
文本

使用gmx energy检查压力, 在提示符下选择与Pressure或其相对应的数字.

在输出的最后即可看到压力计算的结果.

代码
文本
[22]
! echo -e "Pressure\n" | gmx energy -f eql2.edr -o eql2-pres.xvg
                      :-) GROMACS - gmx energy, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /
Command line:
  gmx energy -f eql2.edr -o eql2-pres.xvg

Opened eql2.edr as single precision energy file

Select the terms you want from the following list by
selecting either (part of) the name or the number or a combination.
End your selection with an empty line or a zero.
-------------------------------------------------------------------
  1  LJ-(SR)          2  Disper.-corr.    3  Coulomb-(SR)     4  Coul.-recip.  
  5  Potential        6  Kinetic-En.      7  Total-Energy     8  Conserved-En. 
  9  Temperature     10  Pres.-DC        11  Pressure        12  Box-X         
 13  Box-Y           14  Box-Z           15  Volume          16  Density       
 17  pV              18  Enthalpy        19  Vir-XX          20  Vir-XY        
 21  Vir-XZ          22  Vir-YX          23  Vir-YY          24  Vir-YZ        
 25  Vir-ZX          26  Vir-ZY          27  Vir-ZZ          28  Pres-XX       
 29  Pres-XY         30  Pres-XZ         31  Pres-YX         32  Pres-YY       
 33  Pres-YZ         34  Pres-ZX         35  Pres-ZY         36  Pres-ZZ       
 37  #Surf*SurfTen   38  Box-Vel-XX      39  Box-Vel-YY      40  Box-Vel-ZZ    
 41  T-System      

String '-e Pressure' does not match anything
Last energy frame read 2500 time 1000.000         

Statistics over 500001 steps [ 0.0000 through 1000.0000 ps ], 1 data sets
All statistics are over 5001 points

Energy                      Average   Err.Est.       RMSD  Tot-Drift
-------------------------------------------------------------------------------
Pressure                     2.3203        6.1    692.044   -30.5404  (bar)

GROMACS reminds you: "I used to be blond and stupid, but now I dyed it black" (Miss Li)

代码
文本

预平衡计算时间较长,可运行如下代码复制已经计算得到的结果文件画图

代码
文本
[ ]
#! cp /Gromacs_Tutorials_data/result/eql2-pres.xvg ./
代码
文本

画出第二次预平衡过程曲线

代码
文本
[23]
min2 = xvgfile.plotxvg_line('eql2-pres.xvg', l_w=0.3)
代码
文本

请注意, 压力波动很大, 这是正常的. 在本教程中, 完全平衡后压力的平均值应接近1 bar.

代码
文本

2.2.4 成品模拟

请注意, 成品模拟将花费大约 5 min, 若想直接查看模拟结果,

可跳过gmx部分的gromacs计算代码, 直接运行最后画图的python代码.

先看一下成品模拟的参数文件prd.mdp.

代码
文本
[21]
! cd ../Gromacs_Tutorials_data/mdp/ && cat prd.mdp
integrator               = md        
dt                       = 0.002     ; 2 fs
nsteps                   = 2500000   ; 5.0 ns

nstenergy                = 5000
nstlog                   = 5000
nstxout-compressed       = 2000

continuation             = yes
constraint-algorithm     = lincs
constraints              = h-bonds

cutoff-scheme            = Verlet

coulombtype              = PME
rcoulomb                 = 1.0

vdwtype                  = Cut-off
rvdw                     = 1.0
DispCorr                 = EnerPres

tcoupl                   = Nose-Hoover
tc-grps                  = System
tau-t                    = 2.0
ref-t                    = 298.15
nhchainlength            = 1

pcoupl                   = Parrinello-Rahman 
tau_p                    = 4.0
compressibility          = 4.46e-5
ref_p                    = 1.0 
代码
文本

成品模拟将会跑 步, 也就是5000 ps, 这将花费一定的时间。其他参数设置与第二次预平衡完全相同

若想运行成品模拟代码, 请依次运行如下代码:

代码
文本
[22]
#-------------- Time warning: 6 mins ---------------
! gmx grompp -f /Gromacs_Tutorials_data/mdp/prd.mdp -o prd -pp prd -po prd -c eql2 -t eql2
! gmx mdrun -deffnm prd
                      :-) GROMACS - gmx grompp, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /test
Command line:
  gmx grompp -f /Gromacs_Tutorials_data/mdp/prd.mdp -o prd -pp prd -po prd -c eql2 -t eql2

Setting the LD random seed to -17383442

Generated 330891 of the 330891 non-bonded parameter combinations
Generating 1-4 interactions: fudge = 0.5

Generated 330891 of the 330891 1-4 parameter combinations

Excluding 2 bonded neighbours molecule type 'SOL'

turning H bonds into constraints...

Cleaning up constraints and constant bonded interactions with virtual sites
Analysing residue names:
There are:   395      Water residues
Number of degrees of freedom in T-Coupling group System is 2367.00

The largest distance between excluded atoms is 0.153 nm

Determining Verlet buffer for a tolerance of 0.005 kJ/mol/ps at 298.15 K

Calculated rlist for 1x1 atom pair-list as 1.038 nm, buffer size 0.038 nm

Set rlist, assuming 4x4 atom pair-list, to 1.001 nm, buffer size 0.001 nm

Note that mdrun will redetermine rlist based on the actual pair-list setup

Reading Coordinates, Velocities and Box size from old trajectory

Will read whole trajectory
Last frame         -1 time 1000.000   

Using frame at t = 1000 ps

Starting time for run is 0 ps
Calculating fourier grid dimensions for X Y Z
Using a fourier grid of 20x20x20, spacing 0.114 0.114 0.114

Estimate for the relative computational load of the PME mesh part: 0.24

This run will generate roughly 12 Mb of data

GROMACS reminds you: "Move Over Hogey Bear" (Urban Dance Squad)

                      :-) GROMACS - gmx mdrun, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /test
Command line:
  gmx mdrun -deffnm prd

Reading file prd.tpr, VERSION 2022.6 (single precision)
Changing nstlist from 10 to 50, rlist from 1.001 to 1.119

1 GPU selected for this run.
Mapping of GPU IDs to the 2 GPU tasks in the 1 rank on this node:
  PP:0,PME:0
PP tasks will do (non-perturbed) short-ranged interactions on the GPU
PP task will update and constrain coordinates on the CPU
PME tasks will do all aspects on the GPU
Using 1 MPI thread
Using 2 OpenMP threads 

starting mdrun 'TIP4PEW in water'
2500000 steps,   5000.0 ps.

Writing final coordinates.

               Core t (s)   Wall t (s)        (%)
       Time:      703.117      351.559      200.0
                 (ns/day)    (hour/ns)
Performance:     1228.814        0.020

GROMACS reminds you: "The time for theory is over" (J. Hajdu)

代码
文本

2.3 分析

用gmx energy处理prd.edr, 依次输出TemperaturePressureDensity

在输出的最后即可看到计算的结果.

代码
文本
[23]
! echo -e "Temperature\nPressure\nDensity\n" | gmx energy -f prd.edr -o prd-anal.xvg
                      :-) GROMACS - gmx energy, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /test
Command line:
  gmx energy -f prd.edr -o prd-anal.xvg

Opened prd.edr as single precision energy file

Select the terms you want from the following list by
selecting either (part of) the name or the number or a combination.
End your selection with an empty line or a zero.
-------------------------------------------------------------------
  1  LJ-(SR)          2  Disper.-corr.    3  Coulomb-(SR)     4  Coul.-recip.  
  5  Potential        6  Kinetic-En.      7  Total-Energy     8  Conserved-En. 
  9  Temperature     10  Pres.-DC        11  Pressure        12  Box-X         
 13  Box-Y           14  Box-Z           15  Volume          16  Density       
 17  pV              18  Enthalpy        19  Vir-XX          20  Vir-XY        
 21  Vir-XZ          22  Vir-YX          23  Vir-YY          24  Vir-YZ        
 25  Vir-ZX          26  Vir-ZY          27  Vir-ZZ          28  Pres-XX       
 29  Pres-XY         30  Pres-XZ         31  Pres-YX         32  Pres-YY       
 33  Pres-YZ         34  Pres-ZX         35  Pres-ZY         36  Pres-ZZ       
 37  #Surf*SurfTen   38  Box-Vel-XX      39  Box-Vel-YY      40  Box-Vel-ZZ    
 41  T-System      

String '-e Temperature' does not match anything
Last energy frame read 500 time 5000.000          

Statistics over 2500001 steps [ 0.0000 through 5000.0000 ps ], 3 data sets
All statistics are over 25001 points

Energy                      Average   Err.Est.       RMSD  Tot-Drift
-------------------------------------------------------------------------------
Temperature                 298.146      0.046    8.93098  -0.145778  (K)
Pressure                    1.18697        2.1    688.783    15.0929  (bar)
Density                     995.312       0.12    13.0162 -0.0536551  (kg/m^3)

GROMACS reminds you: "I was detained, I was restrained" (The Smiths)

代码
文本

预测结果如下所示:(运行后可对比)

Energy Average Err.Est. RMSD Tot-Drift
Temperature 298.179 0.023 9.02027 0.0198405 (K)
Pressure 3.88774 2.5 696.005 6.82566 (bar)
Density 995.382 0.13 13.409 -0.17823 (kg/m^3)

Wolfram Alpha中标准条件下水的密度为997 kg /m3.

代码
文本

2.3.1 结果可视化

注意, 由于周期性边界条件, 可能会存在贯穿整个盒子的键, 这看起来有些奇怪, 但并不意味着模拟有问题.

你可以使用gmx trjconv完整化分子:

代码
文本
[24]
! echo "0\n" | gmx trjconv -f prd.xtc -s prd.tpr -pbc mol -o prd-mol.xtc
                     :-) GROMACS - gmx trjconv, 2022.6 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /test
Command line:
  gmx trjconv -f prd.xtc -s prd.tpr -pbc mol -o prd-mol.xtc

Note that major changes are planned in future for trjconv, to improve usability and utility.
Will write xtc: Compressed trajectory (portable xdr format): xtc
Reading file prd.tpr, VERSION 2022.6 (single precision)
Reading file prd.tpr, VERSION 2022.6 (single precision)
Select group for output
Group     0 (         System) has  1580 elements
Group     1 (          Water) has  1580 elements
Group     2 (            SOL) has  1580 elements
Select a group: Selected 0: 'System'
Reading frame       0 time    0.000   
Precision of prd.xtc is 0.001 (nm)
Using output precision of 0.001 (nm)
Reading frame    1200 time 4800.000    ->  frame   1199 time 4796.000      

Last written: frame   1250 time 5000.000


GROMACS reminds you: "I invented the term 'Object-Oriented', and I can tell you I did not have C++ in mind." (Alan Kay, author of Smalltalk)

代码
文本

若未运行成品模拟,请复制结果文件查看模拟结果,运行如下代码可在文件夹/Gromacs_Tutorials_data/result中复制结果文件prd.groprd-mol.xtc

若已运行成品模拟,请忽略复制文件操作.

代码
文本
[ ]
#! cp /Gromacs_Tutorials_data/result/prd.gro ./ && cp /Gromacs_Tutorials_data/result/prd-mol.xtc ./
代码
文本

运行如下代码,使用MDAnalysis和nglview对成品模拟结果进行可视化

代码
文本
[25]
import MDAnalysis as mda
import nglview as nv

u = mda.Universe('prd.gro',"prd-mol.xtc")
view = nv.show_mdanalysis(u)
view.add_representation('ball+stick')
view.center()
view
代码
文本

3. 总结

在本教程中, 我们使用gmx solvate生成了TIP4PEW水盒子. 并分五个不同的阶段对其进行了: 能量最小化1, 能量最小化2, 预平衡1, 预平衡2和成品模拟. 每次模拟都使用了单独的.mdp文件, 我们对这些文件进行了解释. 对每次模拟, 我们使用gmx energy来提取模拟过程中的有用信息. 成品模拟运行完成后, 我们得到了TIP4PEW水的密度.

代码
文本
中文
中文
已赞3
本文被以下合集收录
DeepMD
ytchen@szu.edu.cn
更新于 2024-09-04
10 篇14 人关注
推荐阅读
公开
Jupyter_Dock | 分子对接
化学信息学Jupyter_Dock分子对接
化学信息学Jupyter_Dock分子对接
liyq@dp.tech
发布于 2023-06-15
1 赞9 转存文件
公开
Jupyter_Dock | 对接结果分析
化学信息学Jupyter_Dock分子对接数据分析
化学信息学Jupyter_Dock分子对接数据分析
liyq@dp.tech
发布于 2023-06-15
3 转存文件