在此提供一个计算tip5p水分子转动自相关函数的计算代码,通过修改可以实现对residence time correlation function的计算,个人编程水平低下,欢迎指教。将以下内容保存为racf.f90, linux端执行gfortran racf.f90 -o racf.x即可生成可执行文件racf.x. 用法:./racf.x tip5p.gro >racf.dat
以下为程序代码:- program main
- IMPLICIT DOUBLE PRECISION (A-H, O-Z)
- character fname*216, dum*216
- real(16) :: mu(2000,10000,3), O(3), H1(3), H2(3) !vector mu(nframe,nmolecule,xyz)
- real(16) :: dohh, ddot
- integer :: fr
- integer :: dt
- integer :: atom
- call getarg(1,fname)
- open(10,file=fname,status='OLD',form='FORMATTED',action='READ')
- dohh=0.058588
- nl=0
- do
- read(10,*,end=900)
- nl=nl+1
- read(10,*) num
- num = num/5
- do i=1,num
- read(10,"(A20,3F8.3)") dum, O(1), O(2), O(3)
- read(10,"(A20,3F8.3)") dum, H1(1),H1(2),H1(3)
- read(10,"(A20,3F8.3)") dum, H2(1),H2(2),H2(3)
- read(10,*) dum
- read(10,*) dum
- mu(nl,i,:) = (O(:)-(H1(:)+H2(:))/2)/dohh
- enddo
- read(10,*) bx,by,bz
- enddo
- 900 continue
- n_sample=INT(nl/2-1)
- do dt=1,n_sample
- d_sum=0
- do fr=1,nl-dt
- do atom=1, num
- ddot=mu(fr,atom,1)*mu(fr+dt,atom,1)+mu(fr,atom,2)*mu(fr+dt,atom,2)+mu(fr,atom,3)*mu(fr+dt,atom,3)
- ! write(6,*) ddot
- d_sum=d_sum+ddot
- enddo
- enddo
- d_sum=d_sum/(nl-dt)/num
- write(6,"(I8,F16.3)") dt, d_sum
- enddo
- return
- end
复制代码 |