关于lammps学习的一点汇总.ppt_第1页
关于lammps学习的一点汇总.ppt_第2页
关于lammps学习的一点汇总.ppt_第3页
关于lammps学习的一点汇总.ppt_第4页
关于lammps学习的一点汇总.ppt_第5页
已阅读5页,还剩42页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、LAMMPS、VMD软件的学习汇报,一、分子动力学的简要介绍 二、 Lammps软件的基本介绍 三、Lammps模拟的相关命令 四、VMD可视化处理软件的基础使用,汇报内容,一、分子动力学模拟,第一原理计算 :解薛定谔方程的过程 电子结构方法: 方程中包含了所有的原子核及电子的哈密度量和波函数 密度泛函理论: 用电子密度代替电子坐标,减少自由的计算,计算物理可分为两大类:计算求解和计算机模拟,利用 ,先由各个原子的位置计算系统的势能, 得到各个原子所受的力及加速度,然后计算各原子在经过T之后 的位置及速度;由新的位置计算系统的势能,得到各原子的受力及 加速度。反复循环,就可以得到系统中原子的运

2、动轨迹并输出相关 的热力学数据。,分子动力学模拟 ?,:解牛顿运动方程的过程,优势: 把整个原子作为一个质点进行模拟,减少了自由度的计算, 加大了可计算的体系的空间和时间尺度,简化数据处理和 分析。,二、Lammps软件的基本介绍,Lammps?,Large-scale Atomic/Molecular Massively Parallel Simulator 大规模原子/分子并行模拟器,简单的来说,Lammps就是一个可根植于Windows和Linux系统 的经典分子动力学代码;根据不同的边界条件和初始条件对相互 作用的分子,原子,宏观粒子集合进行牛顿运动方程积分,并输 出相关的热力学数据。

3、,优点: 免费开源的代码;可以根据需要修改、扩展计算程序(C+) 可对固、液、气三种状态的物质进行模拟 能模拟多种模型体系(原子,聚合物,有机分子,粒子材料) 模拟体系可达上百万个粒子(计算资源) 方便的并行计算,模拟流程:,三、Lammps模拟的相关命令,一般而言,一个Lammps工作目录需要包含以下几个文件; Lammps执行程序 脚本文件(in文件) 势函数文件(eam.alloy , tersoff, sw) data文件(体系的初始构型) MPI并行文件(多核运行计算),脚本文件的内容及书写格式,In文件结构 一般分为4个部分:Initialization, Atom definit

4、ion, Settings, Run a simulation(1) Initialization 模拟体系之前, 一些参数必须要被设置.相关的命令有:units, dimension, boundary, atom_style 等. (2) Atom definition lammps提供3种方式定义原子: 按照晶格的方式创建原子, 相关命令: lattice, region, create_box , create_atoms . 通过read_data 或 read_restart 命令从data或restart文件读入(可包含 出原子坐标之外的一些信息) 已经设置好的原子可以用repl

5、icate命令复制以生成一个更大规模的 模拟体系.,(3)settings 原子信息定义好后, 要定义一系列的设置: 力场系数、模拟参数、输出选项 等. 力场系数可以通过这些命令定义: pair_style , pair_coeff , bond_coeff , angle_coeff 等。 各种模拟参数由这些命令设置: neighbor, group, timestep, reset_timestep , run_style , min_style. fix命令是lammps中很重要的一个命令, 它包括很多子命令, 对体系施加 一系列的约束条件,选择系综等等. 设定 lammps进行各种计算

6、: compute, variable. 输出选项由thermo, dump, restart命令设置.,(4)Run a simulation 使用run命令开始一个分子动力学模拟; 用minimize命令来实施能量最小化(molecular statics),units Syntax: units style style =ljorrealormetalorsiorcgsorelectron Examples: units lj units metal dimension Syntax: dimension N N = 2 or 3 Examples: dimension 3 atom_s

7、tyle Syntax: atom_style style args style =atomicorbody orchargeordipoleorelectronorfullor molecular orperiorsphereortriorhybrid Examples: atom_style atomic atom_style full,Initialization,boundary,Fixed boundary (f) Free boundary (s) Periodic boundary (p),柔性边界 (m): 允许边界上的粒子有微小 移动以反映内层粒子的作用力施加到它 们身上的情

8、况,Syntax: boundary x y z x, y, z =porsorform, one or two letters Examples: boundary p p f boundary p fs p boundary s f fm 边界条件不同,模拟所得到的结果会有所不同,应根据实际模拟的 问题和选用的系综来选取合适的边界条件,Al块体结构 lattice fcc 4.0495 #定义晶格类型 region box block 0 10 0 10 0 10 #定义模拟盒子的大小 create_box 1 box #创建模拟盒子 create_atoms 1 box #在模拟盒子中创

