diff --git a/tools/lmp2cfg/README.txt b/tools/lmp2cfg/README.txt index fca8009cd9..eab59ee8cf 100755 --- a/tools/lmp2cfg/README.txt +++ b/tools/lmp2cfg/README.txt @@ -40,6 +40,7 @@ You need to create a user input file. In the examples folder you will find an example input script, LAMMPS dump file, and the correct .cfg output. The input script reads like this: +2898 #total number of atoms in system (may be more than in dump) 7 #number of atom types in your LAMMPS file 'dump.atom' #name of the LAMMPS dump file, you need the ' ' 1 #first frame diff --git a/tools/lmp2cfg/examples/00001.cfg b/tools/lmp2cfg/examples/00001.cfg index 2c4d0250b5..5f2f78237b 100644 --- a/tools/lmp2cfg/examples/00001.cfg +++ b/tools/lmp2cfg/examples/00001.cfg @@ -1,7 +1,7 @@ Number of particles = 2898 # -A = 1.5 Angstrom +A = 1.0 Angstrom # H0(1,1) = 26.05200 A diff --git a/tools/lmp2cfg/examples/00002.cfg b/tools/lmp2cfg/examples/00002.cfg index f311cdda0b..69f3e4ff5b 100644 --- a/tools/lmp2cfg/examples/00002.cfg +++ b/tools/lmp2cfg/examples/00002.cfg @@ -1,7 +1,7 @@ Number of particles = 2898 # -A = 1.5 Angstrom +A = 1.0 Angstrom # H0(1,1) = 26.05200 A diff --git a/tools/lmp2cfg/examples/lmp2cfg_inp.txt b/tools/lmp2cfg/examples/lmp2cfg_inp.txt index cd304bb509..9254f6993d 100755 --- a/tools/lmp2cfg/examples/lmp2cfg_inp.txt +++ b/tools/lmp2cfg/examples/lmp2cfg_inp.txt @@ -1,3 +1,4 @@ +2898 7 'dump.atom' 1 diff --git a/tools/lmp2cfg/lmp2cfg.f b/tools/lmp2cfg/lmp2cfg.f index 8945cefa70..80071f53db 100755 --- a/tools/lmp2cfg/lmp2cfg.f +++ b/tools/lmp2cfg/lmp2cfg.f @@ -1,184 +1,164 @@ -*23456789|123456789|123456789|123456789|123456789|123456789|123456789|12 -c---------------------------------------------------------------------- - program lammps to cfg -c---------------------------------------------------------------------- -*Programming by Jeff Greathouse and Ara Kooser -*Version 1.0 9/1/04 -*Sandia National Labs -*Converts LAMMPS atom dump to .cfg files for AtomEye -*This program is provided as is. Please see the README file. -c---------------------------------------------------------------------- - implicit real*8 (a-h,o-z) - - character*12 inhist,snapshot - character*4 fftype(100),name,ciframe - - integer natom,iatom,itype(50000),q - integer atype(99),itycon,ntype,mass(99) - - dimension x(50000),y(50000),z(50000) - dimension amass(99) - - -c-------Reads in the user input file------------------------------- - - read(*,*) ntype - read(*,*) inhist - read(*,*) iframe1 - read(*,*) iframe2 -c write(*,*) ntype -c write(*,*) inhist - do 1, i=1, ntype - - read(*,*) atype(i) - read(*,*) amass(i) - mass(i)=anint(amass(i)) - read(*,*) fftype(i) - - -c write(*,*) atype(i) -c write(*,*) amass(i) -c write(*,*) fftype(i) - 1 continue - -c-------Lammps output file is 9, reads in lmps header-------------- - - name=inhist(1:4) - open(9,file=inhist,status='old',form='formatted') -c open(2,status='new',form='formatted') - - - iatom=0 - iframe=0 - jframe=0 - -c--------------------------------------------------------------------- -c----------This begins the frame by frame reading section------------- - - 9999 continue - - read(9,*,end=999) - read(9,*,end=999) - read(9,*,end=999) - read(9,*,end=999) natom - read(9,*,end=999) - read(9,*,end=999) xlower,xupper - read(9,*,end=999) ylower,yupper - read(9,*,end=999) zlower,zupper - read(9,*,end=999) - 50 format(2f12.5) - xcell=xupper-xlower - ycell=yupper-ylower - zcell=zupper-zlower - - - - - 1000 format(1x,i5,1x,i2,3f9.5) - - - - - - - - do 440 j=1,natom - 420 read(9,*,end=999)iatom,itype(iatom),x(iatom),y(iatom),z(iatom) - - -*23456789|123456789|123456789|123456789|123456789|123456789|123456789|12 - - - - - 440 continue - - jframe=jframe+1 - if(jframe.lt.iframe1)goto 9999 - iframe=iframe+1 - - if(iframe.ge.iframe2) goto 999 - - -c-------------------------------------------------------------------- -c-------This section writes each ts to a seperate .cfg file---------- - -c ciframe=char(iframe) -c snapshot(iframe)=name//ciframe//'.cfg' -c write(*,*)ciframe - -c write(snapshot,'("Cfgs/",i7.7,".cfg")') iframe - ciframe='.cfg' -c write(*,*)ciframe - write(snapshot,'(i5.5,a4)')iframe,ciframe -c write(*,*)snapshot - open(unit=iframe+20,file=snapshot,status='new', - * form='formatted') - - write((iframe+20),'(a22,i7)')'Number of particles = ',natom - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),'(a16)')'A = 1.0 Angstrom' - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),435)'H0(1,1) = ',xcell,' A' - write((iframe+20),'(a14)')'H0(1,2) = 0 A' - write((iframe+20),'(a14)')'H0(1,3) = 0 A' - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),'(a14)')'H0(2,1) = 0 A' - write((iframe+20),435)'H0(2,2) = ',ycell,' A' - write((iframe+20),'(a14)')'H0(2,3) = 0 A' - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),'(a14)')'H0(3,1) = 0 A' - write((iframe+20),'(a14)')'H0(3,2) = 0 A' - write((iframe+20),435)'H0(3,3) = ',zcell,' A' - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),'(a12)')'eta(1,1) = 0' - write((iframe+20),'(a12)')'eta(1,2) = 0' - write((iframe+20),'(a12)')'eta(1,3) = 0' - write((iframe+20),'(a12)')'eta(2,2) = 0' - write((iframe+20),'(a12)')'eta(2,3) = 0' - write((iframe+20),'(a12)')'eta(3,3) = 0' - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),'(a1)')'#' - write((iframe+20),'(a1)')'#' - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),'(a1)')'#' - write((iframe+20),'(a1)')'#' - write((iframe+20),'(a1)')'#' - write((iframe+20),'(a1)')'#' - write((iframe+20),*) - write((iframe+20),'(a1)')'#' - write((iframe+20),'(a1)')'#' - write((iframe+20),'(a1)')'#' - - 435 format(a11,f10.5,a2) - - do 460, j=1,natom - - do 450,i=1,ntype -c write(*,*)i,amass(i),fftype(i) -c write(*,*)ntype - if(itype(j).eq.atype(i)) - * write((iframe+20),445)mass(i),fftype(i),x(j), - * y(j),z(j),' 0',' 0',' 0' - -c---445 is the format for writing atom data to .cfg file------------ - 445 format(i3.3,1x,a2,1x,3f9.6,3a2) - - 450 continue - - 460 continue - - go to 9999 - - 999 continue - close(9) - - - end +*23456789|123456789|123456789|123456789|123456789|123456789|123456789|12 +c---------------------------------------------------------------------- + program lammps to cfg +c---------------------------------------------------------------------- +*Programming by Jeff Greathouse and Ara Kooser +*Version 1.0 9/1/04 +*Version 1.1 4/10/08 by Axel Kohlmeyer +*Sandia National Labs +*Converts LAMMPS atom dump to .cfg files for AtomEye +*This program is provided as is. Please see the README file. +c---------------------------------------------------------------------- + implicit none + + character*12 inhist,snapshot + character*4 fftype(100),name,ciframe + + integer maxatom,maxtype + parameter(maxatom=50000,maxtype=99) + + integer i,j,iframe,iframe1,iframe2,jframe + integer natom,iatom,allatom,itype(maxatom) + integer atype(maxtype),ntype,mass(maxtype) + + real*8 x(maxatom),y(maxatom),z(maxatom),amass(maxtype) + real*8 xcell,ycell,zcell,upper,lower + + +c-------Reads in the user input file------------------------------- + read(*,*) allatom + if(allatom.gt.maxatom) then + write(*,*) 'number of total atoms larger than:',maxatom + write(*,*) 'change maxatom and recompile' + STOP + endif + + read(*,*) ntype + if(ntype.gt.maxtype) then + write(*,*) 'number of total types larger than:',maxtype + write(*,*) 'change maxtype and recompile' + STOP + endif + + read(*,*) inhist + read(*,*) iframe1 + read(*,*) iframe2 + + do 1, i=1, ntype + read(*,*) atype(i) + read(*,*) amass(i) + mass(i)=anint(amass(i)) + read(*,*) fftype(i) + 1 continue + +c-------Lammps output file is 9, reads in lmps header-------------- + name=inhist(1:4) + open(9,file=inhist,status='old',form='formatted') + + iatom=0 + iframe=0 + jframe=0 + +c--------------------------------------------------------------------- +c----------This begins the frame by frame reading section------------- + + 9999 continue + read(9,*,end=999) + read(9,*,end=999) + read(9,*,end=999) + read(9,*,end=999) natom + read(9,*,end=999) + read(9,*,end=999) lower,upper + xcell=upper-lower + read(9,*,end=999) lower,upper + ycell=upper-lower + read(9,*,end=999) lower,upper + zcell=upper-lower + read(9,*,end=999) + +C clear data array. + do 400 j=1,allatom + itype(j)=0 + x(j)=0.0d0 + y(j)=0.0d0 + z(j)=0.0d0 + 400 continue + + do 440 j=1,natom + read(9,*,end=999)iatom,itype(iatom),x(iatom),y(iatom),z(iatom) + 440 continue + + jframe=jframe+1 + if(jframe.lt.iframe1)goto 9999 + iframe=iframe+1 + + if(iframe.ge.iframe2) goto 999 + + +c-------------------------------------------------------------------- +c-------This section writes each ts to a seperate .cfg file---------- + ciframe='.cfg' + write(snapshot,'(i5.5,a4)')iframe,ciframe + open(unit=iframe+20,file=snapshot,status='new', + * form='formatted') + + write((iframe+20),'(a22,i7)')'Number of particles = ',natom + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),'(a16)')'A = 1.0 Angstrom' + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),435)'H0(1,1) = ',xcell,' A' + write((iframe+20),'(a14)')'H0(1,2) = 0 A' + write((iframe+20),'(a14)')'H0(1,3) = 0 A' + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),'(a14)')'H0(2,1) = 0 A' + write((iframe+20),435)'H0(2,2) = ',ycell,' A' + write((iframe+20),'(a14)')'H0(2,3) = 0 A' + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),'(a14)')'H0(3,1) = 0 A' + write((iframe+20),'(a14)')'H0(3,2) = 0 A' + write((iframe+20),435)'H0(3,3) = ',zcell,' A' + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),'(a12)')'eta(1,1) = 0' + write((iframe+20),'(a12)')'eta(1,2) = 0' + write((iframe+20),'(a12)')'eta(1,3) = 0' + write((iframe+20),'(a12)')'eta(2,2) = 0' + write((iframe+20),'(a12)')'eta(2,3) = 0' + write((iframe+20),'(a12)')'eta(3,3) = 0' + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),'(a1)')'#' + write((iframe+20),'(a1)')'#' + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),'(a1)')'#' + write((iframe+20),'(a1)')'#' + write((iframe+20),'(a1)')'#' + write((iframe+20),'(a1)')'#' + write((iframe+20),*) + write((iframe+20),'(a1)')'#' + write((iframe+20),'(a1)')'#' + write((iframe+20),'(a1)')'#' + + 435 format(a11,f10.5,a2) + + do 460, j=1,allatom + do 450,i=1,ntype + if(itype(j).eq.atype(i)) + * write((iframe+20),445)mass(i),fftype(i),x(j), + * y(j),z(j),' 0',' 0',' 0' +c---445 is the format for writing atom data to .cfg file------------ + 445 format(i3.3,1x,a2,1x,3f9.6,3a2) + + 450 continue + 460 continue + + go to 9999 + + 999 continue + close(9) + end