Question: Based on the attached pseudo codes, write a full MD code. Argon parameters can be used for the LJ parameters in your code. Calculate Radial
Based on the attached pseudo codes, write a full MD code.
Argon parameters can be used for the LJ parameters in your code.
Calculate Radial distribution function from the output of your code.
Algorithm Calculation of the Forces
subroutine forcefen
en
do inpart
fi
enddo
do inpart
do jinpart
xrtextrmxitextrmxj
xrxrboxnint xrbox
rxr
if rltrc then
rir
riri
ffriri
fififfxr
fjfjffxr
enenriecut
endif
enddo
enddo
return
end
determine the force
and energy
set forces to zero
loop over all pairs
periodic boundary conditions
test cutoff
LennardJones potential
update force
update energy
Comments to this algorithm:
For efficiency reasons the factors and are usually taken out of the force
loop and taken into account at the end of the calculation for the energy.
The term ecut is the value of the potential at ; for the LennardJones
potential, we have
ecut
Algorithm Initialization of a Molecular Dynamics Program
subroutine init
sumv
sumv
do inpart
xilatticeposi
vioperatornameranf
sumvsumvvi
sumvsumvvi
enddo
sumvsumvnpart
sumvsumvnpart
fssqrt tempsumv
do inpart
vivisumvfs
xmixividt
enddo
return
end
initialization of MD program
place the particles on a lattice
give random velocities
velocity center of mass
kinetic energy
velocity center of mass
meansquared velocity
scale factor of the velocities
set desired kinetic energy and set
velocity center of mass to zero
position previous time step
Comments to this algorithm:
Function latticepos gives the coordinates of lattice position i and
ranf gives a uniformly distributed random number. We do not use a
MaxwellBoltzmann distribution for the velocities; on equilibration it will be
come a MaxwellBoltzmann distribution.
In computing the number of degrees of freedom, we assume a threedi
mensio
Algorithm Integrating the Equations of Motion
subroutine integratefen
sumv
sumv
do i npart
xxfi
vixxxmidelt
sumvsumvvi
sumvsumvvi
xmixi
xixx
enddo
tempsumvnpart
etot ensumvnpart
return
end
integrate equations of motion
MD loop
Verlet algorithm
velocity
velocity center of mass
total kinetic energy
update positions previous time
update positions current time
instantaneous temperature
total energy per particle
Comments to this algorithm:
The total energy etot should remain approximately constant during the sim
ulation. A drift of this quantity may signal programming errors. It therefore
is important to monitor this quantity. Similarly, the velocity of the center of
mass sumv should remain zero.
In this subroutine we use the Verlet algorithm to integrate the equa
tions of motion. The velocities are calculated using equation nal
Algorithm The Radial Distribution Function
subroutine grswitch
if switcheq then
ngr
delgboxnhis bin size
do inhis
gi
enddo
else if switcheq then
ngrngr
do i npart
do jinpart
xrxixj
xrxrboxnint xrbox
rsqrtxr
if rltbox then
igint rdelg
giggig
endif
enddo
enddo
else if switcheq then
do inhis
rdelgi
vbidelg
nidvbrho
gigingrnid
enddo
endif
return
end
radial distribution function
switch initialization,
sample, and results
initialization
nhis total number of bins
sample
loop over all pairs
periodic boundary conditions
only within half the box length
contribution for particle i and
determine
distance
volume between bin and
number of ideal gas part. in vb
normalize
Comments to this algorithm:
For efficiency reasons the sampling part of this algorithm is usually combined
with the force calculation for example, Algorithm
The factor dots. system in fact, we approximate by N
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
