LAMMPS多物理粒子数据字段
两粒子最小合法数据、属性设置、原生读写与结构示意,配套完整输入和实算结果。
阅读本篇目录
本组例子解决一个常见问题:选好 atom_style 后,Atoms 每列该填什么,电荷、密度、取向等属性怎样一起保存。每个模型只有两个粒子,先读入数据,设置速度,再写出、清空和读回。它们是可直接修改的数据文件模板;没有配置相互作用势,也没有计算材料性质。
资料包使用 LAMMPS 30Sep2026;基础类型调用 lammps/30Sep2026-p100-gpu,Kokkos 条目调用 lammps/30Sep2026-p100-kokkos。这两套模块分别加载相应的 MPI/CUDA 环境,后处理使用 ase/3.29.0 环境中的 NumPy/Matplotlib。先用模块切换环境,不要把两套 LAMMPS 的动态库路径混在一起。
先下载、提交,再查看输出#
下载完整的41例数据文件、输入脚本与参考结果。在个人工作目录执行:
mkdir atom-data
cd atom-data
curl -fL https://yuansuan.top/assets/downloads/full-function/lammps-atom-data-wave77-d41f95983061.zip -o examples.zip
unzip examples.zip
sbatch submit.slurm
submit.slurm 申请一个 P100、一个 CPU 核;脚本逐个运行,Kokkos 条目会初始化 GPU 后端,基础类型仅做原生数据读写。没有 GPU 力计算或性能测试。提交后先看作业输出,再提取数据:
module purge
module load ase/3.29.0
python analyze.py work
python export_xyz.py work
python plot_results.py work
head -8 work/analysis/atom-style-io.csv
依次得到 first.data、读回后的 second.data、两份坐标与速度 dump、属性 CSV、位置 XYZ 和四张原图。已完成算例位于 reference/,可以把上述三个命令的 work 换为 reference 查看配套结果。重新计算请重新解压到新目录。
所有类型共同的读写流程#
下面是 atomic 的完整输入。更换类型时,atom_style 与 input.data 的列格式必须同时匹配;带模板的类型还有额外的初始化步骤。
units lj
dimension 3
atom_style atomic
read_data input.data
velocity all set .1 .2 .3
write_data first.data nocoeff noinit
write_dump all custom first.dump id type x y z vx vy vz modify sort id format float %.16g
clear
units lj
dimension 3
atom_style atomic
read_data first.data
write_data second.data nocoeff noinit
write_dump all custom second.dump id type x y z vx vy vz modify sort id format float %.16g
print "IO_ROUNDTRIP_DONE"
nocoeff 不输出势参数,noinit 用于本例的数据读写,不初始化力模型。要做真实动力学,需要另行设置对应势函数、参数和积分器,并正常执行 run;不要把这里的零步读写当作已经完成的物性计算。velocity all set 是人为给定速度,不是按温度抽样。
write_data 在每个原子行末增加 nx ny nz 三个周期映像标志,本例均为0。读取自己生成的数据时保留它们即可。