9、建原子,lammps内部搭建模型,NaCl结构 lattice custom $x a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 & basis 0.0 0.0 0.0 basis 0.5 0.5 0.0 basis 0.5 0.0 0.5 basis 0.0 0.5 0.5 & basis 0.5 0.5 0.5 basis 0.0 0.0 0.5 basis 0.0 0.5 0.0 basis 0.5 0.0 0.0region box block 0 5 0 5 0 5create_box 2 boxcreate_atoms 2 box bas

10、is 1 1 basis 2 1 basis 3 1 basis 4 1 & basis 5 2 basis 6 2 basis 7 2 basis 8 2,Atom definition,LAMMPS 2013 data file for alcucouple #注释行 61968 atoms #总原子数 2 atom types #原子类型 0.000000000 68.760400000 xlo xhi #模拟盒子x方向尺寸 0.000000000 68.760400000 ylo yhi #模拟盒子y方向尺寸 0.000000000 186.420900000 zlo zhi #模拟盒

11、子z方向尺寸 Masses #关键字:定义原子质量 1 26.982000 #定义第一种原子质量 2 63.546001 #定义第二种原子质量 Atoms #关键字:定义原子坐标 1 1 0.000000000 0.000000000 33.825999948 #原子坐标:原子编号 原子类型 x坐标 y坐标 z坐标 2 1 0.000000000 0.000000000 102.667499948 3 1 2.022364706 2.022364706 33.825999948 4 1 2.022364706 2.022364706 102.667499948 5 1 0.000000000

12、2.022364706 35.850749948 6 2 2.022364706 0.000000000 35.850749948 7 2 0.000000000 0.000000000 37.875499948 8 2 2.022364706 2.022364706 37.875499948 9 2 0.000000000 2.022364706 39.900249948 10 2 2.022364706 0.000000000 39.900249948,外部搭建模型,不同的atom_style, data文件格式不尽相同,定义原子坐标的格式 atomic atom-ID atom-type

13、 x y z charge atom-ID atom-type q x y z full atom-ID molecule-ID atom-type q x y z hybrid atom-ID atom-type x y z sub-style1 sub-style2 .,bonds= # of bonds in system angles= # of angles in system dihedrals= # of dihedrals in system impropers= # of impropers in system bond types= # of bond types in s

14、ystem angle types= # of angle types in system dihedral types= # of dihedral types in system improper types= # of improper types in system,不管采用什么途径,只要data文件格式符合要求,lammps就可以读入,Materials studio结合msi2lmp写入data文件,在MS搭建好模型 在Modules中选择Discover模块,将Forcefield设置为cvff Calculate之后将构型文件Export,保存为*.car *.cor类型 直接

15、export保存为*.car *.cor类型 将保存的两个文件*.car和*.mdf 复制到msi2lmp的工作路径 在msi2lmp路径下执行 ./msi2lmp.exe * -class I -frc cvff data.*,settings,力场参数(势函数的调用),pair_style pair_coeff,Examples: pair_style eam/alloy pair_coeff * * AlCu.eam.alloy Al Cu,pair_style eam/alloy pair_coeff * * AlCu.eam.alloy Al Al Al Cu,pair_style

16、eam/alloy pair_coeff * * AlCu.eam.alloy Cu Al,pair_style eam pair_coeff 1 1 Al.eam pair_style eam pair_coeff 2 2 Cu.eam,pair_style eam/alloy pair_coeff * * AlCu.eam.alloy Cu,neighbor neighbor cutoff distance = force cutoff + skindistance,Syntax: neighbor skin style skin = extra distance beyond force

17、 cutoff (distance units) style =binornsqormulti Examples: neighbor 0.3 bin neighbor 2.0 nsq 三种算法(处理器分配的原子数) bin: N/P nsq: (N/P)2 默认值 2.0 bin for units = real or metal, skin = 2.0 Angstroms,region , group,region box block INF INF INF INF INF INF units box region al block INF INF INF INF INF 102.66749

18、99480 units box region wallal block INF INF INF INF INF 3.454749948 units box region cu block INF INF INF INF 105.4974998710 INF units box region wallcu block INF INF INF INF 161.5253498710 INF units box group Al type 1 group Cu type 2 group box region box group al region al group cu region cu group

19、 wallal region wallal group wallcu region wallcu group wall union wallal wallcu group mobile subtract box wall group mobileal subtract al wallal group mobilecu subtract cu wallcu,timestep , rest_timestep timestep 0.002 reset_timestep 0 minimize , min_style min_style cg minimize 1.0e-4 1.0e-6 100 100

20、0,create类型:为group中的原子用随机的方法产生一个满足指定温度的速度 set类型:用于给group中的所有原子赋予一个特定值的速度 scale类型:先计算当前的group原子的温度,然后再标度速度到指定的温度。 ramp类型:从vlo - vhi的均匀速度梯度,用于vx , vy , vz 维度 zero类型:线动量和角动量置为0,velocity Syntax: velocity group-ID style args keyword args . group-ID = ID of group of atoms whose velocity will be changed sty

21、le =createorsetorscaleorramporzero 以某种style设定或改变指定的group的速度 对于某一类型,有对应的arguments和可选的keyword/value参数,velocity all create 300 4928459 rot no dist gaussian velocity wallal set 0.0 0.0 0.0 units box velocity wallcu set NULL NULL 0.0 units box velocity all zero linear velocity flow ramp vx 0.0 5.0 y 5 25

22、,fix Syntax: fix ID group-ID style args ID = user-assigned name for the fix group-ID = ID of the group of atoms to apply the fix to style = one of a long list of possible style names args = arguments used by a particular style,style,fix nve , nvt , npt,nve:微正则系综,模拟过程中体系原子数,体积,总能量保持不变(孤立系统)。通 过对速度的标度

23、来对能量进行调整 nvt:正则系综,原子数,体积,温度保持不变。保持温度不的方法是让系统与虚拟的 热浴处于热平衡 npt:等温等压系综,原子数,压强,温度保持不变。温度的恒定与nvt一样,压强的恒 定通过调整体积来实现,fix 1 all nve fix 2 all nvt temp 100 300 0.2 drag 1.0 fix 3 all npt temp 300 100 0.2 iso 1.0 1.0 2 drag 1.0 fix 4 all npt temp 300 100 0.2 aniso 1.0 1.0 2 drag 1.0 fix 5 all npt temp 200 500

24、 0.2 x 1.0 1.0 2 y 1.0 1.0 2 z 100 100 2 couple none drag 1.0 fix 6 all npt temp 200 500 0.2 z 1.0 100 2 couple none drag 1.0 fix 7 all npt temp 200 500 0.2 x 1.0 1.0 2 y 1.0 1.0 2 z 1.0 100 2 couple xy drag 1.0,iso 1.0 1.0 2 等同于 x 1.0 1.0 2 y 1.0 1.0 2 z 1.0 1.0 2 couple xyz aniso 1.0 1.0 2 等同于 x 1

25、.0 1.0 2 y 1.0 1.0 2 z 1.0 1.0 2 couple none,fix npt 对于边界条件的要求: 控制压强的方向必须是周期性边界 examples: boundary p p s fix 1 all npt temp 300 300 0.2 z 1.0 1.0 2 drag 1.0 fix 2 all npt temp 300 300 0.2 x 1.0 1.0 2 y 1.0 1.0 2 drag 1.0,fix temp/berendsen fix press/berendsen fix temp/rescale fix 1 all temp/berendse

26、n 300.0 300.0 100.0 fix 1 all press/berendsen iso 0.0 0.0 1000.0 fix 3 boundary temp/rescale 1 1.0 1.5 0.05 1.0,只调整原子的数度,不更新原子的位置(没有时间积分) 所以需要结合nve使用, press/berendsen可结合nvt使用,Fix setforce Syntax: fix ID group-ID setforce fx fy fz keyword value . fix 1 wallal setforce 0.0 0.0 0.0 fix 2 wallcu setforc

27、e NUL NUL 0.0 与velocity结合使用固定原子,fix momentum 通过调整原子的速度,将体系的线动量和角动量归0 fix 1 all momentum 100 linear 1 1 1 angular,compute,Syntax: compute ID group-ID style args,Lammps有两种类型的compute命令 计算global value compute 4 all pe 计算per-atom values compute 3 boundary pe/atom,数据文件输出,全局热力学数据的输出 log.lammps thermo_style

28、,thermo_style custom step temp press pxx pe etotal vol lx enthalpy c_3 c_32 f_31 v_3,原子轨迹文件的输出 dump dump 1 all custom 100 all.lammpstrj id type x y z xs ys zs c_3 c_2 f_2,断点数据的输出 write_restart write_restart 10ns.restart read_restart 10ns.restart,fix ave/time 时间平均 fix 1 all ave/time 100 5 1000 c_31 c

29、_32 c_23 file result.txt,数据处理的相关命令,fix ave/spatial 空间平均 fix 1 all ave/spatial 100 5 1000 z 0.0 2.0 density/number units box ave one file al.txt,compute reduce 矢量转化为标量 compute 1 all property/atoms vx fx compute 2 all reduce sum c_11 c_12 compute 3 all reduce ave c_11 c_12 这样就可以直接在thermo_style中输出c_31和

