6.5 Program 6.1, Fortran Code
107
c ** real d(n3,n3) the diffusion tensor **
c ** real xic(n3) correlated random normal deviates **
c ** real dt reduced timestep **
c ** **
c ** usage: **
c ** **
c ** move is called after force and covar to move the atoms. **
c ***************************************************************
integer n, n3
parameter ( n = 2, n3 = n * 3 )
real rx(n), ry(n), rz(n), fx(n), fy(n), fz(n)
real d(n3,n3), xic(n3)
real dt
real f(n3), sumx, sumy, sumz
integer i, ic, jc
c ***************************************************************
c ** place forces in a temporary array of size 3n **
c ***************************************************************
do 10 i = 1, n
ic = ( i - 1 ) * 3 + 1
f(ic) = fx(i)
f(ic+1) = fy(i)
f(ic+2) = fz(i)
10 continue
c ** move the atoms **
do 30 i = 1, n
ic = ( i - 1 ) * 3 + 1
sumx = 0.0
sumy = 0.0
sumz = 0.0
do 20 jc = 1, n3
sumx = sumx + d( ic , jc ) * f(jc)
sumy = sumy + d( ic+1, jc ) * f(jc)
sumz = sumz + d( ic+2, jc ) * f(jc)
20 continue
rx(i) = rx(i) + sumx * dt + xic( ic )
ry(i) = ry(i) + sumy * dt + xic( ic + 1 )
rz(i) = rz(i) + sumz * dt + xic( ic + 2 )
30 continue
return
end
real function ranf ( dummy )
c ***************************************************************
c ** function ranf returns a uniform random variate between 0 and 1**
c ** **
107
c ** real d(n3,n3) the diffusion tensor **
c ** real xic(n3) correlated random normal deviates **
c ** real dt reduced timestep **
c ** **
c ** usage: **
c ** **
c ** move is called after force and covar to move the atoms. **
c ***************************************************************
integer n, n3
parameter ( n = 2, n3 = n * 3 )
real rx(n), ry(n), rz(n), fx(n), fy(n), fz(n)
real d(n3,n3), xic(n3)
real dt
real f(n3), sumx, sumy, sumz
integer i, ic, jc
c ***************************************************************
c ** place forces in a temporary array of size 3n **
c ***************************************************************
do 10 i = 1, n
ic = ( i - 1 ) * 3 + 1
f(ic) = fx(i)
f(ic+1) = fy(i)
f(ic+2) = fz(i)
10 continue
c ** move the atoms **
do 30 i = 1, n
ic = ( i - 1 ) * 3 + 1
sumx = 0.0
sumy = 0.0
sumz = 0.0
do 20 jc = 1, n3
sumx = sumx + d( ic , jc ) * f(jc)
sumy = sumy + d( ic+1, jc ) * f(jc)
sumz = sumz + d( ic+2, jc ) * f(jc)
20 continue
rx(i) = rx(i) + sumx * dt + xic( ic )
ry(i) = ry(i) + sumy * dt + xic( ic + 1 )
rz(i) = rz(i) + sumz * dt + xic( ic + 2 )
30 continue
return
end
real function ranf ( dummy )
c ***************************************************************
c ** function ranf returns a uniform random variate between 0 and 1**
c ** **
