fix命令为一组原子施加fix约束。
使用语法
fix ID group-ID style args
ID = fix命令的ID
group-ID = 该fix命令所作用的原子组的ID
style = fix类型名(最下有列表)
args = 特定类型fix命令所需要的参数
使用举例
fix 1 all nve fix 3 all nvt temp 300.0 300.0 0.01 fix mine top setforce 0.0 NULL 0.0
使用介绍
为一组原子施加fix约束。在LAMMPS中,fix是施加在分子动力学时间步或能量最小化过程中的某种操作。举例来说,它可能是在时间积分的过程中更新原子的位置和速度,或是控制温度,或是给原子施加约束力,或是强制某种边界条件,或计算过程诊断,等等。在LAMMSP中有一些列可以使用的fix命令,具体参考后面的列表。
fix命令会在时间步中的不同过程中执行相关的操作。如果有2个或多个fix命令作用于时间步中的同一过程,它们会按着在输入脚本中定义的顺序依次被激活。
fix命令的ID只能包含字母、数字和下划线。
fix命令所施加的约束可以被unfix命令删去。
注意:使用unfix命令是唯一用来关闭fix命令所施加的约束的方法。如果只是指定一种新的类似的fix命令并不会关闭之前的fix命令。这对于进行积分的fix命令特别重要。举例来说,如果你先定义了fix nvt命令,然后又定义了fix nve命令,这样做并不会将先定义的NVT时间积分取消掉,而是这两个时间积分同时进行。
如果你在定义一个新的fix命令时,所使用的ID和类型名与某个已经定义的fix命令完全相同,那么先前定义的那个fix命令就会被删除掉,而新的fix命令会被创建,所使用的参数也是重新定义的。这样做就好像是在定义这个新的fix命令之前,先使用unfix命令取消了旧fix命令,除了说它们所作用的顺序会因着定义的位置不同而有所差异。另外需要注意的是,这种重新定义fix命令也会将先前使用fix_modify命令定义的,与旧fix命令相关的其他任何改变都清除掉。
fix_modify命令可以用来重置fix命令定义的某些设置。具体细节可以参考特定类型的fix命令。
有些fix命令会在写二进制重启动文件(restart命令或write_restart命令)时保存其内部状态。这些fix命令会在重启动该模拟时继续对计算过程起作用。参考read_restart命令,了解在读入重启动文件的输入脚本中,如何重新指定fix命令。参考具体类型的fix命令,了解哪些命令会被写入到重启动文件中。
有些类型的fix命令会计算某种类型的量(全局量、单原子量或局部量),这些量可以被其他命令使用或输出。
- 全局量(global)是系统维度的量,比如体系的总能。
- 单原子量(per-atom)是每个原子都具有的量,比如每个原子的位移矢量。不在fix命令所约束的组内的原子的该单原子量被设为0。
- 局域量(local)是每个处理器基于它们所拥有的原子而计算出的量。原子可能有多个或没有局域量。
另外需要注意的是一个单独的fix命令只可能会产生这三种类型量的某一种。
全局量、单原子量和局域量都有三种存在形式:单独的标量、一维矢量和二维阵列。每种具体类型的fix命令的页面会介绍它会产生哪种类型的变量,以及它的存在形式,比如单原子一维矢量。有些类型的fix命令会产生多种存在形式的某种类型的量,比如全局标量和全局矢量。
如果要使用fix命令计算出的量,比如使用输出命令将它们输出,可以使用下面的方括号记号来引用它们。其中的ID是fix命令的ID。
f_ID | 整个标量、整个一维矢量、整个二维阵列 |
f_ID[I] | 一维矢量中的一个元素、二维阵列中的一列 |
f_ID[I][J] | 二维阵列中的一个元素 |
也就是说,使用使用一个方括号可以将量的维度降低一维,这样矢量就会变成标量,阵列就会变成矢量。使用两个方括号会将维度降低两次,也就是将阵列变为标量。通过这种方法,使用fix标量值作为输入的命令也可以同样处理矢量和阵列的元素。
注意:可以使用fix量的命令和变量并不是可以使用任何一种存在形式的量,比如一个命令可能会需要矢量类型的量,而不是标量类型的。这也就意味着在引用fix计算的量时不能含糊,而需要注意它的存在形式。这也会在具体介绍这些命令时详细的解释到。
在LAMMPS中,fix命令产生的值有下列的使用方法:
- 全局量可以使用命令thermo_style custom or fix ave/time 输出,也可以以equal类型或atom类型的变量进行引用。
- 单原子量可以使用 dump customor fix ave/spatial命令进行输出,也可以使用 fix ave/atom命令对时间进行平均,或使用compute reduce 命令进行降维,或使用atom-style类型的变量进行引用。
- 局域量可以使用compute reduce命令进行降维,或者使用fix ave/histo命令进行直方图化。
fix命令计算的全局量既可以是内部的,也可以是外部的。“内部”是说其值独立于模拟中的原子数,比如温度。“外部”是说其值的大小与模拟中的原子数有关系,比如总的转动动能。命令Thermodynamic output 会将外部量的值对体系中的原子数进行规范化,具体看”thermo_modify norm”的设置。但对于内部量,它不会进行规范化。如果使用其他方法对fix量进行引用,比如变量variable,你需要了解它是内部量还是外部量。
每一种类型的fix命令都有单独的文档页面来介绍其参数和它具体是做什么的。下面是lammps中可用的fix命令列表。(译注:fix命令会经常增加,所以这里列出的很可能并非全部。)
详情见官方文档:fix command — LAMMPS documentation
adapt - change a simulation parameter over time addforce - add a force to each atom append/atoms - append atoms to a running simulation aveforce - add an averaged force to each atom ave/atom - compute per-atom time-averaged quantities ave/histo - compute/output time-averaged histograms ave/spatial - compute/output time-averaged per-atom quantities by layer ave/time - compute/output global time-averaged quantities bond/break - break bonds on the fly bond/create - create bonds on the fly bond/swap - Monte Carlo bond swapping box/relax - relax box size during energy minimization deform - change the simulation box size/shape deposit - add new atoms above a surface drag - drag atoms towards a defined coordinate dt/reset - reset the timestep based on velocity, forces efield - impose electric field on system enforce2d - zero out z-dimension velocity and force evaporate - remove atoms from simulation periodically external - callback to an external driver program freeze - freeze atoms in a granular simulation gravity - add gravity to atoms in a granular simulation gcmc - grand canonical insertions/deletions heat - add/subtract momentum-conserving heat indent - impose force due to an indenter langevin - Langevin temperature control lineforce - constrain atoms to move in a line momentum - zero the linear and/or angular momentum of a group of atoms move - move atoms in a prescribed fashion msst - multi-scale shock technique (MSST) integration neb - nudged elastic band (NEB) spring forces nph - constant NPH time integration via Nose/Hoover nph/asphere - NPH for aspherical particles nph/sphere - NPH for spherical particles nphug - constant-stress Hugoniostat integration npt - constant NPT time integration via Nose/Hoover npt/asphere - NPT for aspherical particles npt/sphere - NPT for spherical particles nve - constant NVE time integration nve/asphere - NVE for aspherical particles nve/asphere/noforce - NVE for aspherical particles without forces" nve/body - NVE for body particles nve/limit - NVE with limited step length nve/line - NVE for line segments nve/noforce - NVE without forces (v only) nve/sphere - NVE for spherical particles nve/tri - NVE for triangles nvt - constant NVT time integration via Nose/Hoover nvt/asphere - NVT for aspherical particles nvt/sllod - NVT for NEMD with SLLOD equations nvt/sphere - NVT for spherical particles orient/fcc - add grain boundary migration force planeforce - constrain atoms to move in a plane poems - constrain clusters of atoms to move as coupled rigid bodies pour - pour new atoms into a granular simulation domain press/berendsen - pressure control by Berendsen barostat print - print text and variables during a simulation property/atom - add customized per-atom values reax/bonds - write out ReaxFF bond information recenter - constrain the center-of-mass position of a group of atoms restrain - constrain a bond, angle, dihedral rigid - constrain one or more clusters of atoms to move as a rigid body with NVE integration rigid/nph - constrain one or more clusters of atoms to move as a rigid body with NPH integration rigid/npt - constrain one or more clusters of atoms to move as a rigid body with NPT integration rigid/nve - constrain one or more clusters of atoms to move as a rigid body with alternate NVE integration rigid/nvt - constrain one or more clusters of atoms to move as a rigid body with NVT integration rigid - constrain many small clusters of atoms to move as a rigid body with NVE integration setforce - set the force on each atom shake - SHAKE constraints on bonds and/or angles spring - apply harmonic spring force to group of atoms spring/rg - spring on radius of gyration of group of atoms spring/self - spring from each atom to its origin srd - stochastic rotation dynamics (SRD) store/force - store force on each atom store/state - store attributes for each atom temp/berendsen - temperature control by Berendsen thermostat temp/rescale - temperature control by velocity rescaling thermal/conductivity - 使用Muller-Plathe方法计算热导 tmd - guide a group of atoms to a new configuration ttm - two-temperature model for electronic/atomic coupling viscosity - Muller-Plathe动量交换法计算粘度 viscous - viscous damping for granular simulations wall/colloid - Lennard-Jones wall interacting with finite-size particles wall/gran - frictional wall(s) for granular simulations wall/harmonic - harmonic spring wall wall/lj126 - Lennard-Jones 12-6 wall wall/lj93 - Lennard-Jones 9-3 wall wall/piston - moving reflective piston wall wall/reflect - reflecting wall(s) wall/region - use region surface as wall wall/srd - slip/no-slip wall for SRD particles
另外还有一些用户贡献的fix命令也发布在LAMMPS程序包中。
也有一些用于加速CPU和GPU计算速度的fix命令发布在LAMMPS程序包中。
使用限制
有些类型的fix命令被包含在某些特定安装包里。只在安装LAMMPS的时候将这些安装包编译进去,它们才是可用的。如果某种类型的fix命令需要某个特定的安装包,会在其单独的介绍页面中介绍。