| 查看: 5772 | 回复: 15 | ||||||||||||
| 本帖产生 2 个 模拟EPI ,点击这里进行查看 | ||||||||||||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | ||||||||||||
qphll金虫 (正式写手)
|
[交流]
【分享】尝试lammps中, 分享中...已有9人参与
|
|||||||||||
|
Lesson 1 Loop inside Lammps input script 想要尝试在lammps的input script里面做循环, 结果因为一个小问题, 捣鼓了我几个小时, 这才完全通过测试. 分享一下. (1) input script里面的循环块 include tempfile include tempfile2 variable i loop 10 label loopa fix 2 all nvt temp ${mytemp} ${mytemp2} 100.0 run 200 unfix 2 next mytemp next mytemp2 next i jump SELF loopa 这个的SELF是让程序执行到这里, 跳回自己, 然后从标签 loopa开始执行. 当然loopa是随便取的, 你可以用CHN来做label. 另外, 在某些情况下, 如果要让c++ rewind, 那么最好在执行脚本里面这样写: lmp -in script 而不是 lmp < script 否则, 你人品不好的时候, 会出问题, 哈哈. (2) tempfile 和 tempfile2是在同目录下的另外两个文件. tempfile的文件内容是: variable mytemp index 500.0 700.0 900.0 1100.0 1300.0 1500.0 1700.0 1900.0 2100.0 2300.0 注意, 只有一行! 至于lammps能读多长的一行, 我还没有测试. tempfile2的文件内容, 也是一行: variable mytemp2 index 700.0 900.0 1100.0 1300.0 1500.0 1700.0 1900.0 2100.0 2300.0 2500.0 折腾我的问题是, 我原先在这两个tempfile文件中, 数值之间用逗号分隔, 但是事实上, 是需要用空格分隔的. (3) 如果你需要做的循环不是很多, 那么不需要额外准备tempfile 和 tempfile2文件. 而只是需要在 input script中这样做: variable mytemp index 500.0 700.0 900.0 1100.0 1300.0 1500.0 1700.0 1900.0 2100.0 2300.0 #variable mytemp2 index 700.0 900.0 1100.0 1300.0 1500.0 1700.0 1900.0 2100.0 2300.0 2500.0 variable i loop 10 label loopa fix 2 all nvt temp ${mytemp} ${mytemp2} 100.0 run 200 unfix 2 next mytemp next mytemp2 next i jump SELF loopa 当然, 这里不需要原先的这两句 include语句了. 总结一下你需要熟悉的命令: variable, include, jume, next End of Lesson 1. ENJOY. [ Last edited by qphll on 2010-12-3 at 11:54 ] |
» 收录本帖的淘帖专辑推荐
资源收集 | 材料计算模拟实用技巧 | 分子模拟 | MD分子动力学 |
我学习计算的一些帖子 | 分子动力学 | 量化 | LAMMPS |
关于Lammps |
» 本帖已获得的红花(最新10朵)
» 猜你喜欢
2025冷门绝学什么时候出结果
已经有4人回复
真诚求助:手里的省社科项目结项要求主持人一篇中文核心,有什么渠道能发核心吗
已经有8人回复
寻求一种能扛住强氧化性腐蚀性的容器密封件
已经有5人回复
论文投稿,期刊推荐
已经有6人回复
请问哪里可以有青B申请的本子可以借鉴一下。
已经有4人回复
孩子确诊有中度注意力缺陷
已经有14人回复
请问下大家为什么这个铃木偶联几乎不反应呢
已经有5人回复
请问有评职称,把科研教学业绩算分排序的高校吗
已经有5人回复
天津工业大学郑柳春团队欢迎化学化工、高分子化学或有机合成方向的博士生和硕士生加入
已经有4人回复
康复大学泰山学者周祺惠团队招收博士研究生
已经有6人回复
» 本主题相关价值贴推荐,对您同样有帮助:
在Lammps中安装xmovie工具时,Makefile文件怎么修改X库路径
已经有3人回复
lammps中固定键长
已经有4人回复
【求助】lammps安装过程中,在安装fftw的过程中遇到问题
已经有8人回复
【讨论】想学lammps是否应该先学习C++
已经有28人回复
【讨论】lammps-怪异的group温度
已经有9人回复
【讨论】lammps里的boundary的位置能够随意更改?
已经有14人回复
【讨论】lammps中利用velocity命令无法控制住速度问题
已经有11人回复
【求助】lammps中多元化合物的晶格创建问题
已经有14人回复

