LAMMPS 壁面通道流实操
用384粒子的二维LJ通道,设置固定原子壁面、x方向外力和横向温控,提取速度剖面。
阅读本篇目录
本篇用一个小的二维 Lennard–Jones(LJ)粒子通道,跑通 建立壁面与移动粒子 → 预热 → 外力驱动 → 分层速度剖面 → 作图。真实输入、逐原子轨迹、曲线与分析脚本来自鸢算科技集群实际运行。下一篇说明剖面统计与近壁外推怎样读。
1. 下载、运行、看表格#
下载两篇共用的完整输入、实际输出与绘图包,上传到自己的目录:
python3 -m zipfile -e lammps-LJ-channel-wave548-2a16e3209bb0.zip LJ-channel
cd LJ-channel
bash run.sh
脚本建立 work,经普通账号 Slurm 提交 P100 和 V100 16G 两份分配。每份 1 张 GPU、2 个申请的 CPU 核心、1 个 MPI 进程、1 个 OpenMP 线程,八个案例在各自的一张 GPU 上顺序执行。完整对照需具备两个分区权限;不会直接 SSH 到 GPU 节点。TC 分区全部动态成员和 V100 32G 节点自动排除。
计算完成后生成 tables/*.csv 与 figures/*.png。作业号在 work/SUBMISSIONS.json;终端中断后先看作业号和 squeue,不要重复提交。已有完整计算时,run.sh 只更新分析,不重复提交;不完整目录会提示先检查原作业。需要重新计算时使用新解压目录。
head -n 4 tables/p100-wall0.25-force0.04-seed58001-thermo.csv
2. 体系是什么#
| 项目 | 设置 |
|---|---|
| 几何 | 二维 hex 初始排列,16×12 晶格周期,初始约化数密度 0.8 |
| 粒子 | 384 个,其中 288 个移动粒子、96 个固定壁面粒子 |
| 边界 | x 周期、y 非周期;所有粒子的 z、vz、fz 为零 |
| 壁面 | 上下各三排固定原子;移动粒子沿 x 受力 |
| 相互作用 | lj/cut 2.5,势能在截断处平移为零;所有 σ=1、质量=1 |
| LJ 深度 | 移动–移动和壁面–壁面 ε=1;壁面–移动 ε=0.25 或 1.0 |
| 外力 | 每个移动粒子沿 x 施加 0.02 或 0.04 |
| 时间步与时长 | dt=0.002,预热 5000 步=10τ,再加载 20000 步=40τ |
| 温控 | 只对 y 速度分量控温,目标 Ty=1,阻尼 1τ |
| 随机种子 | 58001、58002;另有独立 Langevin 随机流 |
| 输出 | 加载阶段每 500 步保存一次,共 41 帧 |
所有量均为 LJ 约化单位,没有映射到某种真实液体、纳米通道或实际秒数。这是二维粒子模型;初始有序排列也不等于已经确认平衡液相。

灰色方块为固定壁面,圆点按瞬时 vx 着色,色标范围 −2 到 2,超出部分按端色显示。图为 P100、外力 0.04、seed58001 的实际末帧。单帧热速度不等于平均流速,应继续看空间与时间平均。
3. 完整输入与关键设置#
cat work/p100-wall0.25-force0.04-seed58001/in.lmp
可运行输入如下,脚本只按案例替换壁面 ε、外力和种子:
units lj
dimension 2
atom_style atomic
boundary p f p
lattice hex 0.8
region box block 0 16 0 12 -0.5 0.5
create_box 2 box
create_atoms 1 box
mass * 1.0
region lower block INF INF INF 1.5 INF INF
region upper block INF INF 10.5 INF INF INF
region walls union 2 lower upper
group wall region walls
group fluid subtract all wall
set group wall type 2
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5
pair_coeff 2 2 1.0 1.0 2.5
pair_coeff 1 2 0.25 1.0 2.5
pair_modify shift yes
neighbor 0.3 bin
neigh_modify every 1 delay 0 check yes
velocity wall set 0 0 0
fix raw all store/force
fix hold wall setforce 0 0 0
min_style cg
minimize 0 0.002 2000 20000
velocity fluid create 1.0 58001 mom yes rot no dist gaussian
compute Ty fluid temp/partial 0 1 0
compute_modify Ty extra/dof 0
fix integrate fluid nve
fix bath fluid langevin 1.0 1.0 1.0 58101 zero yes
fix_modify bath temp Ty
fix planar all enforce2d
timestep 0.002
thermo 500
thermo_style custom step atoms c_Ty pe ke etotal
thermo_modify norm no format float %.16g
run 5000
unfix planar
reset_timestep 0
fix drive fluid addforce 0.04 0 0
fix planar all enforce2d
compute atomE all pe/atom
compute meanv fluid reduce ave vx
variable Nf equal count(fluid)
variable Nw equal count(wall)
compute bins fluid chunk/atom bin/1d y lower 1.0 units box
fix profile fluid ave/chunk 500 1 500 bins vx norm sample ave one file flow.profile format " %.16g"
thermo_style custom step atoms c_Ty pe ke etotal c_meanv v_Nf v_Nw lx ly lz
thermo_modify norm no format float %.16g
dump tr all custom 500 flow.dump id type x y z vx vy vz fx fy fz f_raw[1] f_raw[2] f_raw[3] c_atomE
dump_modify tr sort id format float %.16g
print BEGIN_CHANNEL_FLOW
run 20000
write_data final.data nocoeff
wall 是固定原子组,fluid 是移动原子组。壁面速度置零,受力用 setforce 0 0 0 清零,并且不对壁面施加积分器。只对 fluid 使用 fix nve 积分;由于同时存在 Langevin 温控和外力,整个过程不是微正则 NVE 能量守恒测试。
外力用 fix drive fluid addforce 0.04 0 0 添加,总驱动力为 288×0.04=11.52。fix raw all store/force 放在壁面清零、温控与外力之前,保存相互作用原始力;它帮助分清保守力、外加力和壁面约束,而不是把清零后的壁面力当作零反作用力。
4. 为什么不直接给总温度控温#
流向是 x。若直接把包含平均 vx 的总动能当热运动进行温控,可能把正在形成的流动也阻尼掉。本例使用:
compute Ty fluid temp/partial 0 1 0
compute_modify Ty extra/dof 0
fix bath fluid langevin 1.0 1.0 1.0 58101 zero yes
fix_modify bath temp Ty
0 1 0 只保留 y 分量;extra/dof 0 在本例中明确采用 Ty=Σvy²/Nfluid 的约化温度定义。它不是三分量总温度。Langevin 的温度偏置机制保留 x 流动分量,不对它施加同样的热阻尼;zero yes 去掉每一步随机力的整体偏置。

上排为移动粒子的平均 vx,下排为 Ty;虚线为目标 1。热涨落、初态与驱动力会影响短轨迹。本图不是温度或流量收敛证明。
bash analyze.sh work
这条命令重读已完成轨迹,不重新提交动力学。P100、seed58001 的最后 10 帧平均为:
| 壁面 ε | 外力 | 移动粒子平均 vx | Ty |
|---|---|---|---|
| 0.25 | 0.04 | 0.274424 | 0.986844 |
| 1.00 | 0.04 | 0.181042 | 0.964486 |
这是给定种子与短时间窗的实际数值,不能仅凭两行认定一种壁面一定具有更大的材料滑移长度。下一篇继续说明如何检查剖面与外推。
版本为 LAMMPS 30Sep2026,GCC 13.3、CUDA 12.8、OpenMPI 5.0.10、Kokkos 5.2.1;分析与绘图使用既有 ASE 3.29.0 环境中的 NumPy、Matplotlib。参考:Langevin 温控、排除速度分量的温度。