Car-Parrinello Molecular Dynamics
Introduction
The standard procedure to perform an ab-initio, Car-Parrinello molecular dynamics simulation consists of a number of steps that have to be executed in the correct order. The first step consists in preparing a statistically meaningful initial configuration.Electronic minimization of an ideal Si crystal
ndw = 50The parameter "dt" determines the time step for the integration of the MD equations. It is expressed in atomic units (1 a.u. = 2.4 10^-17 s). In our case, we set
dt = 10.0d0"nstep" fizes the total number of time steps that will be executed
nstep = 300The parameter "iprint" determines after how many MD steps the codes prints out a summary of several interesting variables, like atomic positions, forces, velocities, etc.
iprint = 10Notice that a number of quantities are printed in the standard output, but the most relevant ones are also printed out in separate files for different physical quantities. Positions are printed out in file "prefix".pos, forces in "prefix".for, various energies in "prefix".evp, and so on. Notice that the code appends (and does not overwrite) the output of consecutive runs to the same .pos, .for, etc, files.
isave = 100Before we can start a MD simulation we must ensure that the electrons are in their ground state. In this example, we will use a steepest descent ("sd") algorithm to find the electronic ground state
electron_dynamics = 'sd'The electron dynamics is controlled by the "fictitious" mass "emass",
emass = 400.d0The ions will not move while we determine the ground state,
ion_dynamics = 'none'We place the atoms in the ideal positions of a face centered cubic conventional cell,
ATOMIC_POSITIONS (crystal) Si 0.0000 0.0000 0.0000 1 1 1 Si 0.0000 0.5000 0.5000 1 1 1 Si 0.5000 0.5000 0.0000 1 1 1 Si 0.5000 0.0000 0.5000 1 1 1 Si 0.2500 0.2500 0.2500 1 1 1 Si 0.2500 0.7500 0.7500 1 1 1 Si 0.7500 0.7500 0.2500 1 1 1 Si 0.7500 0.2500 0.7500 1 1 1We are now ready to execute the electronic minimization:
../bin/cp.x < si.in.00 > si.out.00Notice that the resulting forces on the ions are zero, due to symmetry. This is not a convenient starting point for a MD simulation because the ions will not move away from this configuration.
Random displacement of the atoms from their ideal positions
cp si.in.00 si.in.01and modify the new file "si.in.01" as follows. We need to read the old configuration from the stored unit "50", so we need to change the restart mode from "from_scratch" to
restart_mode = "restart"and we need to add the line
ndr = 50If we want to keep the information (positions, wfc's, etc) of the "ideal" crystal, we better write on a different unit, so we need to change the value of "ndw" as
ndw = 51Notice that unit "50" will not be touched if ndr.ne.ndw.
tranp = .true. amprp = 0.1d0All ionic positions will be displaced with respect to the positions read from unit "ndr", by a random quantity of the order of "amprp" (in atomic units).
../bin/cp.x < si.in.01 > si.out.01
Let's dance!
cp si.in.01 si.in.02and modify the new file "si.in.01" as follows.
ndr = 51 ndw = 52It is also essential to remove the randomization parameters (we don't want to randomize the ions again, they are already displaced). The "tranp" and "amprp" parameters must be removed.
electron_dynamics = 'verlet' electron_velocities = 'zero'in the "&electrons" namelist, and
ion_dynamics = 'verlet' ion_velocities = 'zero'in the "&ions" namelist. Finally, we may want to change the total number of steps
nstep = 1000With a time step of 10 a.u., this implies that we will be simulating the dynamics of the system for a total time of 0.24 ps. For convenience, we may also want to reset the time step counter
restart_mode = 'reset_counters',We also clean up the directory by removing files that we now want to overwrite:
rm si.pos si.cel si.str si.evp si.for si.vel si.spr si.the si.nos si.eig si.con si.polThe code will now perform a Car-Parrinello MD simulation configuration:
../bin/cp.x < si.in.02 > si.out.02We will consider here two typical analyses of a MD trajectory. First, we will learn how to visualize the trajectories using "xcrysden". We will then also learn how to compute pair-correlation functions.
Visualizing the trajectory with XCrysDen
gfortran cp2xsf.f90 -o cp2xsf.xTake a look at "cp2xsf.in". It contains information about the prefix of the .pos and .cel files of which you want to calculate the trajectory, and the total number of frames that you want to include in the movie. If you want to visualize the run described above, then nframes = nstep/iprint = 1000/10 = 100 (NB: positions and cell are printed in files .pos and .cel every iprint).
./cp2xsf.x < cp2xsf.inThis will produce an output file named "si.axsf", where the suffix "axsf" stands for "animated" xsf. Now launch xcrysden... File... Open Structure... si.axsf, and enjoy the movie!
Generating a pair-correlation function
gfortran gofr.f -o gofr.xTake a look at "gofr.in". It contains information about the names of the .pos and .cel files of the trajectory for which you want to calculate the pair correlation function, and the total number of frames that you want to include in the statistics.
./gofr.x < gofr.inThis will produce an output file named "gofr.out", which contains three columns. Column 1 is the radius, column 2 contains the pair-correlation function, and column 3 contains the integral of the pair correlation function, normalized in such a way that it corresponds to the total number of atoms found within that radius.
Setting a target temperature with a thermostat
ion_temperature='nose' tempw=4000 fnosep=3.0where "tempw" is the target temperature (in Kelvin) and "fnosep" is the characteristic frequency of the thermostat (in THz!). Such frequency should be tuned within the range of characteristic frequencies of the ionic dynamics of your system. Vibrational modes with frequencies closer to the thermostat frequency will thermalize faster, but the final thermodynamical state of your system should not depend on the thermostat frequency, as long as the whole system is allowed to thermalize. Notice that dynamical properties such as vibrational frequencies, diffusion coefficients, transport properties, are affected by the thermostat, so if you're interested in those, you must switch the thermostat off after equilibration is achieved, and only then start collecting dynamical averages.