LAMMPS 专题

LAMMPS BOCS 压力匹配

用实际完成的 LAMMPS 输入展示参数、提交和结果文件,附各条件的操作记录。

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

下载输入、Slurm 作业与实际结果。本例使用 LAMMPS 30 Sep 2026 的 P100 构建。附件保存 1 个已完成条件,按输入保留相互作用与操作参数。

选择条件#

解压并进入 lammps-bocs-pressure-matching-operations。CASES 每行对应一个作业数组索引,inputs 保存条件输入,reference 保存实际输出。gpu 条件使用 GPU 构建,其中普通 CPU 样式按输入直接运行;kokkos 条件启用 Kokkos。

条件目录 主要样式 运行模式
producer-p100-CG-methanol-BOCS pair_style table, fix bocs, compute pressure, fix ave/time, dump custom gpu

输入与提交#

第一组的输入如下。单位、边界条件和参数以对应 in.lammps 为准。

units		real
dimension	3
boundary	p p p
atom_style      atomic

newton		on
timestep	1.0

read_data	methanol.data

velocity	all create 300.0 16802 dist gaussian

pair_style	table spline 15000

pair_coeff	1 1 lammps_nb_MET-MET.table nb_METMET 12.0

neigh_modify	delay 0 every 1 check yes one 10000
neighbor	12.0 bin

thermo 10
thermo_style	custom step temp pe etotal press vol

variable STEP equal step
variable TEMP equal temp
## volume from cubic angstroms to cubic nm
variable VOL equal vol/1000.0
## pressure from atm to bar
variable PRESS equal press*1.01325
variable PXX equal pxx*1.01325
variable PYY equal pyy*1.01325
variable PZZ equal pzz*1.01325
variable PXY equal pxy*1.01325
variable PXZ equal pxz*1.01325
variable PYZ equal pyz*1.01325
## energy from kcal/mol to kJ/mol
variable KE equal ke*4.184
variable PE equal pe*4.184
variable UVDW equal evdwl*4.184


#####     SPECIAL COMMANDS FOR FIX_BOCS     #####
#       ID group-ID style_name thermostat T_init T_end T_couple barostat P_start P_end  P_couple pmatch_basis avg_vol     N_sites N_coeffs coeff1      coeff2
fix 	1  all      bocs       temp       300.0  300.0 100.0    cgiso    0.986   0.986  1000.0   analytic     66476.015   968     2        245030.10   8962.20 

# Report the modified pressure
thermo_modify 	press 1_press



## Uncomment to save some data from simulation to files
#fix             print_temp all print 500 "${STEP} ${TEMP}" file temp.dat screen no
#fix             print_vol all print 500 "${STEP} ${VOL}" file vol.dat screen no
#fix             print_press all print 500 "${STEP} ${PRESS}" file press.dat screen no
#fix             print_ke all print 500 "${STEP} ${KE}" file kinetic_E.dat screen no
#fix             print_pe all print 500 "${STEP} ${PE}" file potential_E.dat screen no
#fix             print_ve all print 500 "${STEP} ${UVDW}" file vdw_E.dat screen no
#fix             print_press_tens all print 500 "${STEP} ${PXX} ${PYY} ${PZZ} ${PXY} ${PXZ} ${PYZ}" file press_tens.dat screen no
#fix		print_PV_eos all print 500 "${VOL} ${PRESS}" file pv_eos.dat screen no

## Prints a configuration to dump.txt every 500 steps
#dump		1 all custom 500 dump.txt id type x y z fx fy fz

# Write restart files to continue simulations
#restart 10000 state1.restart state2.restart

## Run for this many steps
compute Pordinary all pressure thermo_temp
variable Vhist equal vol
fix history all ave/time 10 1 10 c_thermo_temp c_1_press c_Pordinary v_Vhist file pressure-history.dat
dump coords all custom 100 trajectory.lammpstrj id type x y z vx vy vz
run_style       verlet
run 2000


write_data final.data nocoeff
write_restart final.restart

在附件根目录提交第一组或所选条件。

sbatch --array=0 run.slurm
# 按 CASES 的完整列表提交
sbatch run.slurm

脚本申请一个 MPI 任务、一个 CPU 核和一张 P100,根据 MODES 加载对应模块。实际调用保存在 cases.json,例如第一组的命令参数为:

lmp -k off -pk omp 1 -echo both -in in.lammps > native.out

查看输出#

结果写入 work-new/条件名。先查看日志中的实际热力学表与结束信息。

cd work-new/producer-p100-CG-methanol-BOCS
tail -n 35 native.out

本次第一组的原生日志片段如下。

   Step          Temp          PotEng         TotEng         Press          Volume    
Loop time of 5.63859 on 1 procs for 2000 steps with 968 atoms
Total wall time: 0:00:05

原始输入若包含 dump、数据表或其他导出命令,相应文件会保存在该条件目录。附件提供的参考数据文件为 final.data, pressure-history.dat。按自己的体系修改输入时,保留对应势函数文件、单位和原子样式设置。

再次运行前,将已有的同名 work-new 条件目录改名保存。

本次输出示例#

第一组原生热力学输出的开头如下,列名由该组输入的 thermo_style 设置。

   Step          Temp          PotEng         TotEng         Press          Volume    
         0   300            1061.5961      1926.3291      107.006        66250.679    
        10   299.50944      1062.9245      1926.2435      94.669178      66252.387    
        20   299.22725      1063.5132      1926.0188      82.081193      66257.229    
需要根据你的体系选择资源?联系讨论计算需求。实际可用软件与权限,以当前账户和运行环境为准。

查看配图

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

100%查看原图 ↗