GROMACS压控、盒体积与NPT实操
216个SPC/E水的实际GPU短MD:完整输入、终端操作、数据与图。
阅读本篇目录
下载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速度有输出精度限制,并不是读取同一完整检查点的位级重启。
本例比较什么#
在相同起点比较C-rescale、Parrinello–Rahman与Berendsen压控。使用各向同性压强1 bar、tau-p = 5 ps、compressibility = 4.5e-5 bar^-1。
npt-c-rescale#
cd npt-c-rescale
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 = v-rescale
tc-grps = System
tau-t = 0.1
ref-t = 300
pcoupl = C-rescale
gen-vel = no
constraints = none
nstenergy = 10
nstxout-compressed = 100
fourierspacing = 0.12
pcoupltype = isotropic
tau-p = 5.0
ref-p = 1.0
compressibility = 4.5e-05
npt-parrinello-rahman#
cd npt-parrinello-rahman
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 = v-rescale
tc-grps = System
tau-t = 0.1
ref-t = 300
pcoupl = Parrinello-Rahman
gen-vel = no
constraints = none
nstenergy = 10
nstxout-compressed = 100
fourierspacing = 0.12
pcoupltype = isotropic
tau-p = 5.0
ref-p = 1.0
compressibility = 4.5e-05
npt-berendsen#
cd npt-berendsen-demo
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 = v-rescale
tc-grps = System
tau-t = 0.1
ref-t = 300
pcoupl = Berendsen
gen-vel = no
constraints = none
nstenergy = 10
nstxout-compressed = 100
fourierspacing = 0.12
pcoupltype = isotropic
tau-p = 5.0
ref-p = 1.0
compressibility = 4.5e-05
实际结果#
| 条件 | 10–20 ps平均温度/K | 温度时间波动标准差/K | 平均压力/bar | 最终体积/nm³ |
|---|---|---|---|---|
| npt-c-rescale | 298.910 | 11.490 | -10.53 | 6.629727 |
| npt-parrinello-rahman | 299.754 | 10.939 | 6.79 | 6.617644 |
| npt-berendsen | 298.974 | 10.858 | 5.03 | 6.646922 |

20 ps只用于认识体积响应,不是水密度的收敛结果。Berendsen不产生严格正确的NPT系综,只作为旧方法演示;-demo目录因这项明确警告采用grompp -maxwarn 1,其余任务不使用该选项。不要根据短轨迹的瞬时压力判断压控是否有效。
表中的标准差是轨迹自身的时间波动,不是平均值误差条。
提取与画图#
返回下载包根目录:
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
这些例子用于学会修改输入、提交任务、检查输出和解读曲线。换成蛋白、界面或其他力场时,需要重新选择合理的截断、耦合时间与模拟长度。