|
| 1 | +program hisread |
| 2 | +!--------------------------------------------------------------------- |
| 3 | +! read lammps trajectory file and wirte the trajectory in PDB format |
| 4 | +! written by Francesco Tavanti, March 2020 |
| 5 | +! CNR-NANO S3, Modena, Italy |
| 6 | +! |
| 7 | +! USAGE: |
| 8 | +! build the fortran executable ==> gfortran lammpstraj2pdb.f90 |
| 9 | +! then ./a.out |
| 10 | +! insert the name of input lammps file |
| 11 | +! insert the name of output file in pdb format |
| 12 | +!--------------------------------------------------------------------- |
| 13 | +implicit none |
| 14 | +integer natmax,ncouplemax |
| 15 | + |
| 16 | +parameter(natmax=50000) |
| 17 | + |
| 18 | + |
| 19 | +integer it,hkey,pdbkey,t,nat,itemp,j,k,i,num(natmax) |
| 20 | +integer nn,index(natmax),n,numero(natmax) |
| 21 | +integer fluct,h,step,step_end,dump,eneyn,foryn |
| 22 | +character*8 ctemp |
| 23 | +character*2 atyp,chain(natmax),catena |
| 24 | +character*2 atype(natmax) |
| 25 | +character*3 resi(natmax) |
| 26 | +character*70 ctemp2 |
| 27 | +character*80 title,tfilename |
| 28 | + |
| 29 | +real*8 pos(3,natmax),vel(3,natmax),for(3,natmax) |
| 30 | +real*8 temptot,raggio(natmax),speed,force |
| 31 | +real*8 xa,xb,xc,ya,yb,yc,za,zb,zc,energy |
| 32 | +real*8 fx(natmax),fy(natmax),fz(natmax),nothing |
| 33 | +character*8 chskip |
| 34 | +character*4 res(natmax),residuo |
| 35 | +integer skip,nca,mass,charge,replica,index1,timestep,yn |
| 36 | + |
| 37 | +character*1 option |
| 38 | +character*4 atname |
| 39 | +character*80 lammpsfile,pdbfile |
| 40 | + |
| 41 | +!------------------------------------------------------------------ |
| 42 | +! read the lammps file |
| 43 | +!------------------------------------------------------------------ |
| 44 | +write(*,*)'' |
| 45 | +write(*,*)'*********************' |
| 46 | +write(*,*)' This script reads a lammps trajectory file and writes the trajectory in PDB format' |
| 47 | +write(*,*)' The trajectory could come both from serial and from parallel simulations' |
| 48 | +write(*,*)' written by Francesco Tavanti, March 2020' |
| 49 | +write(*,*)' CNR-NANO S3, Modena, Italy' |
| 50 | +write(*,*)'*********************' |
| 51 | +write(*,*)'' |
| 52 | + |
| 53 | +write(*,*)'Write name of lammps trajcetory file' |
| 54 | +!read(*,*)lammpsfile |
| 55 | + |
| 56 | +open(10,file='Ge50Se50_P.pos',status='old') |
| 57 | +open(11,file='Ge50Se50_P.evp') |
| 58 | + |
| 59 | +open(13,file='GeSe.label') |
| 60 | +open(14,file='Ge50Se50_P.for') |
| 61 | +open(15,file='conf_deepmd.xyz') |
| 62 | + |
| 63 | +!write(*,*)'Do you want energy? 0 = NO , 1 = YES' |
| 64 | +!read(*,*)eneyn |
| 65 | + |
| 66 | +eneyn=1 |
| 67 | +!write(*,*)'Do you want forces? 0 = NO , 1 = YES' |
| 68 | +!read(*,*)foryn |
| 69 | +foryn=1 |
| 70 | +write(*,*)'Dump frames' |
| 71 | +read(*,*)dump |
| 72 | +write(*,*)'Do you want forces? 0=no 1=yes' |
| 73 | +read(*,*)yn |
| 74 | + |
| 75 | +do j=1,50 |
| 76 | + read(13,'(a2)')atype(j) |
| 77 | +enddo |
| 78 | + |
| 79 | +!dump=10 |
| 80 | + |
| 81 | +step=1 |
| 82 | +step_end=100000 |
| 83 | +read(11,*) |
| 84 | + |
| 85 | +xb= 21.4735 |
| 86 | +yb= 21.4735 |
| 87 | +zb= 21.4735 |
| 88 | +do it=1,step_end |
| 89 | + read(10,900)title |
| 90 | + read(11,*)nothing,nothing,nothing,nothing,nothing,energy |
| 91 | +if((it.ge.step).and.(it.le.step_end).and.((modulo(it,dump)).eq.0))then |
| 92 | + |
| 93 | + write(15,'(i2)')50 |
| 94 | + if(yn.eq.1)then |
| 95 | + write(15,'(a27,9f10.5,a1,a52,f11.4,a12)')'config_type=1000 Lattice=" ',xb/1.8897,0.0,0.0,0.0,yb/1.8897,0.0,0.0,0.0,zb/1.8897, & |
| 96 | + '"',' Properties=species:S:1:pos:R:3:forces:R:3 energy=',energy*27.2114,' pbc="T T T"' |
| 97 | + else |
| 98 | + write(15,'(a27,9f10.5,a1,a42,f11.4,a12)')'config_type=1000 Lattice=" ',xb/1.8897,0.0,0.0,0.0,yb/1.8897,0.0,0.0,0.0,zb/1.8897, & |
| 99 | + '"',' Properties=species:S:1:pos:R:3 energy=',energy*27.2114,' pbc="T T T"' |
| 100 | + endif |
| 101 | +endif |
| 102 | + |
| 103 | + |
| 104 | +read(14,*)title |
| 105 | +do j=1,50 |
| 106 | +read(14,*)fx(j),fy(j),fz(j) |
| 107 | +fx(j)=fx(j)*51.422086 |
| 108 | +fy(j)=fy(j)*51.422086 |
| 109 | +fz(j)=fz(j)*51.422086 |
| 110 | +if(foryn.eq.0)then |
| 111 | +fx(j)=0 |
| 112 | +fy(j)=0 |
| 113 | +fz(j)=0 |
| 114 | +endif |
| 115 | +read(10,*)(pos(k,j),k=1,3) |
| 116 | +if((pos(1,j).gt.xb))then |
| 117 | + pos(1,j)=MOD(pos(1,j),xb) |
| 118 | +elseif((pos(1,j).lt.0))then |
| 119 | + pos(1,j)=MOD(pos(1,j),xb)+xb |
| 120 | +endif |
| 121 | +if((pos(2,j).gt.yb))then |
| 122 | + pos(2,j)=MOD(pos(2,j),yb) |
| 123 | +elseif((pos(2,j).lt.0))then |
| 124 | + pos(2,j)=MOD(pos(2,j),yb)+yb |
| 125 | +endif |
| 126 | +if((pos(3,j).gt.zb))then |
| 127 | + pos(3,j)=MOD(pos(3,j),zb) |
| 128 | +elseif((pos(3,j).lt.0))then |
| 129 | + pos(3,j)=MOD(pos(3,j),zb)+zb |
| 130 | +endif |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | +!if(pos(1,j).gt.xb)then |
| 136 | +! pos(1,j)=pos(1,j)-xb |
| 137 | +!elseif(pos(1,j).lt.0)then |
| 138 | +! pos(1,j)=pos(1,j)+xb |
| 139 | +!elseif(pos(2,j).gt.yb)then |
| 140 | +! pos(2,j)=pos(2,j)-yb |
| 141 | +!elseif(pos(2,j).lt.0)then |
| 142 | +! pos(2,j)=pos(2,j)+yb |
| 143 | +!elseif(pos(3,j).gt.yb)then |
| 144 | +! pos(3,j)=pos(3,j)-zb |
| 145 | +!elseif(pos(3,j).lt.0)then |
| 146 | +! pos(3,j)=pos(3,j)+zb |
| 147 | +!else |
| 148 | +!endif |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | +if((it.ge.step).and.(it.le.step_end).and.((modulo(it,dump)).eq.0))then |
| 153 | + if(yn.eq.1)then |
| 154 | + write(15,'(a2,6f17.9)')atype(j),pos(1,j)/1.8897,pos(2,j)/1.8897,pos(3,j)/1.8897,fx(j),fy(j),fz(j) |
| 155 | + else |
| 156 | + write(15,'(a2,3f17.9)')atype(j),pos(1,j)/1.8897,pos(2,j)/1.8897,pos(3,j)/1.8897 |
| 157 | + endif |
| 158 | +endif |
| 159 | +enddo |
| 160 | + |
| 161 | + |
| 162 | +enddo |
| 163 | + |
| 164 | +170 format(a6) |
| 165 | + |
| 166 | +900 format(a80) |
| 167 | + |
| 168 | +1070 format(a4,2x,i5,1x,a2,3x,a3,i6,4x,f8.3,f8.3,f8.3,f6.2,f6.2) |
| 169 | + |
| 170 | +end |
| 171 | +!------------------------------------------------------------------------ |
| 172 | + |
0 commit comments