Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     program kitty
  2.    
  3.     implicit none
  4.     integer, parameter  :: n=120
  5.     real*8  :: rx(n), ry(n), rz(n)
  6.     real    :: k, l
  7.     integer :: flag, intgr
  8.     real*8  :: rxij, ryij, rzij, rijsq, rij
  9.     real*8  :: delr, rupper, rlower, nideal, box, box3, const, dens, pi
  10.     integer :: bin, maxbin, ncountgr, i, j, ii, hist(100000)
  11.     real*8  :: gr1(100000),gr2(100000),gr3(100000),gr4(100000)
  12.    
  13.     open ( unit = 7, file = 'out.out', status = 'unknown' )
  14.    
  15.     pi  = 4.0d0*tan(1.0d0)
  16.     box = 6.09d0
  17.     write(*,*)"box in nm= ", box
  18.     box3 = box*box*box
  19.     write(*,*) "box3= ", box3
  20.     dens = n/box3
  21.     write(*,*)"density= ", dens
  22.     ncountgr = 25001
  23.     delr  = 0.04
  24.  
  25. !    maxbin  = int(0.5*box/delr)
  26.     maxbin = 100005
  27.    
  28.     do i=1,maxbin
  29.         hist(i)=0
  30.     end do
  31.     flag = 0
  32.    
  33.     do ii=1,ncountgr
  34.         do i=1, n
  35.                     flag = flag+1
  36.             read(7,*) k,l,rx(i),ry(i),rz(i)
  37.         end do
  38.        
  39.         do  i=1, n-1
  40.  
  41.             do j = i+1, n
  42.        
  43.                 rxij =  rx(i)-rx(j)
  44.                 ryij =  ry(i)-ry(j)
  45.                 rzij =  rz(i)-rz(j)
  46.                 if (rxij>box .or. rxij<0.0) then
  47.                     rxij = modulo(rxij, box)
  48.                 end if            
  49.                 if (ryij>box .or. ryij<0.0) then
  50.                     ryij = modulo(ryij, box)
  51.                 end if
  52.                 if (rzij>box .or. rzij<0.0) then
  53.                     rzij = modulo(rzij, box)
  54.                 end if
  55.                
  56.                 rijsq = rxij * rxij + ryij * ryij + rzij * rzij
  57.                 rij = dsqrt ( rijsq )
  58.                 bin = int ( rij/delr )
  59.                 hist (bin) = hist (bin) + 1
  60.             end do
  61.         end do
  62.     end do
  63.    write(*,*)"flag=",flag/ncountgr
  64.  
  65. ! Calculation of solute solvent g(r)
  66. ! ==================================
  67.  
  68.     const=4.0*pi*dens/3.0   ! constant for calculating the volume
  69.     intgr = 0
  70.     do  bin = 1, maxbin
  71.         rlower = real(bin)*delr
  72.         rupper = rlower + delr
  73.         nideal = const*( rupper**3 - rlower**3 )
  74.         gr1(bin) = real(hist(bin))
  75.         gr2(bin) = real(hist(bin))/real(ncountgr)
  76.         intgr    = intgr  + hist(bin)
  77.         gr3(bin) = real(hist(bin))/real(ncountgr)/real(n)
  78.         gr4(bin) = real(hist(bin))/real(ncountgr)/real(n)/nideal
  79.         write(120,*) rlower, gr1(bin), gr2(bin), gr3(bin), gr4(bin)
  80.     end do
  81.          write(*,*)"intgr=",intgr/ncountgr
  82.  
  83.     end program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement