科学网

 找回密码
  注册

tag 标签: lammps

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

lammps计算平衡晶格常数
daishoujun 2018-4-12 15:54
原帖在 http://www.52souji.net/how-to-calculate-equilibrium-lattice-constant-using-lammps.html 正文中我加了少许改动,还是感谢原作者的贡献,红色字体是我添加的。 平衡晶格常数(equilibrium lattice constant)对应的体系能量是最低的,因此只需要计算一些列不同晶格常数下体系的能量,那么体系能量最小时对应的晶格常数就是平衡晶格常数。 在初次计算时,建议将晶格常数增加的步长取得大一点,比如0.1A,这样通过结果数据就可以大致确定晶格常数的范围。 然后再将晶格常数的范围缩小,减小步长,比如0.01A,这样做就可以获得精度比较高的结果。下面以金刚石为例介绍具体如何计算平衡晶格常数。 输入文件: in.diamond # This input script is used to calculate # the lattice constant of diamond # Powered by Xianbao Duan # Email: xianbao.d@gmail.com # Website: http://www.52souji.net/ units metal #单位是金属 boundary p p p# 周期性边界条件 atom_style atomic variable i loop 20 #20次循环 variable x equal 3.5+0.01*$i #晶格常数 # build the model lattice diamond $x #lattice diamond 3.5 region box block 0 10 0 10 0 10 create_box 1 box create_atoms 1 box # specify the potential pair_style tersoff pair_coeff * * SiC.tersoff C #C 是使用原子 mass 1 12 variable n equal count(all) #原子的总数 variable P equal pe/$n timestep 0.005 thermo 10 # minimize the total energy min_style cg#算法 minimize 1.0e-12 1.0e-12 1000 100 0#最小化条件 print @ $x $P clear next i jump in.diamond 脚本很简单,只要一个简单的能量最小化就可以了,然后输出晶格常数和结合能log文件中。 然后从log文件中将晶格常数和结合能的数据提取出来。 grep^@log.lammpslat.vs.Ecoh.step1 grep是一个linux命令( 搜索命令 ),上面的意思就是将log.lammps文件中以@开始的行输出到 lat.vs.Ecoh.step1 文件中。 得到的文件中,每一行开头会有一个@,通过列编辑器一起删掉,就可以获得有如下内容的文件。 3.51-7.35079243 3.52-7.356562846 3.53-7.361141466 3.54-7.364556691 3.55-7.366836396 3.56-7.368007936 3.57-7.368098161 3.58-7.367133418 3.59-7.365139565 3.6-7.362141974 3.61-7.358165545 3.62-7.353234707 3.63-7.347373432 3.64-7.340605242 3.65-7.332953213 3.66-7.324439984 3.67-7.315087768 3.68-7.304918353 3.69-7.293953116 3.7-7.282213024 上面的数据实际上对应的就是结合能曲线,其能量最低点对应的就是平衡晶格常数。当然,能量最低点的能量就是晶体的结合能。 具体如何从上面的数据中获得最终结果,可以参考原作者之前写的一篇文章: MATLAB计算平衡晶格常数 。 正是我的第一个运行的程序,很开心
个人分类: lammps|14172 次阅读|0 个评论
lammps 运行文件linux Ubuntu 17.10
daishoujun 2018-4-11 21:23
原帖在 http://blog.sina.com.cn/s/blog_a1b839e10102wcu7.html 正文中我加了少许改动,还是感谢原作者的贡献,红色字体是我添加的。 如何使用lammps进行计算 先简要地说说lammps的运行过程: lammps本身没有图形界面, 模拟计算的过程都是在linux终端执行 。计算的时候,需要用户写一个输入文件( input script ),可能还需要一个 data 文件,至于如何写输入文件,我们稍后讨论。 假设你已经写好了这个输入文件, 最好网上找个简单的例子, 文件名为 in.name ,把这个 in.name 文件(如果有data文件的话,连同data文件)和在 步骤2 中编译得到的 lmp_serial 放在同一个目录下, 注意所用势函数文件也要和前述文件一起,要不然找不到势函数,会报错,最好重新建一个文件夹, lmp_serial是 可以复制的 , 如 /Desktop/compute/ 。从终端进入到这个目录,所需要的命令是: cd /Desktop/compute 然后,在终端输入 ./lmp_serial in.name 回车。你就会发现lammps开始计算了。就这么简单。 lammps的 输出文件 主要可以分为三种:一是 log.lammps ,这里面记录了整个计算过程屏幕上显示的所有信息,更详细的请参照 thermo 、 thermo_modify 等命令;另一类是与 dump 命令有关的输出文件,可以输出应力、能量、原子位置、速度等等信息;第三种是 restart 文件,具体的信息请查阅 write_restart 命令。 lammps新手一般会很快注意到下载的lammps解压之后的一个名为 examples 的子目录。面对这里面的in 文件中一行行看似无序的单词和数字的组合,如何写in文件,恐怕是新手们的最大疑问。很多网友在一开始学习lammps的时候,总是问:“怎么写in文 件?”,“examples目录中in文件里面的那些命令和数字是什么意思呀?”等等这些问题,不是人家不回答,而是实在不好回答,无法回答。其实你想 想,只要你会写某个MD模拟过程的in文件了,那lammps就完全可以计算了,那剩下的工作仅仅是数据的后处理。 如何写in文件这要你首先看懂lammps手册!!! 。最次我找个例子演示。
个人分类: lammps|7862 次阅读|0 个评论
lammps 安装linux Ubuntu 17.10
daishoujun 2018-4-11 21:05
原帖在 http://blog.sina.com.cn/s/blog_a1b839e10102wcu7.html 正文中我加了少许改动,还是感谢原作者的贡献,红色字体是我添加的。 下载和编译 lammps是在linux环境下运行的。所以,首先你要有一个linux环境,如果你已经在用linux了,那当然再好不过了。如果你听到lammps这个词的时候对linux一窍不通, 希望你多百度下, 多罗嗦几句:一开始用ubuntu,我就深深的喜欢上它了,现在,我的机子上原来的Windows已经被我格掉了。换一个操作系统,刚开始会很不不习惯, 但是现在,我可以在ubuntu下上网、写文档、看电影听音乐、聊QQ 、用MSN 、看网络电视、使用Matlab……这一切都是通过ubuntu完成的,而非在VirtualBox虚拟的XP中做的。还有最重要的一点,ubuntu中 你所需要的绝大多数软件都可以用 sudo apt-get install 这个命令通过网络安装,不会有Windows里面烦死人的软件破解等等问题。 一段时间之后,你就会觉得ubuntu.linux带给你的美妙的享受,它的那种自由和分享的理念,这,绝对不是Windows可以给你的。 我现在使用的是Ubuntu 17.10。 好了,如果你拥有了linux环境,下面就开始我们体验lammps的历程。 到 这里 下载lammps,建议你下载 LAMMPS upgrade 。需要说明的是,lammps更新很快,几乎每天都有源代码的修改。所以,你有必要经常关注 lammps官方网页, http://lammps.sandia.gov/download.html是下载地址。 下载之后,你会得到一个 *.tar.gz 的压缩文件包,可直接在 Ubuntu 17.10中直接点击右键解压。 之后,你会得到一个名为 lammps-* 的文件夹( 注意,这里的*是通配符 )。最新版本的lammps是用C++写的,编译之前,你的linux系统中需要有一个 编译器 。抱歉地说,我忘记ubuntu是否自带这个编译器了,如果没有的话,用 sudo apt-get install build-essential 这个命令安装,这需要你的系统管理员帐户和密码。 下面说ubuntu下 编译单机版的lammps 的过程: 首先cd到 lammps/src/STUBS 目录下,输入 make ,回车。 然后再cd到 lammps/src/ 目录下,输入 make serial ,回车。 好了,现在你会看到屏幕上的字幕流,表示lammps正在被编译。喝口茶 ,喝点咖啡,小伙儿, 等会儿,剩下的事情ubuntu会帮你搞定。如果成功编译,在 lammps/src/ 目录下,会生成了一个名为 lmp_serial 的可执行文件,计算,就是靠它了,到此你已成功搞定安装过程,恭喜,第一步。
个人分类: lammps|4490 次阅读|0 个评论
Lammps中Voronoi package的安装
XJTUhehuan 2017-11-27 16:47
必要条件:要有一个安装好的Lammps,这方面教程很多。 开始安装Voronoi, 1.在网上下载Voro++的包 网址为: http://math.lbl.gov/voro++/download (可能有的网会打不开,我是用手机打开的) 2.在lammps/lib/voronoi的文件夹下,解压voro++-0.4.6 命令:tar -xvf voro++-0.4.6 3.解压结束后,打开voro++-0.4.6,输入命令:make 4.make结束后,直接输入命令:sudo make install 5.创造链接:输入命令:ln -s voro++-0.4.6/src includelink ln -s voro++-0.4.6/src liblink 6.编译lib/voronoi文件下的Makefile.lammps,将Makefile.lammps改成如下格式 7.进入到lammps/src文件夹下, make yes-voronoi make mpi(这里根据个人情况不同,Manual上写的是make machine,安装包里read me文件里写的是g++) 8. 安装结束后是这样的,安装成功
13893 次阅读|0 个评论
lammps在Mac上的安装——只需4步
liudan2004sd 2017-3-3 22:02
4105 次阅读|1 个评论
LAMMPS的lattice命令的翻译与理解
WTianSD 2016-11-30 15:21
lattice命令,在lammps建模中具有举足轻重的地位,因为LAMMPS本身建模方面是比较薄弱的。Lattice 方便于我们建立大多数晶格模型,所在在金属,晶体,材料等相关领域的研究中,使用比较频繁。 下面是对Lattice命令的介绍: 1. style : none or scor bcc or fcc or hcp or diamond or sq or sq2 or hex or custom 【格点类型】 2. scale : 晶格和模拟盒子之间的比例因子( LJ ) / 格点常数 ( 其他单位 ) 3. (可以不添加或添加多个 keyword/value ) keyword : origin / orient / spacing --- 设置原胞在盒子中的平移或取向规则 Keyword : a1 - a2 - a3– basis --- 【复杂格点设置】 默认:格点是间距为一个单位的立方格子组成。 【功能介绍】 Lattice 命令定义了一个其他指令可以使用的晶格,在 lammps 中,一个晶格是空间中简单的点集,由基本原子构成的可在 3D 空间中无限复制的晶胞(反应晶体对称性的最小重复单元,也作单胞)所组成。 Lattice 命令 可以灵活利用其参数来定义各种各样的晶格。 【使用方式介绍】 lattice 命令在 lammps 中有两种实用方式,首先, create_atomscommand 在模拟盒子内部的格点上创建原子。需要说明的是, create_atoms command 可以为基本原子分配不同的原子类型。第二, 3D 晶格中的晶格间距,可以被其他命令,比如 create_box, region, velocity, 作为距离单元使用。一般来说,当处理格点模型的时候比较方便。 (这个很重要,如果要建完整晶格的话,最好用晶格单位) 【晶格参数的决定参数】一个晶格由晶胞、晶胞内部的 基本原子 和 变换参数 (密度、平移规则、取向)决定。矢量 a1 , a2 , a3 是晶胞的棱矢量【 custom 用的参数】,在固态物理学里面用术语基矢来表示。但是在 lammps 中不一定要用最小体积的原胞(最小的周期性重复单元,个人理解其实由基本原子决定的?)来定义晶胞: 【原胞类型对应的维度】 晶格类型必须要与模拟的维度 (dimension) 匹配。 Sc (简单立方) or bcc (体心立方) or fcc (面心立方) or hcp (六角密堆积) or diamond (金刚石)类型用于三维建模。 sq (四方) or sq2 or hex (六方)类型用于二维建模。 custom 类型既可以用于二维,也可以用于三维建模。 【几种原胞类型的特点】: 简单立方( sc ) , 面心立方( fcc ) , 体心立方( bcc ) , 金刚石( diamond )是 3D 晶格,晶格间距为 1 个 晶格单位 。六方密排晶格( hcp 图片请百度)的基矢为 a1=1 0 0, a2= 0 sqrt(3) 0, a3= 0 0 sqrt(8/3). Sc 在晶胞左下角有一个基本原子, bcc 有两个基本原子、一个在左下角,一个在立方盒子中心; fcc 有四个基本原子 一个在左下角, 3 个在立方面心上。 hcp 晶格有 4 个基本原子,有 2 个在 z=0 的平面上,另外 2 个在 z = 0.5 的平面上。 diamond 晶格有 8 个基本原子。 【基本原子的计算方法要参考晶体学书籍,分在角,面,棱,内等几个部分贡献比例不同】 sq and sq2 类型的晶格是一个 2D 正交晶格。 sq 晶格在正方形左下角有一个基本的原子。 Sq2 晶格则有两个基本原子,一个在角落另一个在正方形的中心。类型 hex 定义的也是二维晶格,但单胞是长方形的,其单胞基矢为 a1 = 1 0 0 和 a2 = 0 sqrt(3) 0 。 hex 晶格有 2 个基本原子,分别在长方形的角上和中心的位置。 类型 custom 允许你通过指定基矢 a1, a2, a3 和单胞中一系列基本原子的坐标来定义晶格。默认情况下, a1, a2, a3 是正交的单位矢量,但你也可以将它们指定为非正交任意长度的矢量,从而描述平行六面体式的单胞。关键字 basis 是用来添加原子的,每使用一次添加一个。它的参数是分数坐标( 0.0 = x,y,z 1.0 )。一个 basis 原子在晶胞中的位置向量是三个基矢的线性组合: x=bx*a1+by*a2+bz*a3.(bx,by,bz 是 basis 关键词给出的分数坐标 ) 【按原胞的基矢定义位置】 【原胞在模拟盒子中如何放置?】 【 scale 参数】 决定在模拟盒子中布置单胞时,它的实际尺寸。也就是说,将该参数作为倍增因子( factor )作用在单胞上,从而可以获得所需尺寸的晶格。 【 scale 参数】 的意义依赖于你在模拟过程中使用的单位类型。 对于 LJ 之外的所有单位类型,参数 scale 都是由相应长度单位决定。举例来说,对于 real 或 metal 的单位类型,如果立方单胞的边长为 1.0 ,指定 scale=3.52 ,那么就会创建一个间距 3.52A (一个格点单位是 3.52 )的立方晶格。 【其实就是晶格单位和时间单位的对应关系:实际单位 * scale= 格点单位】 对于 LJ 单元, scale 是 Lennard-Jones 约化数密度( rho* )。 Lammps 通过公式 factor^dim= rho/rho* 将这个值转变为倍增因子( factor )。 rho =N/V (数密度 = 数目 / 体积), v= 晶格单元的体积, n= 晶胞中基本原子的数量, dim 根据模拟的维度等于 2 或者 3 。实际上这表明如果在模拟中使用的 lj 粒子的 sigma=1.0 ,那么晶格中的粒子将会有预期的约化密度。 【设置时要根据格点类型算出密度来】 origin 选项指定在将单胞布置在模拟盒子中的时候, 如何对其进行上浮或者平移 。参数 x,y,z 是分数值( 0.0 =x,y,z 1.0 ),意思是说按着相应方向上 的晶格间距的分数倍进行平移或者上浮 。 【也就是上浮或平移晶格的几分之几】 orient 选项指定在将单胞布置在模拟盒子中的时候,如何对其进行旋转。 【其实是设置坐标轴放在哪个晶格方向上】 参数 dim 是模拟盒子 3 个坐标轴中的一个。 另外 3 个参数定义一个晶体学方向,你的单胞将会沿着那个方向摆放; 需要指定为整数,比如 orient x 2 1 0 的意思就是说模拟盒子的 x 方向是沿着晶格的 方向。你所指定的三个晶格方向必须是相互正交的,并且满足右手定则,即 X 叉乘 Y 的方向与 Z 相同。 需要注意的是,这里的介绍只对正交晶格是适用的。 如果你要使用 custom 类型定义非正交的边矢量 a1,a2,a3 ,那么你可以认为 orient 选项定义了 3x3 的旋转矩阵,并将其作用于 a1,a2,a3 对最初的单胞进行旋转,从而得到新的摆向。 【非正交体系的旋转问题使用时要测试;或者源码解析下看看具体数学表达式,手册上说的含糊,不好理解,其实就是晶体结构都是定的,其实意思就是如何在 晶体上切块,切一个什么样的块】 LAMMPS 命令可以使用沿着 x,y,z 三个方向的晶格距离作为距离的单位。比如使用命令 region 创建尺寸为 10x20x20 的方块,其中的 10 就是说沿着 x 方向的长度是 10 倍的晶格距离。 spacing 选项用来直接设置 3 个晶格间距。所有的参数都不能是 0 (如果是二维模拟,将 dz 设置为 1.0 )。【这个只是在特殊情况下使用】
个人分类: 模拟技术|17383 次阅读|0 个评论
模拟小窝(SimulationWorld)网络课堂介绍
WTianSD 2016-11-30 15:12
1. . 模拟小窝在网易云课堂推出系列分子动力学模拟的课程,包含基本理论、模拟软件、数据分析软件的介绍(目前包含分子模拟入门知识,LAMMPS软件,GROMACS软件,VMD软件)等等。课堂是一线科研人员精心制作的计算模拟技术入门和提升课程。 课程系列以引导如何自学为目标,解决学什么、怎么学的问题;课程以授“渔”为宗旨。入门课程旨在缩短新手的入门时间,降低入门的门槛,实现新人尽快掌握模拟所需要的基本知识和基本技能 课题地址: http://study.163.com/u/simuly 另外课程部分内容可以在优酷 模拟小窝 自频道观看: http://i.youku.com/i/UMjg3MDcwODM1Mg== 2. SimulationWorld微信公众号(扫描关注): 共享分子模拟的技巧,分享模拟经验和相关知识技能,打造国内利用分子模拟进行科学研究的交流平台;构建学习型互联网+社区,助力中国科学技术发展。
个人分类: 模拟技术|7409 次阅读|0 个评论
Ubuntu下LAMMPS的并行安装教程(最新版)
WTianSD 2016-11-6 11:31
Ubuntu下LAMMPS的并行安装步骤 最近一直有些新人咨询如何在 Ubuntu下安装并行版的LAMMPS。尽管本人不推荐用ubuntu桌面版做并行计算(server版不错), 但还是想写一个帖子来回答这个问题。 网络上有很多教程教大家安装,但大多有点老旧了,跟不上LAMMPS版本的发展。官网上有ubuntu系统下的预编译版,但完全不推荐;因为LAMMPS包含的包很多,不需要所有的都安装上。全安装上,在一定程度上会影响到计算效率,这有点像你去旅游,背了很多根本用不到的沙袋走路。 在任何类Unix操作系统下安装软件,不外乎如下步骤: 1. 检查依赖包 2. 安装没有的依赖包 3.按说明安装软件,并设置路径 下面就具体介绍安装步骤: Ubuntu下安装LAMMPS并行版需要安装必要的依赖包,都包含哪些呢?你可以到你lammps源程序下的src/MAKE/MACHINES下找到Makefile.ubuntu文件; 用文本浏览软件打开它(命令行也行,比如 less Makefile.ubuntu)。 你会看到前10行有依赖包的介绍。 2016版的如下(版本有变,可能依赖包会有变化,大家都可以找到这个文件打开看看): ---------------- # ubuntu = Ubuntu Linux box, g++, openmpi, FFTW3 # you have to install the packages g++, mpi-default-bin, mpi-default-dev, # libfftw3-dev, libjpeg-dev and libpng12-dev to compile LAMMPS with this # makefile 包含,g++编译器,如果你安装user发展的包,可能还要用到gfortran编译器; 并行包,mpi编译器,fftw库,图片打印输出库等。 1. 我们首先检查下依赖包:在命令行下 用 which命令进行检查是否存在。 执行: which gcc ; which g++; which mpirun; which mpic++; which gfortran等。Fftw,jpeg,png等库要到/usr/include下查看有没有fftw3等相应的头文件。 有了就不需要再次安装,没有就需要先安装上。 2. 假定你上面的依赖包都没有(重复安装无所谓),请顺序执行下面命令: 【这些安装要su root下;LAMMPS安装不需要root权限】 a) apt-get install gcc* b) apt-get install g++* c) apt-get install mpi-default-* d) apt-get install libfftw3* e) apt-get install libjpeg-* f) apt-get install libpng12-* 确保上面的库都安装上,安装过程中可以看到是否已经装上,没有的话,窗口会等待让你输入 yes 3. 上面包安装好后,进入到 lammps/src/MAKE下,把MACHINES下的 Makefile.ubuntu文件 复制到 MAKE下,这时,你看到MAKE下还有 .mpi, .serial两个Makefile文件。 4. 到src下执行make package-status查看有哪些包是yes态和no态;yes表示安装,no表示不安装。用make yes-包名或make no-包名, 加载/取消你安装的包。选择自己必要的包就行了。 5. 进入src下执行 make Ubuntu 命令,等待安装; 安装结束后,会生成一个lmp_ubuntu可执行程序,这个就是你要的了 6. 在你的家目录下(比如/home/zhangsan),执行mkdir bin见一个bin文件夹,并把lmp_ubuntu复制到此文件夹下; 然后 cd 到 家目录 vi .bashrc 文件。在此文件的最后一行 加入 export PATH=/home/zhangsan/bin:$PATH;保存并 source .bashrc。 最新执行 which lmp_ubuntu查看下是不是可以找到路径。可以的话,可结束安装了。 上面的步骤完成后,安装就结束了, 你可以cd 到 example下的例子中(比如 micelle下),执行 lmp_ubuntu in.micelle 或者 mpirun -np 2 lmp_ubuntu in.micelle 看看是否可以用。 Linux下软件的安装,根本在依赖包的安装和路径的设置,这些搞定,安装不会有障碍。 详细的安装过程,大家也可以观看免费网络视频: http://i.youku.com/simuly
个人分类: 模拟技术|29728 次阅读|0 个评论
LAMMPS学习和分子动力学学习网络课程上线啦
WTianSD 2016-9-24 21:49
各位关注分子模拟和LAMMPS入门课程的同学,【分子动力学入门引导网络课程】和【LAMMPS入门引导网络课程】正式入驻专业的网络教学平台--网易云课堂 上,希望为大家带来更好的学习体验。 以后关注这两门课程的更新都会在网易云课堂上进行。 入门引导课程系列以引导如何自学为目标,解决学什么、怎么学的问题;同时,课程中会分享模拟的技巧和经验,避免弯路之法;课程以授“渔”为宗旨。 优酷平台( http://i.youku.com/simuly )上只保留 【口说LAMMPS命令】 的更新 网易云课堂的地址为: http://study.163.com/u/simuly (最好在电脑浏览器地址栏打开)。 欢迎大家有需要的同学来访问。
个人分类: 模拟技术|10112 次阅读|0 个评论
[转载]origin-输入特殊符号
motivatedgirl 2014-8-31 15:29
origin-输入特殊符号相信很多人都遇到过这种情况 ,用 Origin 作图时插入某些特殊符号( 如αβμ等希腊字母或℃等某些单位符号)之后,粘贴到W ord里就会变成乱码或 问号。如何解决这个问题呢? 散人在这里提供三种有效的方法。 第一种可以说是放之四海皆准的通法。在Origin软件里输入特殊符号后,选中它们,然后在Origin快捷工具栏 里将字体设置为宋体或者Symbol 。设置完毕之后,这时候再将Origin里作的图粘贴到Word中,所有特殊符号都可 以正常显示了。 第二种方法就更简单了:在Origin的文本输入状态下,按Ctrl+M快捷键,看看出 现什么了?没错,是特殊符号库!在这里尽情地选择并插入你需要的特殊符号吧。通过这种方式插入的特殊符号在Word里面也可以正常显示。 第三种方法是专门针对Origin中输入希腊字母而言。点击工具栏上的Greek按钮(即“αβ”按钮)或者ctrl+g快捷键,就可以通过键盘毫不费力地输入希腊字母了,还可以切换大小写。比如在这种状态下,m键就是希腊字母的μ。 转载自 拼命三郎的博客 http://blog.sina.com.cn/s/blog_4f0994930100rmix.html
1928 次阅读|0 个评论
[转载]LAMMPS的DUMP中原子属性, 在VMD直接着色
motivatedgirl 2014-8-31 14:59
因为我一直用的是LAMMPS来 计算 , 看过hongye的关于 原子 着色的代码, (参见此处) http://www.mdbbs.org/thread-24159-1-1.html 觉得稍微改改就可以在VMD里直接着色DUMP 文件 了. 不必再另外提取DUMP中那些属性列的(域user)成单独文件了. 这里把改过后的TCL文档发出来和大家 分享 下. 把附件中的 load.tcl 文件放在VMD的安装目录下, 一般是 C:\Program Files\University of Illinois\VMD . 然后步骤: 1. 打开VMD主界面 (出现三个窗口, 一个VMD Main, 一个openGL Display, 还有一个就是控制台了) 2. 载入LAMMPS产生的DUMP文件,可通过VMD Main-File- New... ( 在win环境下将dump文件后缀改成 lammps trj 后可直接把文件往VMD里拖即可 ; 或者在控制台输入 mol new $filename waitfor all, 太慢,不建议 如果非要用load.tcl中的第一行(本来被我#掉的) 命令 : mol new $filename waitfor all ; 大家千万不要把后面的waitfor all删掉啊, 要不肯定出问题, 原因很简单大家可以自己想想. ) 3. 在上面打开的三个窗口之一的VMD的 控制台 中, (或用Main-Extensions-Tk Consle打开Tk控制台, 不建议采用Tk Console, 处理数据时容易死掉), 输入命令: set file c:/filename; source load.tcl (注意空格. c:/filename 是刚才打开的DUMP文件名称. 注意请填写DUMP文件绝对路径名称, LINUX的'/'而不是微软的'\', 如 c:/lammps/crack.dump. 如果DUMP文件在VMD安装目录下, 可不用填写路径. 也可以用在控制台中输入命令转换你的工作目录,如命令: cd c:/lammps/ ;即可将当前工作目录转到c:/lammps/下, 如果这个时候你的DUMP文件和load.tcl正好在工作目录下,就可以输入 set file filename; source load.tcl 其实这里只是个路径绕来绕去的问题, set file和source指令后面要跟的是两个文件名, 常规情况下两文件名是应该要带有绝对路径的, 可这不是想为大家省事么, 每次都傻瓜似操作就好, 所以先set好dump文件的绝对位置, 再干脆然后就把load.tcl放在了工作目录(WIN下也就是安装目录). 大家也可以通过cd来改变工作目录, 只要保证set file后面能跟对dump文件的位置, source后面跟对load.tcl文件的位置, 不管是在WIN还是LINUX下原理都这样. 其实 linux 下还方便一些, 在 控制台 输入 vmd 后, 当前路径就是vmd的工作路径了, 这时如果dump和load.tcl都正在当前工作路径下,直接set file filename; source load.tcl 就行了. 有 朋友 想要我说明下load.tcl里都是什么意思, 哎...实在不值一提啊, tk/tcl其实是跟basic一样简单的东西, 大家对着命令参考google下就知道都是些啥了. ) 4. 等待加载完成后, 可以在Graphical Representations-Color Method-Trajectory-User-User(2,3,4)里选想要着色的域. (这里要注意的是VMD默认的User域是float型的,如果阁下要着色非float型, 改load.tcl中的User为其它Keywords吧,如Name, Type等..., 参考9楼说明. 但这里注意一下, VMD好像将非实数型数据所有第一个字符相同的数据归为一个类型了, 如: 如果你设的非实数型属性分别是 H1, H2, H3, O1, O2, O3... 的话, VMD会将H1,H2,H3着相同的色, O1,O2,O3会着相同的色, 也就说把所有字母数字啥的都用上作为属性首字母,能着的色也就几十种(我记得VMD能给的这种类型的着色好像不超过15种)... ) VMD会自动将DUMP的末四列数据分别放入user, user2, user3, user4 如,如果DUMP文件列的格式如下: ITEM: ATOMS id type x y vx vy c_displ c_displ v_meanstress v_effestress v_constraint 那么user, user2, user3, user4 分别放 v_constraint, v_effestress, v_meanstress , c_displ 的值. (这里如果不是想着色后四列, 而是想着色指定的令, 参照我9楼的回贴改改load.tcl文件吧. ) 最后附上一个LAMMPS的例子in.crack供大家调试看看效果. (是in文件,得分把钟跑出dump文件). 注意,此load.tcl目前只适用LAMMPS产生的DUMP格式文件, 其它格式文件的着色,可以参考其具体的格式来修改load.tcl文件. 也希望各位能将修改过的各种不同格式的load.tcl跟贴发上来, 或直接传给我, 到时整合整合后让这个文件更通用些. 哦, 还有一点补充的就是,多CPU计算后如果生成的DUMP文件是一个多帧在一块的大文件, 我这里的提供的load.tcl 可能就不适用了, 因为多CPU生成的多帧在一起的文件里id没经过排序,解决办法就将每帧数据按id排序后再用. 2010年5月5号 看到hooge专门发个贴针对我的load.tcl文件以 学习 tcl各语句含义, http://www.mdbbs.org/thread-25347-1-1.html 觉得惭愧, 原来的load.tcl文件里没加上任何注释因为当时自己也是看着hongye的文件现学的tk/tcl改写的, 以为那是很简单的东西应该一看就明白的. 为了方便大家明白里面各命令的含义, 这里再上传一份load2.tcl,里面有稍微改动并添加了注释. 2010年5月28号 在以下两个回贴中说到VMD中怎样改变着色云图以达到我们所希望的好的效果: http://www.mdbbs.org/viewthread.php?tid=26085page=1#pid119093 http://www.mdbbs.org/viewthread.php?tid=25903page=1#pid118159 这里再编辑总结一下, 以方便各位想作云图的朋友, 虽然VMD的渲染等效果是没有Pymol等好, 不过稍微调整一下还是不错的,我截个的裂纹扩展的范例 效果图 如下供大家参考 (注意不是例子中in.crack算例, 是我另外一个算例截的图). VMD的color method方案默认是的RWB, 即红白蓝,所以着色默认是红低白中蓝高, 这样弄出的云图效果确实不敢恭维, 而一般漂亮的云图着色则会是 BGR,即蓝低绿中红高, 如范例图, 可将着色方案 配置如下: Graphics-color-color scale-method-BGR, Offset-0.0 Midpoint-0.5 同时配合手动调整此着色域范围来达到想要的最佳效果, 请在 Graphics-Representations-Trajectory-Color scale data range 里调整数值便可. 如果大家想把以上着色配置设成VMD的默认项,那请将以下两行代码添加到VMD安装目录下的 vmd.rc 文件中即可, mol default color mol default color 顺便多说一句, 大家要是有其它 设置 项希望设置成VMD默认项的, 也在继续在vmd.rc文件中添加相关设置命令.
6302 次阅读|0 个评论
[转载]VMD中实现原子的数值着色方法
motivatedgirl 2014-8-31 14:59
类似于下面的图 只要是对 原子 根据某一数值进行着色(如 能量 、位移、破裂等),本文的方法都可以实现,对单帧或多帧都适用。 附件为 教程 和代码。 VMD中实现原子的数值着色方法.doc (1.21 MB) user.tcl (448 Bytes) PS. 用LAMMPS的同学可以参考这个帖子 http://www.mdbbs.org/thread-24429-1-3.html ,也希望各位能将该方法扩充到各种常用 软件 中。
2719 次阅读|0 个评论
[转载]lmp to vmd
motivatedgirl 2014-8-31 14:56
This directory contains utility scripts for using VMD to visualize and analyze LAMMPS trajectories (hopefully in the future this will turn into a plugin or proper library). Below are short descriptions and examples on how to use them. Additional information on VMD as well as additional scripts can be found at: http://www.ks.uiuc.edu/Research/vmd/ and: http://www.theochem.rub.de/go/cpmd-vmd.html codes:http://code.google.com/p/lammps-hppi/source/browse/branches /lammps-10Mar10/tools/lmp2vmd/?r=21 The scripts are maintained by Axel Kohlmeyer akohlmey@cmm.chem.upenn.edu; please contact him through the LAMMPS mailing list in case of problems. ------------------------- 0. Installation. The scripts below define new tcl procedures for use with the tcl script interpreter embedded into VMD. To activate them, you can load them by using the "source" command. However it is more convenient to have VMD load them automatically on demand. To do this, you need to modify your .vmdrc (or vmd.rc) file (see the VMD User's Guide for details) and add the and adapted version of the following code. # add local (auto-loaded) scripts to the interpreter search path set auto_path With this change the "source" command lines below are no longer needed. If you add new files or procedures to this directory, you have to run the mkindex script to update the tclIndex file. ------------------------- 1. lmpbonds2vmd.tcl - translate bonding information from a LAMMPS data file into VMD. 1a. Background. With VMD one typically reads bonding information from a topology file and then reads a trajectory with the coordinate information on top of that. The most common use is the combination of a (CHARMM or X-PLOR style) PSF file and a DCD file (the latter can be produced by LAMMPS directly). If the bonding information is not available, VMD uses a heuristic guess which works reasonably well with biological systems, but can be particularly cumbersome in coarse grained MD or similar model systems. The lmpbonds2vmd.tcl script provides an option to transfer bonding information from a LAMMPS data file into VMD. 1b. Usage. The script defines a new procedure "lmpbondsfromdata". To activate it type at the VMD command prompt: source lmpbonds2vmd.tcl To then build a PSF file for use in subsequent visualizations you can load one just frame of a native LAMMPS trajectory (not binary, not custom!), for example perusing the output from the micelle example. mol new dump.micelle type lammpstrj waitfor all lmpbondsfromdata data.micelle Now you should only see the bonds that actually have bonded interactions. To avoid having to run the script all the time you can save the bonding information in an (incomplete) PSF file. animate write psf micelle.psf In the future you can now load this PSF file first and then the LAMMPS dump file(s) (or a more compact and faster loading DCD or XTC file) with: vmd micelle.psf -lammpstrj dump.micelle 1c. Problems. The LAMMPS data file format is quite flexible and thus not always easy to parse independently from context. As a consequence, the lmpbondsfromdata parser may be confused by your specific setup. 1d. History. First version. 2007, Axel Kohlmeyer akohlmey@cmm.chem.upenn.edu Added a sanity check 03/2008, Axel Kohlmeyer akohlmey@cmm.chem.upenn.edu ------------------------- 2. lmpresid2vmd.tcl - translate residue information from a LAMMPS data file into VMD. 2a. Background. LAMMPS dump files contain information about the (numerical) atom type, but not a molecule or residue id as it is typically used in PSF or PDB files to define subunits of a system. Adding this information can be very helpful for analysis and post-processing of LAMMPS data in VMD. 2b. Usage. The script defines a new procedure "lmpresidfromdata". To activate it type at the VMD command prompt: source lmpresid2vmd.tcl To then add the residue information to a PSF file, see the steps for from item 1 from above and then type into the VMD console. lmpresidfromdata data.micelle To avoid having to run the script all the time you can save the residue information in an (incomplete) PSF file. animate write psf micelle2.psf In the future you can now load this PSF file first and then the LAMMPS dump file(s) (or a more compact and faster loading DCD or XTC file) with: vmd micelle2.psf -lammpstrj dump.micelle You can use the residue information to join bonds split across the periodic boundaries with: pbc join residue -all and then enjoy a nice visualization of the micelle example with VMD. :) 2c. Problems. The LAMMPS data file format is quite flexible and thus not always easy to parse independent from context. As a consequence, the lmpresidfromdata parser may be confused by your specific setup. 2d. History. First version. 2008, Axel Kohlmeyer akohlmey@cmm.chem.upenn.edu ------------------------- 3. lmpname2vmd.tcl - set atom names based on LAMMPS type in VMD. 3a. Background. LAMMPS dump files contain information about the (numerical) atom type, but not atom names like in PSF or PDB files. The names are used in VMD to guess element, radius and (default) coloring. Adding this information can be very helpful to set convenient defaults for visualization of LAMMPS data in VMD. 3b. Usage. The script defines a new procedure "lmptypetoname". To activate it type at the VMD command prompt: source lmpname2vmd.tcl To then add atom name information, e.g., to a PSF file, see the steps for item 1 from above and then type into the VMD console. lmptypetoname "SOL HDR TL1 TL2" To avoid having to run the script all the time you can save the bonding information in an (incomplete) PSF file. animate write psf micelle3.psf In the future you can now load this PSF file first and then the LAMMPS dump file(s) (or a more compact and faster loading DCD or XTC file) with: vmd micelle3.psf -lammpstrj dump.micelle And you'll see that VMD will assign different colors to the atom types. You cat get the previous coloring back by using the "Type" coloring scheme. 3c. Problems. This script assumes the data originates from a LAMMPS dump file and thus the atoms types are numerical starting from 1. If those have been modified by some means, no name will be assigned. 3d. History. First version. 2008, Axel Kohlmeyer akohlmey@cmm.chem.upenn.edu ------------------------- 4. lmpradius2vmd.tcl - set VdW radius based on LAMMPS type in VMD. 4a. Background. The radii used for VDW and derived representations in VMD are guessed from the atom names. This script offers a convenient way to reset them (e.g. by using the sigma parameters from matching LJ interactions). 4b. Usage. The script defines a new procedure "lmptypetoradius". To activate it type at the VMD command prompt: source lmpradius2vmd.tcl To then add atom radius information, see the steps for item 1 from above and then type into the VMD console. lmptypetoradius "1.00 1.00 0.75 0.50" 4c. Problems. This script assumes the data originates from a LAMMPS dump file and thus the atoms types are numerical starting from 1. If those have been modified by some means, no name will be assigned. There is currently no file format that exports the radius information, so this script/command has to be added, e.g., to "saved states" and other visualization scripts. 4d. History. First version. 2008, Axel Kohlmeyer akohlmey@cmm.chem.upenn.edu
2177 次阅读|0 个评论
[转载]Lammps中逐渐加力
motivatedgirl 2014-8-31 14:55
label forloop variable i loop 50 variable F1 equal $i*0.05 variable F2 equal $i*0.05*(-1) fix 1 lo setforce ${F1} 0.0 0.0 fix 2 hi setforce ${F2} 0.0 0.0 dump 3 hi custom 10 dump.myforce id fx run 1000 next i
1476 次阅读|0 个评论
Lammps安装
ywmucn 2013-7-19 19:23
1.相应lib安装 1)lib/atc make -f Makefile.icc 生成 libatc.a 修改 Makefile.lammps 将user-atc_SYSLIB = 一行改为 MKL_PATH=/opt/intel/Compiler/11.1/059/mkl/lib/em64t user-atc_SYSLIB = -Wl,--start-group \$(MKL_PATH)/libmkl_intel_lp64.a \$(MKL_PATH)/libmkl_sequential.a \$(MKL_PATH)/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -limf -lm -L\$(MKL_PATH) \$(MKL_PATH)/libmkl_lapack95_lp64.a 2)lib/awpmd make -f Makefile.openmpi 生成 libawpmd.a 修改 Makefile.lammps,与atc类似。 3)lib/colvars make -f Makefile.g++ 生成 libcolvars.a 4)lib/meam make -f Makefile.lammps.ifort 生成 libmeam.a 修改 Makefile.lammps meam_SYSPATH = 。。 改为 meam_SYSPATH = -L/opt/intel/Compiler/11.1/059/lib/intel64 5)lib/poems make -f Makefile.icc 生成libpoems.a 6) lib/reax make -f Makefile.ifort 生成 libreax.a 修改 Makefile.lammps,修改方式与meam类似。 2.安装包的确定src目录下 执行 make package-status make yes-standard make no-gpu make no-kim make no-voronoi make yes-USER-ATC make yes-USER-AWPMD make yes-USER-COLVARS make yes-USER-EFF make yes-USER-PHONON make yes-USER-REAXC make yes-USER-SPH 3.MAKE/Makefile.openmpi 修改 修改部分如下: 。。。。 MPI_INC = -I/home/chem/chemsoft/openmpi/include MPI_PATH = -L/home/chem/chemsoft/openmpi/lib MPI_LIB = -lmpi 。。。。 FFT_INC = -DFFT_FFTW3 FFT_PATH = -L/usr/local/lib FFT_LIB = /usr/local/lib/libfftw3.a 。。。。。。 JPG_INC = -I/home/chem/source/source.mu/bin/include JPG_PATH = -L/home/chem/source/source.mu/bin/lib JPG_LIB = /home/chem/source/source.mu/bin/lib/libjpeg.a 然后执行 make openmpi 生成 lmp_openmpi 4.tools编译
个人分类: MD|2 次阅读|0 个评论
bk 平阳 compile LAMMPS in Amber 1
chnfirst 2012-4-24 17:13
Instruction how to compile LAMMPS in the amber1 Dear Haining; This instruction is based on the 15Jan2012 version of LAMMPS and our amber1 machine. 1. Download the latest LAMMPS 2. Unzip the file you downloaded. 【自:解压命令 tar -xvf 文件; 而 不是-zxvf。 改于20170507 】 3. go to the library directory, (dir)/lib/ compile the libraries that you want to include in LAMMPS. 3-1. for example, if you want to include ReaxFF into LAMMPS, you should compile it. Go to the reax directory, then type the following: make -f Makefile.ifort 3-2. If the libreax.a file is created, the compile has been done well. 3-3. Open and edit Makefile.lammps. You can refer the following: # Settings that the LAMMPS build will import when this package library is used reax_SYSINC = reax_SYSLIB = -lifcore -lsvml -lompstub -limf reax_SYSPATH = -L/opt/intel/opt/intel/Compiler/11.1/046/lib/intel64 3-4. If you include other packages such as meam, atc, etc. go back to 3-1. 4. go to the main source directory. (dir)/src/ 4-1. Type 'make package-status', then you can see which package will be installed or not. 4-2. Type 'make yes-reax' in order to include the package that you already compiled in the section 3. 4-3. Type 'make package-status' again to check if it does well. 4.4. If you type just 'make' you will see the information. 5. go to the Make directory. (dir)/src/MAKE/ 5-1. rename Makefile.linux into Makefile.(version), for example, Makefile.15Jan12 5-2. open and edit Makefile.15Jan12 as follows CC = mpicxx CCFLAGS = -O DEPFLAGS = -M LINK = mpicxx LINKFLAGS = -O -i-static LIB = -lstdc++ ARCHIVE = ar ARFLAGS = -rc SIZE = size LMP_INC = -DLAMMPS_GZIP MPI_INC = -I/usr/local/mpich-mx-1.2.7..7_i11/include -DMPICH_IGNORE_CXX_SEEK MPI_PATH = -L/usr/local/mpich-mx-1.2.7..7_i11/lib MPI_LIB = -lmpich -lpthread FFT_INC = -I/usr/local/fftw-2.1.5_i10_mx/include -DFFT_FFTW FFT_PATH = -L/usr/local/fftw-2.1.5_i10_mx/lib FFT_LIB = -lfftw 5-3. Do not change any words after this sentences in Makefile. # --------------------------------------------------------------------- # build rules and dependencies # no need to edit this section 6. Now you are ready to install the LAMMPS 6-1. go to (dir)/src 6-2. Type 'make (version name, suffix that you rename in section 5-1.)' make 15Jan12 6-3. If lmp_(version name) is created, you done! Don't forget the details must be changed according to which machine we are going to use. Hope this helps. BK. ------------------------------------------------------- Byung-Hyun Kim Ph. D Candidate Computational Science Center Korea Institute of Science and Technology 39-1 Hawolgok-dong, Seongbuk-gu, Seoul, 136-791, KOREA TEL : +82-2-958-5498 FAX : +82-2-958-5509 Mobile : +82-10-7558-0791 E-mail : bhkim00@kist.re.kr
个人分类: LAMMPS|0 个评论
Fortran program writing *.eam.alloy potential for lammps
热度 4 starbinbin 2012-4-18 16:16
This blog is about a program written by my self for generating the *.eam.alloy file for lammps, which has been finished 2012.04.18. Potential bugs must exist, therefore, advice and suggestion about this program is highly appreciated. !############################################################################################################################# !EAM_Table Program Version 1.0 !Generating the setfl file for eam/alloy potential in lammps !Programmer: Bin Ouyang, McGill University !Supervisor: Jun Song, McGill uUniversity !Department of Mining and Materials Engineering, McGill University !Date: 2012.04.17 !############################################################################################################################# program eam_table implicit none character*50 :: para_file, out_file real :: re(2), fe(2), rou_e(2), arfa(2), beta(2), A(2), B(2), kai(2), lambda(2), Fn0(2), Fn1(2) real :: Fn2(2), Fn3(2), F0(2), F1(2), F2(2), F3(2), ita(2), F_e(2) real :: drho, dr, cutoff, latt_c(2), mass(2) integer :: Nrho, Nr, atom_num, ind(2) character* 50 :: comment(3) character* 7 :: elem(2), latt(2) real,allocatable :: rho(:, :), F(:, :), phi(:, :), radius(:, :) integer :: i, j real :: rou_n(2), rou_0(2) namelist /eam_para/ re, fe, rou_e, arfa, beta, A, B, kai, lambda, Fn0, Fn1, Fn2 , Fn3, F0, F1, F2, F3, ita, F_e namelist /eam_format/ drho, dr, cutoff, latt_c, Nrho, Nr, atom_num, ind, elem, comment, latt, mass do while(1) !display the welcome screen write(*,*)'EAM_Table Program Version 1.0' write(*,*)'=====================================================================' write(*,*)'Generating the setfl format file for eam/alloy potential in lammps' write(*,*)'Programmer: Bin Ouyang, McGill university' write(*,*)'Supervisor: Jun Song, McGill university' write(*,*)'Department of Mining and Materials Engineering, McGill University' write(*,*)'Date: 2012.04.17' write(*,*)'======================================================================' write(*,*)' ' write(*,*)'Please enter the name of eam parameter file' read(*,*) para_file !reading the parameter file of eam potential open(1,file = para_file,status = 'old') read(1,eam_para) read(1,eam_format) close(1) allocate(rho(Nrho, atom_num), F(Nrho, atom_num), radius(Nrho, atom_num)) allocate(phi(Nrho, atom_num + 1)) write(*,*)' ' write(*,*)'Reading parameter file successfully!' write(*,*)'Please enter the name of output file' write(*,*)'Format: ***.eam.alloy' read(*,*)out_file write(*,*)' ' !Calculating the required table of parameters for EAM do i = 1, Nrho radius(i, 1) = (i-1) * dr radius(i, 2) = radius(i, 1) enddo !discrete the radius do i = 1, 2 rho(:, i) = fe(i) * exp(-1 * beta(i) * (radius(:, i) / re(i) - 1)) / (1 + (radius(:, i) / re(i) - lambda(i)) ** 20) enddo !calculating the density of electonic rou_n = rou_e * 0.85 rou_0 = rou_e * 1.15 do i = 1, 2 do j = 1, Nr if(rho(j, i) rou_n(i))then F(j, i) = Fn0(i) + Fn1(i) * (rho(j, i) / 0.85 / rou_e(i)) + Fn2(i) * (rho(j, i) / 0.85 / rou_e(i)) ** 2 + Fn3(i) * (rho(j, i) / 0.85 / rou_e(i)) ** 3 elseif(rho(j, i) rou_0(i))then F(j, i) = F0(i) + F1(i) * (rho(j, i) / rou_e(i)) + F2(i) * (rho(j, i) / rou_e(i)) ** 2 + F3(i) * (rho(j, i) / rou_e(i)) ** 3 else F(j, i) = F_e(i) * (1 - ita(i) * log(rho(j, i) / rou_e(i))) * (rho(j, i) / rou_e(i)) ** ita(i) endif enddo enddo do i = 1, Nr phi(i, 1) = A(1) * exp(arfa(1) * (1 - radius(i,1) / re(1))) / (1 + (radius(i,1) / re(1) - kai(1)) ** 20) enddo do i = 1, Nr phi(i, 3) = A(2) * exp(arfa(2) * (1 - radius(2,2) / re(2))) / (1 + (radius(i,2) / re(2) - kai(2)) ** 20) enddo do i = 1, Nr phi(i, 2) = 0.5 * (rho(i, 1) / rho(i, 2) * phi(i, 3) + rho(i, 2) / rho(i, 1) * phi(i, 1)) enddo !End of calculation !Wrting the eam/alloy file open(2, file = out_file) write(2,*) comment(1) write(2,*) comment(2) write(2,*) comment(3) write(2,*) atom_num, ' ', elem(1), elem(2) write(2,*) Nrho, drho, Nr, dr, cutoff write(2,*) ind(1), mass(1), latt_c(1), latt(1) do i = 1, Nrho / 5 write(2,*) F(5 * i - 4, 1), F(5 * i - 3, 1), F(5 * i - 2, 1), F(5 * i - 1, 1), F(5 * i, 1) enddo do i = 1, Nr / 5 write(2,*) rho(5 * i - 4, 1), rho(5 * i - 3, 1), rho(5 * i - 2, 1), rho(5 * i - 1, 1), rho(5 * i, 1) enddo write(2,*) ind(2), mass(2), latt_c(2), latt(2) do i = 1, Nrho / 5 write(2,*) F(5 * i - 4, 2), F(5 * i - 3, 2), F(5 * i - 2, 2), F(5 * i - 1, 2), F(5 * i, 2) enddo do i = 1, Nr / 5 write(2,*) rho(5 * i - 4, 2), rho(5 * i - 3, 2), rho(5 * i - 2, 2), rho(5 * i - 1, 2), rho(5 * i, 2) enddo do i = 1, Nr / 5 write(2,*) phi(5 * i - 4, 1), phi(5 * i - 3, 1), phi(5 * i - 2, 1), phi(5 * i - 1, 1), phi(5 * i, 1) enddo do i = 1, Nr / 5 write(2,*) phi(5 * i - 4, 2), phi(5 * i - 3, 2), phi(5 * i - 2, 2), phi(5 * i - 1, 2), phi(5 * i, 2) enddo do i = 1, Nr / 5 write(2,*) phi(5 * i - 4, 3), phi(5 * i - 3, 3), phi(5 * i - 2, 3), phi(5 * i - 1, 3), phi(5 * i, 3) enddo close(2) write(*,*) 'The eam potential file has been output succesfully!' deallocate(rho, F, radius, phi) enddo end program
个人分类: Computational Materials Science|10011 次阅读|5 个评论
[转载]lammps模拟时输入文件命令中文详解
swx0789 2011-7-11 16:42
Commands 描述了lammps输入文件的格式和在定义lammps模拟所需要的命令. 1.1 LAMMPS input script 我们用lammps做分子动力学模拟, 需要一个输入文件. lammps在执行计算的时候, 从这个文本文件中逐行读入命令. 大多数情况, lammps输入文件中各个命令的顺序并不是很重要. 但是你要注意以下几点: (1)lammps并不是将你的输入文件全部读入之后才开始进行计算的, 或者说, 每条命令在它被读入之后就会起作用了. 注意, 下面两组命令的执行效果是不相同的. timestep 0.5 run 100 run 100 和 run 100 timestep 0.5 run 100 (2)有些命令只有在另一些命令已经被定义的情况下才有效. 例如如果你要设定一组原子的温度, 那么用group命令定义哪些原子属于这个组才行. (3)还有一种情况就是: 命令B要用到命A设置的一些数值, 这样你也不能颠倒这两个命令的顺序. 每个命令的详细介绍中的Restrictions部分会说明要使用该命令定义的时候哪些命令必须要被预先定义. 如果你的输入文件书写的格式有问题, lammps在执行的时候会提示ERROR或者WARNING , 出现类似信息时, 你可以到手册的第九章中查询原因. 1.2 Parsing rules 输入文件中的每一非空行都被认为是一条命令. lammps中命令的书写是对大小写敏感的, 不过一般的命令和参数都是小写的, 大写字母用于极少数的情况. (1)命令行后的 表示这一行跟下一行是同一条命令. 这一点跟FORTRAN很像. (2)命令行最开始的 # 表示这一行在执行过程中被忽略, 你可以用它来写注释. (3) $ 是跟声明变量有关系的, 我暂时还没用到过, 具体请参阅variable命令的详细介绍. (4)命令行被tabs, spaces间隔成各个“words”, 注意这里的“words”可以包含字母、数字、下划线、或标点符号. (5)一行中第一个词是命令名, 后续的词是相关的参数. (6)双引号内的文字空格被整体地当作一个参数, 其中的 # 或 $ 就没有前面说的作用了. 1.3 Input script structure lammps的输入文件一般分为4个部分Initialization, Atom definition, Settings, Run a simulation 后面的两个部分可以按照需要多次重复. Remember that almost all the commands need only be used if a non-default value is desired. (1) Initialization 在你的模拟体系定义之前, 一些参数必须要被设置.相关的命令有:units, dimension, newton, processors, boundary, atom_style, atom_modify. units: 选择单位系统, lammps提供了lj、real、metal三种单位系统 dimension: 2d模拟还是3d模拟, 默认是3d boundary: 边界条件:周期性边界or自由边界 atom_style: 定义你的模拟体系中的原子属性, 注意这个style要区分后面设置力场参数时命令里提到的atom type 还有, 这些命令告诉lammps在你的模拟中使用何种力场: pair_style, bond_style, angle_style, dihedral_style, improper_style. (2) Atom definition lammps提供3种方式定义原子: ① 通过read_data或read_restart命令从data或restart文件读入, 这些文件可以包含分子拓扑结构信息. ② 按照晶格的方式创建原子(不包含分子拓扑信息), 你会用到这几个命令: lattice, region, create_box, create_atoms. ③ 已经设置好的原子可以用replicate命令复制以生成一个更大规模的模拟体系. (3)Settings 原子和分子的拓扑信息定义好后, 你要制定一系列的设置: 力场系数、模拟参数、输出选项 等等. 力场系数可以通过这些命令定义: pair_coeff, bond_coeff, angle_coeff, dihedral_coeff, improper_coeff, kspace_style, dielectric, special_bonds. 注意, 其实力场系数也可以在data文件中制定, 详见read_data命令介绍. 各种模拟参数由这些命令设置: neighbor, neigh_modify, group, timestep, reset_timestep, run_style, min_style, min_modify. 我觉得fix命令是lammps中很重要的一个命令, 它包括很多子命令, 可以施加一系列的边界条件、时间积分、诊断选项等等. 模拟过程中通过下面的命令制定lammps进行各种计算: compute, compute_modify, variable. 输出选项由thermo, dump, restart命令设置. (4)Run a simulation 使用run命令开始一个分子动力学模拟, 用minimize命令来实施能量最小化(molecular statics), 使用temper命令来进行parallel tempering(replica-exchange) simulation. 1.4 Commands listed by category 这一节分门别类地列出了lammps的所有命令. 注意有些命令的有些选项是特定的lammps package的一部分, 也就是说只有在编译lammps的时候包括了这些packages, 这些命令才能被使用. 默认情况下编译lammps并不包括所有的packages. 这些依赖关系在相关命令的详细介绍中Restrictions部分中列出了. Initialization: atom_modify, atom_style, boundary, dimension, newton, processors, units Atom definition: create_atoms, create_box, lattice, read_data, read_restart, region, replicate Force fields: angle_coeff, angle_style, bond_coeff, bond_style, dielectric, dihedral_coeff, dihedral_style, improper_coeff, improper_style, kspace_modify, kspace_style, pair_coeff, pair_modify, pair_style, pair_write, special_bonds Settings: communicate, dipole, group, mass, min_modify, min_style, neigh_modify, neighbor, reset_timestep, run_style, set, shape, timestep, velocity Fixes: fix, fix_modify, unfix Computes: compute, compute_modify, uncompute Output: dump, dump_modify, restart, thermo, thermo_modify, thermo_style, undump, write_restart Actions: delete_atoms, delete_bonds, displace_atoms, displace_box, minimize, run, temper Miscellaneous: clear, echo, if, include, jump, label, log, next, print, shell, variable 作者:御剑江湖 一、各种文件的介绍: 1 in file:建立该文件以便程序的写入 2 log file:写入状态信息(if the switch is used?) 3 screen file决定结果的是否进行屏幕输出 4 var name file 定义一个变量,name指变量名,可为字母也可为字符串,形式$x / $ {abc} 二、屏幕输出: 结果显示在屏幕上,同时在log file 中。开始前LAMMPS计算出所需的存储空间,运行中每隔几个时步显示一次热力学状态,直至输出最终状态。 Loop time of 49.002 on 2 procs for 2004 atoms 该部分显示了几个大类的计算时间 Pair time (%) = 35.0495 (71.5267) Bond time (%) = 0.092046 (0.187841) Kspce time (%) = 6.42073 (13.103) Neigh time (%) = 2.73485 (5.5811) Comm time (%) = 1.50291 (3.06703) Outpt time (%) = 0.013799 (0.0281601) Other time (%) = 2.13669 (4.36041) Nlocal: 1002 ave, 1015 max, 989 min 每个处理器中特定原子的数目 Histogram: 1 0 0 0 0 0 0 0 0 1 Nghost: 8720 ave, 8724 max, 8716 min Histogram: 1 0 0 0 0 0 0 0 0 1 Neighs: 354141 ave, 361422 max, 346860 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 708282 Ave neighs/atom = 353.434 Ave special neighs/atom = 2.34032 Number of reneighborings = 42 Dangerous reneighborings = 2 当运用了能量最小化命令进行能量最小化时,还将出现如下所示语句: Minimization stats: E initial, next−to−last, final = −0.895962 −2.94193 −2.94342(显示初终能量以及next-to-last 循环的能量) Gradient 2−norm init/final= 1920.78 20.9992(给出能量梯度,即所有原子的受力) Gradient inf−norm init/final= 304.283 9.61216 2-form是力向量的长度,inf-form是最大构成? Iterations = 36 循环次数 Force evaluations = 177 对力进行评定的次数 当程序中有kspace_style long−range Coulombics solve,将会显示以下语句: FFT time (% of Kspce) = 0.200313 (8.34477)完成3d FFT计算的时间及在总时间中占的百分比 FFT Gflps 3d 1d−only = 2.31074 9.19989 每秒执行的浮点指令次数(flops)为5N*log(2N),N为3维晶体中的节点数 The 3d rate is with communication; the 1d rate iswithout (just the 1d FFTs). 在GPU(图形处理单元)上的运行 三、指令系统介绍(*) 一般来说指令的顺序并不重要,胆在以下几种情况中必须注意: 1 LAMMPS并不是全部读完所有指令才执行,而是读一行执行一次,因此下面的两组语句是不同的: timestep 0.5 以下的两个模拟其步长均为0.5 fmsec run 100 run 100 run 100 第一个模拟采用缺省值步长为1 fmsec timestep 0.5 run 100 第二个采用步长为0.5 fmsec 2 某些指令只在其他指令之后才生效,如要得到系统温度必须先进行各种定义 3 若A指令在B之前,B可以引用A定义的变量 四、语法规则 在LAMMPS中要区分大小写,一般指令名称用小写字母,文件及用户定义ID Strings 用大写。 LAMMPS对每行语句的语法要求如下: 1 当语句太长一行放不下时,在语句一行结束的时候输入字符 “” 表示下一行的语句接着上一行继续。 2 在#之后输入的字符认为是评论语句,是无用的,但有例外 3 紧跟在$后定义变量(之前讲过) 4 单词间用空格隔开 5 第一个词为指令名,接下来的字母全都为自变量(arguments) 6 If you want text with spaces to be treated as a single argument, it can be enclosed in double quotes 五、输入的语句结构 一个普通的LAMMPS程序通常由以下四部分组成: 1 初始化 2 原子定义 3 设定 4 进行模拟 初始化阶段:设定所需参数,相关各项命令,引入所需的力场参数 相关命令介绍: 1units command 语句形式: units style · style = lj or real or metal or si or cgs or electron Examples: units metal units lj 该语句定义了单元类型,除了LJ类型,其他物理常量来自于某网,定义实际单元的热能=4.184J。 而在LJ类型中,所有变量都是无单位的(参考陈义龙的论文) 实际量换算成简化单位量有系列公式。 以下列出了换算关系及其它各种类型中所使用的标准单位。 This command cannot be used after the simulation box is defined by a read_data or create_box command. 缺省状态默认为LJ类型 2 语句形式: dimension N · N = 2 or 3 例如:dimension 2 一般缺省为3d模拟,2d模拟的话要在建立simulation box之前进行设定(其余省略) COMMANDS LISTED BY CATEGORY 以下列出的LAMMPS命令以按类分好,其分类情况如下: 初始化指令:atom_modify, atom_style, boundary, dimension, newton, processors, units 原子定义指令:create_atoms, create_box, lattice, read_data, read_restart, region, replicate 力场指令:angle_coeff, angle_style, bond_coeff, bond_style, dielectric, dihedral_coeff, dihedral_style, improper_coeff, improper_style, kspace_modify, kspace_style, pair_coeff, pair_modify, pair_style, pair_write, special_bonds 设定指令:communicate, dipole, group, mass, min_modify, min_style, neigh_modify, neighbor, reset_timestep, run_style, set, shape, timestep, velocity FIXESfix, fix_modify, unfix Computes: compute, compute_modify, uncompute Output: dump, dump_modify, restart, thermo, thermo_modify, thermo_style, undump, write_restart Actions: delete_atoms, delete_bonds, displace_atoms, displace_box, minimize, prd, run, temper Miscellaneous: clear, echo, if, include, jump, label, log, next, print, shell, variable 六 how to discussions() 重启一个模拟。有3种方法继续长的LAMMPS程序。在同一个程序中可多次使用运行命令。每次运行都会接着上一条运行指令(run command)进行。Binary file使用restart command将binary files存入硬盘中,之后用read-restart命令可将binary file读出。或者可转为text data files,经read-data命令读出。restart2data 涉及到的命令: 1 run command syntax run N keyword values……(N= # of timesteps; zero or more keyword/value pairs may be appended; keyword= upto or start or stop or pre or post or every) Examples: run 10000# 运行10000步;N=0意味着直接把现系统的热力学值输出 run 1000000 upto# 从当前开始一直运行至upto所指定的数值(该语句意为运行至10000000步止) run 100 start 0 stop 1000 run 1000 pre no post yes run 100000 start 0 stop 1000000 every 1000 "print Protein Rg = $r" run 100000 every 1000 NULL (补充说明 fix 指令: Syntax: fix ID group−ID style args · ID = user−assigned name for the fixID是用户自己定义的名字,便于通过fix定义 · group−ID = ID of the group of atoms to apply the fix to · style = one of a long list of possible style names (see below) · args = arguments used by a particular style Examples: 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指令的用途是对一组原子进行定义,可以用于更新原子的位置、速度、控制温度、加常力、施加边界条件等。当两个或更多fix在同一过程中作用时,根据程序中的先后顺序执行fix指令。Fix指令可通过unfix指令来消除,形式为unfix fix-ID) 对于run 100 start 0 stop 1000 这个语句来说,主要与fix语句配合使用。 fix 1 all nvt 200.0 300.0 1.0 这两个指令的功能是在接下来的1000步运行中,每 run 1000 步的温度都要从200度升到300度 fix 1 all nvt 200.0 300.0 1.0 对于左侧的一组指令,温度随着从0到10000步的执行 run 1000 start 0 stop 10000 逐渐升至300.0度,是一个发生在整个过程的渐变行为 run 1000 start 0 stop 10000 ... run 1000 start 0 stop 10000(共10个) 至于pre and post大概是这样的,pre no 的意思是跳过初始设定阶段,如果以下的计算是承接之前运行命令的话(意思是采用之前的参数)但是如果该run指令是第一个指令是,该设定会被忽略。 注意:当两次运行指令之间使用了修改设定值的命令时(比如fix等),pre no是不允许的,必须重新设定,否则报错 若是post no,则跳过full timing summary, 输出one-line summary timing Every 的作用是将一个run分成一系列较短的runs variable q equal x run 6000 every 2000 "print Coord = $q" 每运行2000步输出一次某原子的x坐标值 Default: The option defaults are start = the current timestep, stop = current timestep + N, pre = yes, and post = yes. 在run语句中的缺省值 2 restart command (将binary files存入硬盘)restart文件是lammps的一种输出文件形式 Syntax: restart 0 N = write a restart file every this many timesteps restart N root root = filename to which timestep # is appended restart N file1 file file1,file2 = two full filenames, toggle between them when writing file Examples: restart 0 restart 1000 poly.restart restart 1000 restart.*.equil restart 10000 poly.%.1 poly.%.2 restart 0 意味着不输出restart files。与dump文件一样,restart不能包含两个wild card characters(即通配符)。若filename中含有*号,则它会被目前的值所代替(该情况只在仅有一个filename的情况下成立)
个人分类: 知识储备|9255 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-18 02:48

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部