图中蓝黄分别标识两个粒子,位置、尺寸、取向及标注均取自实际输出;是xy投影,z信息仍完整保存在data/CSV中。
本篇类型与列顺序#
| 类型 | 实际Atoms列(不含末尾可选映像标志) |
|---|---|
mdpd |
id type rho x y z |
rheo |
id type status rho x y z |
rheo/thermal |
id type status rho energy x y z |
dpd |
id type theta x y z |
edpd |
id type temperature cv x y z |
sph |
id type rho energy cv x y z |
tdpd |
id type x y z cc1 cc2 |
electron |
id type q espin eradius x y z |
spin |
id type x y z spx spy spz magnitude |
peri |
id type volume density x y z |
smd |
id type molecule volume mass kradius cradius x0 y0 z0 x y z |
mdpd:最小可修改数据#
rho 是粒子密度字段,不能用它代替类型质量。真实MDPD还需对应势和积分设置。
先看配套文件:
head -60 inputs/mdpd/input.data
cat inputs/mdpd/in.lammps
input.data 完整内容:
Yuansuan minimal mdpd data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # mdpd
1 1 1.2 2 2 2
2 1 .8 5 5 5
rheo:最小可修改数据#
保存状态与密度。本例状态取0,仅演示字段,不配置流变方程。
先看配套文件:
head -60 inputs/rheo/input.data
cat inputs/rheo/in.lammps
input.data 完整内容:
Yuansuan minimal rheo data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # rheo
1 1 0 1.2 2 2 2
2 1 0 .8 5 5 5
rheo/thermal:最小可修改数据#
在 rheo 数据中再保存内能;温度还需要根据实际模型和热容关系确定。
先看配套文件:
head -60 inputs/rheo-thermal/input.data
cat inputs/rheo-thermal/in.lammps
input.data 完整内容:
Yuansuan minimal rheo/thermal data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # rheo/thermal
1 1 0 1.2 2.5 2 2 2
2 1 0 .8 3.5 5 5 5
dpd:最小可修改数据#
theta 是粒子内部温度,不是整个体系速度换算得到的温度。
先看配套文件:
head -60 inputs/dpd/input.data
cat inputs/dpd/in.lammps
input.data 完整内容:
Yuansuan minimal dpd data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # dpd
1 1 1.5 2 2 2
2 1 2.5 5 5 5
edpd:最小可修改数据#
保存粒子温度与体积热容;两者都不能从坐标文件中自动推导。
先看配套文件:
head -60 inputs/edpd/input.data
cat inputs/edpd/in.lammps
input.data 完整内容:
Yuansuan minimal edpd data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # edpd
1 1 1.5 2 2 2 2
2 1 2.5 3 5 5 5
sph:最小可修改数据#
同时给密度、内能和热容;SPH流体方程及单位需与真实材料模型一起选择。
先看配套文件:
head -60 inputs/sph/input.data
cat inputs/sph/in.lammps
input.data 完整内容:
Yuansuan minimal sph data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # sph
1 1 1.2 2.5 3 2 2 2
2 1 .8 3.5 4 5 5 5
tdpd:最小可修改数据#
atom_style tdpd 2 声明两个化学组分,因此每行坐标后必须给 cc1、cc2 两个浓度。
先看配套文件:
head -60 inputs/tdpd/input.data
cat inputs/tdpd/in.lammps
input.data 完整内容:
Yuansuan minimal tdpd data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # tdpd
1 1 2 2 2 .2 .8
2 1 5 5 5 .7 .3
本例完整输入:
units lj
dimension 3
atom_style tdpd 2
read_data input.data
velocity all set .1 .2 .3
write_data first.data nocoeff noinit
write_dump all custom first.dump id type x y z vx vy vz modify sort id format float %.16g
clear
units lj
dimension 3
atom_style tdpd 2
read_data first.data
write_data second.data nocoeff noinit
write_dump all custom second.dump id type x y z vx vy vz modify sort id format float %.16g
print "IO_ROUNDTRIP_DONE"
electron:最小可修改数据#
q、整数自旋标记和电子半径位于坐标之前;这里 espin=0 为核、1为一个电子自旋方向。此处只验证数据格式,真实EFF计算要使用适当单位和EFF参数。
先看配套文件:
head -60 inputs/electron/input.data
cat inputs/electron/in.lammps
input.data 完整内容:
Yuansuan minimal electron data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # electron
1 1 1 0 1.2 2 2 2
2 1 -1 1 .8 5 5 5
spin:最小可修改数据#
坐标后先给单位方向矢量,再给自旋大小;本例方向分别沿x/y,大小1.2和2.3。
先看配套文件:
head -60 inputs/spin/input.data
cat inputs/spin/in.lammps
input.data 完整内容:
Yuansuan minimal spin data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # spin
1 1 2 2 2 1 0 0 1.2
2 1 5 5 5 0 1 0 2.3
peri:最小可修改数据#
volume 是粒子代表体积,后面的值是密度。源数据与读回文件保存相同体积/密度。
先看配套文件:
head -60 inputs/peri/input.data
cat inputs/peri/in.lammps
input.data 完整内容:
Yuansuan minimal peri data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Atoms # peri
1 1 .8 2 2 2 2
2 1 1.2 3 5 5 5
smd:最小可修改数据#
除当前位置还需原始位置x0/y0/z0、体积、质量和两种半径;原始位置不要误当成第二套可删除的坐标。
先看配套文件:
head -60 inputs/smd/input.data
cat inputs/smd/in.lammps
input.data 完整内容:
Yuansuan minimal smd data; reduced LJ units, IO example only
2 atoms
1 atom types
0 8 xlo xhi
0 8 ylo yhi
0 8 zlo zhi
Masses
1 2.0
Atoms # smd
1 1 1 .8 2 1 .5 2 2 2 2 2 2
2 1 1 1.2 3 1.2 .6 5 5 5 5 5 5
如何核对结果与继续使用#
实际两次写出覆盖全部原子属性、质量/形状/拓扑附加段、速度及坐标dump。41例逐项核对通过;数值差异只在有限尺寸几何的浮点舍入范围内,完整误差在CSV中。
head -12 work/analysis/atom-style-io.csv
head -5 work/analysis/xyz/charge-attributes.csv
head -5 work/analysis/xyz/charge.xyz
XYZ导出工具只输出位置,电荷、取向、密度等另存属性CSV;继续计算时保留原生data文件及附加段。只把XYZ读回不能恢复完整模型。图件为PNG原图,可点击放大。
本包统一使用约化 units lj 演示存储格式,数值是教学输入;套用真实体系时,把单位、质量、相互作用参数、边界、粒子属性及积分器作为一个整体检查。尤其电子、磁性、流变与连续介质模型不要直接套用这里的人为参数。
继续阅读:
字段解释参照官方atom_style说明、read_data说明和Body粒子说明,实际列顺序以本教程对应30Sep2026原生写出文件为准。