Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2017
76
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, natom = 40
  5.     real*8  :: rx(n), ry(n), rz(n)
  6.     real    :: k, l
  7.     real*8  :: rxij, ryij, rzij, rijsq, rij
  8.     real*8  :: delr, rupper, rlower, nideal, box, box3, const, dens, pi
  9.     integer :: bin, maxbin, ncountgr, i, j, ii, hist(100000)
  10.     real*8  :: gr1(100000),gr2(100000),gr3(100000),gr4(100000)
  11.     integer :: nn,mn,intgr
  12.     open ( unit = 7, file = 'out.out', status = 'unknown' )
  13.    
  14.     pi  = 4.0d0*tan(1.0d0)
  15.     box = 6.09d0
  16.     write(*,*)"box in nm= ", box
  17.     box3 = box*box*box
  18.     write(*,*) "box3= ", box3
  19.     dens = n/box3
  20.     write(*,*)"density= ", dens
  21.     ncountgr = 25001  
  22.     delr  = 0.02
  23.  
  24.     write(*,*)"which interaction?"
  25.     read(*,*)nn, mn
  26.    
  27.     maxbin  = int(0.5*box/delr)
  28.  
  29.     do i=1,maxbin
  30.         hist(i)=0
  31.     end do
  32.  
  33.     do ii=1,ncountgr
  34.  
  35.         do i=1,n
  36.             read(7,*) k,l,rx(i),ry(i),rz(i)
  37.         end do
  38.        
  39.         if(nn.eq.1.and.mn.eq.1) then            
  40.         do  i=1, n-1, 3
  41.             do j = i+3, n, 3      
  42.    
  43. !                if (ii.eq.1) then
  44. !                write(*,*)i,j
  45. !                end if
  46.                 rxij =  rx(i)-rx(j)
  47.                 ryij =  ry(i)-ry(j)
  48.                 rzij =  rz(i)-rz(j)
  49.                
  50.                 if (rxij>box .or. rxij<0.0) then
  51.                    rxij = rxij - (int(rxij/box))*box
  52.                 end if
  53.                
  54.                 if (ryij>box .or. ryij<0.0) then
  55.                     ryij = ryij - (int(ryij/box))*box
  56.                 end if
  57.                
  58.                 if (rzij>box .or. rzij<0.0) then
  59.                     rzij = rzij - (int(rzij/box))*box
  60.                 end if
  61.                
  62.                 rijsq = rxij * rxij + ryij * ryij + rzij * rzij
  63.                 rij = dsqrt ( rijsq )
  64.                 bin = floor ( rij/delr )
  65.            
  66.                 hist (bin) = hist (bin) + 1
  67.        
  68.             end do
  69.         end do
  70.         end if
  71.     end do
  72. ! ==================================
  73.  
  74.     const=4.0*pi*dens/3.0   ! constant for calculating the volume
  75.     intgr = 0
  76.     do  bin = 1, maxbin
  77.         rlower = real(bin)*delr
  78.         rupper = rlower + delr
  79.         nideal = const*( rupper**3 - rlower**3 )
  80.         gr1(bin) = hist(bin)
  81.         gr2(bin) = hist(bin)/real(ncountgr)
  82.         intgr = intgr + gr2(bin)
  83.         gr3(bin) = hist(bin)/real(ncountgr)/real(natom)
  84.         gr4(bin) = hist(bin)/real(ncountgr)/real(natom)/nideal
  85.         write(120,*) rlower, gr1(bin), gr2(bin), gr3(bin), gr4(bin)
  86. 121     continue
  87.     end do
  88.     write(*,*)"integration of gr =", intgr
  89.  
  90.     end program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement