GROMACS专题

GROMACS时间步长与NVE能量检查

216个SPC/E水的实际GPU短MD:完整输入、终端操作、数据与图。

更新于 2026-10-27约 5 分钟阅读按任务与环境选择适用配置
阅读本篇目录

下载16组完整输入、原始日志、能量数据与绘图脚本。所有例子使用同一盒216个SPC/E水分子(648原子),在鸢算科技集群P100上实际运行20 ps。GROMACS 2026.4使用CUDA 12.8、thread-MPI构建;每个任务使用1张GPU、2个CPU线程。建模与最小化见Packmol接GROMACS水盒工作流。

运行步骤#

先解压下载包,进入gromacs-water子目录。下面各个算例互相独立,每次从下载包根目录进入对应目录;为每个需要运行的目录保存一份下方的run.sh。start.gro包含坐标和速度,topol.top引用安装包自带SPC/E参数。下面的脚本在所选算例目录保存为run.sh:

#!/bin/bash
#SBATCH --partition=gpu-8p100-hs
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=2
#SBATCH --gres=gpu:1
#SBATCH --time=00:20:00
set -eo pipefail
source /etc/profile
module purge
module load gromacs/2026.4-p100-threadmpi
export OMP_NUM_THREADS=2
gmx grompp -f md.mdp -c start.gro -p topol.top -o md.tpr
gmx mdrun -deffnm md -ntmpi 1 -ntomp 2 -nb gpu -pme gpu -bonded cpu -update cpu
if grep -Eq '^pcoupl[[:space:]]*=[[:space:]]*no([[:space:]]|$)' md.mdp; then
  printf 'Potential\nTotal-Energy\nTemperature\nPressure\n0\n' | gmx energy -f md.edr -o thermo.xvg
else
  printf 'Potential\nTotal-Energy\nTemperature\nPressure\nVolume\n0\n' | gmx energy -f md.edr -o thermo.xvg
fi
sbatch run.sh
# 任务结束后检查最后几行日志
 tail -n 20 md.log

constraints = none不代表这里的水是柔性水:SPC/E拓扑含SETTLE,水分子内部几何仍保持刚性。continuation = yes与gen-vel = no保留输入速度。本组从同一GRO起点分叉,GRO速度有输出精度限制,并不是读取同一完整检查点的位级重启。

本例比较什么#

把步长设为0.5、1、2 fs,并调整步数使总时长均为20 ps。关闭温控和压控后,观察总能量,而不是只看温度是否接近300 K。

nve-dt-0.0005#

cd nve-dt-0.0005
sbatch run.sh

完整 md.mdp:

integrator = md
dt = 0.0005
nsteps = 40000
continuation = yes
cutoff-scheme = Verlet
coulombtype = PME
rcoulomb = 0.8
rvdw = 0.8
pbc = xyz
tcoupl = no
tc-grps = System
tau-t = 0.1
ref-t = 300
pcoupl = no
gen-vel = no
constraints = none
nstenergy = 10
nstxout-compressed = 100
fourierspacing = 0.12

nve-dt-0.001#

cd nve-dt-0.001
sbatch run.sh

完整 md.mdp:

integrator = md
dt = 0.001
nsteps = 20000
continuation = yes
cutoff-scheme = Verlet
coulombtype = PME
rcoulomb = 0.8
rvdw = 0.8
pbc = xyz
tcoupl = no
tc-grps = System
tau-t = 0.1
ref-t = 300
pcoupl = no
gen-vel = no
constraints = none
nstenergy = 10
nstxout-compressed = 100
fourierspacing = 0.12

nve-dt-0.002#

cd nve-dt-0.002
sbatch run.sh

完整 md.mdp:

integrator = md
dt = 0.002
nsteps = 10000
continuation = yes
cutoff-scheme = Verlet
coulombtype = PME
rcoulomb = 0.8
rvdw = 0.8
pbc = xyz
tcoupl = no
tc-grps = System
tau-t = 0.1
ref-t = 300
pcoupl = no
gen-vel = no
constraints = none
nstenergy = 10
nstxout-compressed = 100
fourierspacing = 0.12

实际结果#

条件 10–20 ps平均温度/K 温度时间波动标准差/K 平均压力/bar 最终体积/nm³
nve-dt-0.0005 292.169 8.939 167.92 6.461670
nve-dt-0.001 291.261 9.372 109.61 6.461670
nve-dt-0.002 292.491 10.037 351.87 6.461670

实际计算曲线

本组总能量漂移并未随时间步长单调变化。起点的速度精度、leap-frog半步速度、自动Verlet缓冲和短轨迹都会影响比较,因此不能用这三条短轨迹认定2 fs比0.5 fs更准确。严格步长收敛还需控制邻居表误差、初态速度定义并增加独立重复。

表中的标准差是轨迹自身的时间波动,不是平均值误差条。

提取与画图#

返回下载包根目录:

module purge
module load gpumdkit/1.5.8
python analyze.py

得到analysis/RESULTS.json和六幅PNG曲线。脚本按XVG列名读取数据;定容任务的体积从GRO盒矢量取得。NPT若重新提取体积,使用:

printf 'Volume\n0\n' | gmx energy -f md.edr -o volume.xvg

这些例子用于学会修改输入、提交任务、检查输出和解读曲线。换成蛋白、界面或其他力场时,需要重新选择合理的截断、耦合时间与模拟长度。

需要根据你的体系选择资源?联系讨论计算需求。实际可用软件与权限,以当前账户和运行环境为准。

查看配图

放大后可滚动查看细节,按 Esc 关闭。

100%查看原图 ↗