30、c_32 或者用 fix ave/time输出,Variable 变量的使用,Variable的巧妙使用能简化脚本文件,后期数据处理节约时间 包括字符串,数学运算,数学函数,组函数,区域函数,特殊函数,variable x index 300 400 500 600 variable b1 equal x234+0.5*vol Variable N1 equal “count (Al, Al) variable S equal step variable T equal temp variable P equal pe,examples: compute 1 al msd com yes va

31、riable A equal c_11 variable B equal c_12 variable C equal c_13 variable D equal c_14 fix 1 al print 1000 $S $A $B $C $D file al.txt screen no,Serial simulation ./ lmp_linux in. input Parallel simulation mpirun -n 32 ./lmp_linux in.input,#Cu-Al couple diffusion units metal dimension 3 boundary p p p

32、 atom_style atomic variable x index 600 650 700 750 variable runtime equal (v_x-300)*10 variable t equal $runtime variable S equal step variable T equal temp variable P equal pe variable K equal ke variable Y equal press variable N equal etotal variable V equal vol read_data data.alcucouple lattice

33、none region allbox block INF INF INF INF INF INF units box region al block INF INF INF INF INF 102.6674999480 units box region wallal block INF INF INF INF INF 3.454749948 units box region cu block INF INF INF INF 105.4974998710 INF units box region wallcu block INF INF INF INF 161.5253498710 INF un

34、its box,AlCu扩散in文件,group Al type 1 group Cu type 2 group allbox region allbox group al region al group wallal region wallal group cu region cu group wallcu region wallcu group wall union wallal wallcu group mobile subtract allbox wall group mobileal subtract al wallal group mobilecu subtract cu wall

35、cu pair_style eam/alloy pair_coeff * * AlCu.eam.alloy Al Cu neighbor 2.0 bin neigh_modify every 1 delay 0 check yes timestep 0.002 velocity mobile create 300 4928459 dist gaussian velocity wallal set 0.0 0.0 0.0 units box velocity wallcu set 0.0 0.0 0.0 units box thermo_style custom step temp press

36、pe etotal vol thermo_modify norm no thermo 5000,fix 1 allbox npt temp 300 300 0.2 iso 1.0 1.0 2 drag 1.0 fix 2 wallal setforce 0.0 0.0 0.0 fix 3 wallcu setforce 0.0 0.0 0.0 fix 4 allbox print 500 $S $T $Y $P $K $N $V file sys$x.txt screen no run 50000 unfix 1 fix 5 allbox npt temp 300 $x 0.02 iso 1.

37、0 1.0 2 drag 1.0 run $t unfix 5 compute 1 mobileal msd com yes compute 2 mobilecu msd com yes thermo_style custom step temp press pe etotal vol c_11 c_12 c_13 c_14 & c_21 c_22 c_23 c_24 thermo_modify norm no thermo 5000 variable A equal c_11 variable B equal c_12 variable C equal c_13 variable D equ

38、al c_14 variable E equal c_21 variable F equal c_22 variable G equal c_23 variable H equal c_24,fix 6 allbox npt temp $x $x 0.2 iso 1.0 1.0 2 drag 1.0 fix 7 Al ave/spatial 100 5 1000 z 0.0 2.0 density/number units box ave one file al$file fix 8 Cu ave/spatial 100 5 1000 z 0.0 2.0 density/number

39、 units box ave one file cu$file fix 9 mobileal print 1000 $S $A $B $C $D file al$x.txt screen no fix 10 mobilecu print 1000 $S $E $F $G $H file cu$x.txt screen no dump 1 Al custom 10000 al$x.lammpstrj id type xs ys zs dump 2 Cu custom 10000 cu$x.lammpstrj id type xs ys zs dump 3 allbox custom 1

40、0000 box$x.lammpstrj id type xs ys zs run 500000 write_restart alcu$x.restart clear next x jump in.AlCu750-700,可视化处理VMD的使用,Lammps无法实现模拟过程的可视化,需要借助辅助软件,VMD 搭载了tcl语言环境,具有很强的编译和处理能力,有window版本和Linux版本,在终端输入 “ vmd ” 从白色对话框中导入 dump.lammpstrj 文件,进入Graphics - colors调整颜色 进入Graphics - Representation,结合selections中 的key words创建不同的图层,可对不同图层中的原 子进行独立的调整(显示模型,原子大小,颜色等),进入主对话框“ file render ” 在弹出的对话框中将“ Render using ” 改 为POV3,修改文件名保存,图片的输出与保存,将保存的文件在 pov-ray的软件中打开, 调节分辨率,点击“run”输出图片,单个原子的观测,“ type 2 and x 30 and x 40 and y 50 and z 51 ”,进入主界面 extensions - tcl console,输入:atomselect top “

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论