24小时热门版块排行榜    

CyRhmU.jpeg
查看: 5763  |  回复: 15
本帖产生 2 个 模拟EPI ,点击这里进行查看
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

qphll

金虫 (正式写手)

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
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
Life, Love, Laugh.
6楼2010-12-10 03:29:50
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

qphll

金虫 (正式写手)

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
ghcacj(金币+10, 模拟EPI+1): 谢谢 2011-02-24 13:30:03
好久没有做什么更新, 这两个月来在Lammps, 尤其是reaxff上面花了不少时间, 写了不少小程序, 现在基本到一个尾声. 很多程序写的时候一鼓作气, 没有很好地加入备注, 今天花了一整天的时间注释了一些程序的用途. 有可能会慢慢发出来.

这是才写下的一段话, 是对于lammps+reax中最重要两个输出文件的处理意见. 程序本身对别人没有什么帮助, 但是这段备注我想和大家分享.


! The "REAXFRAG" code needs two files:
! (1) coordinate table <---- "molfra.configure" <----- from Lammps "molfra" dump file, prepared by this code
! (2) bond order table <---- "bonds.connect"    <---- directly from Lammps 'fix' dump
!
! The corresponding commamds in "in.reaxff" file look like:
!
! "dump    1  all custom 10 molfra id type q x y z vx vy vz mass"
! "dump_modify 1 sort id"   <---- This "sort" option is very important.
!
! "fix 2 all reax/bonds 10 bonds.connect"
!
! Some further explanations to the "molfra" and "bonds.connect" files.
!
! Each frame of "molfra" is made up of the head part, 9 line and body part, N line (N=number of atoms of the system).
! So an output of "m" MD iterations will produce (m+1)*(N+9) lines in "molfra".
!
! Each frame of "bonds.connect" file has head part, 7 line, body part, N line (N=number of atoms of the system)
! and tail part, 1 line, which contains a "#" sign as the ending remark.
! So an output of "m" MD iterations will produce (m+1)*(N+8) lines in "molfra".
!
! "m+1" comes from the fact that Lammps dose output the t=0 image.
!
!!!!!!!!!!!!
! IT IS VERY IMPORTANT that you use same output frequency for all the dumps in Lammps.
! You also need to 'sort' the output so that atoms in different dump files are in good match.
! That explains why I prefer to seprate the minimization part from MD runs.
!!!!!!!!!!!!
!
! The other input is the number of frames in 'molfra', which is the number of iterations
! you request in "in.reaxff" file, such as the following:
!
! "run 1200000"
!
!
! Required input:
! "molfra" from Lammps & number of frames in the molfra file
!
! Please always double check to make sure that is what you want to have.
! @ QPHLL, Feb.23,2010
Life, Love, Laugh.
9楼2011-02-24 07:13:34
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 qphll 的主题更新
普通表情 高级回复(可上传附件)
信息提示
请填处理意见