qphll
金虫 (正式写手)
- 模拟EPI: 10
- 应助: 18 (小学生)
- 金币: 2708.7
- 散金: 2294
- 红花: 8
- 帖子: 554
- 在线: 227.1小时
- 虫号: 89654
- 注册: 2005-08-29
- 性别: GG
- 专业: 碳素材料与超硬材料
★ ★ ★ ★ ★ ★ ★ ★ ★ ★
ghcacj(金币+10, 模拟EPI+1):谢谢 2010-12-10 10:41:17
ghcacj(金币+10, 模拟EPI+1):谢谢 2010-12-10 10:41:17
|
更新一下, 稍微修改了一下前楼的程序. 现在如果在计算中有发生过反应, 那么分析程序会将那部分信息输出到另外的一个文件中. !# DEC.9, 2010 !# QPHLL !# www.muchong.com !# !# This is a program to read the output from 'fix reax/bond', TPRD, Lammps !# The output is saved into the file "bonds.connect", where each image is divided !# into three parts: !# !# (1) Head, 7 Lines; !# (2) Body, No._of_atom Lines; !# (3) Tail, 1 Line !# !# The total number of images is related with the output frequence and number of iterations. !# In this case, it is "number of iteration+1". !# !# Each line in Body part is made up of the following parameters: !# id, type, nb, id_1, id_2, ... id_nb, mol, bo_1, bo_2, ... bo_nb, abo, nlp, q !# abo = atomic bond order !# nlp = number of lone pairs !# q = atomic charge !# !# PLEASE DOUBLE CHECK YOUR OWN LAMMPS INPUT SCRIPT & OUTPUT AND MAKE CORRESPONDING CHSNGES program main implicit none integer I, J, K, L integer image, natom integer headline, tailline integer id, atype, nb, bd1, bd2, bd3, bd4, mol double precision bo1, bo2, bo3, bo4, abo, nlp, q open (unit=10, file='bonds.connect') open (unit=20, file='N129.txt', status='unknown') open (unit=21, file='N133.txt', status='unknown') open (unit=22, file='N137.txt', status='unknown') open (unit=23, file='N141.txt', status='unknown') open (unit=24, file='N145.txt', status='unknown') open (unit=25, file='N149.txt', status='unknown') open (unit=26, file='N153.txt', status='unknown') open (unit=27, file='N157.txt', status='unknown') open (unit=30, file='reactionRecord.txt', status='unknown') !# Make changes accordingly. image = 2000 headline = 7 tailline = 1 natom = 160 do I = 1, image+1 ! Skip the head part do J = 1, headline read(10,*) end do ! Each image has 'natom' lines do K = 1, natom ! read in the first three number each line to determine: ! (1) what type of atom it is, atype ! the correspondence in Lammps: 1-C, 2-H, 3-O, 4-N, 5-S ! (2) how many bonds it has, nb ! this 'nb' determines the following bond_link information & bond_order paramaters of the same line read(10,*) id, atype, nb ! TEST ! write(*,*) id, atype, nb if (atype .eq. 4) then backspace 10 ! Should have some easier way to replace this "IF", I am just toooo lazy. ! Thanks to the fact that the maximum number of bonds is 4. ^-^ !??? is it possible that nb = 0 ??? KEEP THAT IN MIND. if (nb.eq.0) then read(10,*) id, atype, nb, mol, abo, nlp, q if (id .eq. 129) then write(20, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 133) then write(21, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 137) then write(22, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 141) then write(23, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 145) then write(24, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 149) then write(25, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 153) then write(26, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 157) then write(27, 200) id, atype, nb, mol, abo, nlp, q 200 format(4I4, 3f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 300) I, id, atype, nb, mol, abo, nlp, q 300 format(5I4, 3f14.3) elseif (nb.eq.1) then read(10,*) id, atype, nb, bd1, mol, bo1, abo, nlp, q if (id .eq. 129) then write(20, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 133) then write(21, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 137) then write(22, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 141) then write(23, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 145) then write(24, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 149) then write(25, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 153) then write(26, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 157) then write(27, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q 201 format(5I4, 4f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 301) I, id, atype, nb, bd1, mol, bo1, abo, nlp, q 301 format(6I4, 4f14.3) elseif (nb.eq.2) then read(10,*) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q if (id .eq. 129) then write(20, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 133) then write(21, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 137) then write(22, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 141) then write(23, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 145) then write(24, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 149) then write(25, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 153) then write(26, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 157) then write(27, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q 202 format(6I4, 5f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 302) I, id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q 302 format(7I4, 5f14.3) elseif (nb.eq.3) then read(10,*) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q if (id .eq. 129) then write(20, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 133) then write(21, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 137) then write(22, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 141) then write(23, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 145) then write(24, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 149) then write(25, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 153) then write(26, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bd3, abo, nlp, q elseif (id .eq. 157) then write(27, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q 203 format(7I4, 6f14.3) endif elseif (nb.eq.4) then read(10,*) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q if (id .eq. 129) then write(20, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 133) then write(21, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 137) then write(22, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 141) then write(23, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 145) then write(24, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 149) then write(25, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 153) then write(26, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bd3, bo4, abo, nlp, q elseif (id .eq. 157) then write(27, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q 204 format(8I4, 7f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 304) I, id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q 304 format(9I4, 7f14.3) ! Corresponding to "if (nb.eq.0) then " endif ! Corresponding to "if (atype .eq. 4) then" endif enddo do L =1,tailline read(10,*) enddo enddo end program main |

6楼2010-12-10 03:29:50
qphll
金虫 (正式写手)
- 模拟EPI: 10
- 应助: 18 (小学生)
- 金币: 2708.7
- 散金: 2294
- 红花: 8
- 帖子: 554
- 在线: 227.1小时
- 虫号: 89654
- 注册: 2005-08-29
- 性别: GG
- 专业: 碳素材料与超硬材料
★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
ghcacj(金币+20):谢谢 2010-12-04 17:09:24
ghcacj(金币+20):谢谢 2010-12-04 17:09:24

2楼2010-12-04 15:07:09
sg18408926
至尊木虫 (著名写手)
- 应助: 0 (幼儿园)
- 金币: 10945.9
- 散金: 246
- 红花: 1
- 帖子: 1075
- 在线: 431.4小时
- 虫号: 727956
- 注册: 2009-03-21
- 性别: GG
- 专业: 凝聚态物性 II :电子结构
3楼2010-12-04 17:27:08
qphll
金虫 (正式写手)
- 模拟EPI: 10
- 应助: 18 (小学生)
- 金币: 2708.7
- 散金: 2294
- 红花: 8
- 帖子: 554
- 在线: 227.1小时
- 虫号: 89654
- 注册: 2005-08-29
- 性别: GG
- 专业: 碳素材料与超硬材料
★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
ghcacj(金币+20):谢谢 2010-12-10 10:40:58
ghcacj(金币+20):谢谢 2010-12-10 10:40:58

4楼2010-12-07 23:19:38













回复此楼
fly771125








