+ All Categories
Home > Documents > Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a...

Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a...

Date post: 16-Oct-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
48
Molecular Dynamics In CASTEP David Quigley University of York May 10, 2005
Transcript
Page 1: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

Molecular Dynamics In CASTEP

David QuigleyUniversity of York

May 10, 2005

Page 2: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

Chapter 1

Introduction

This document is intended as a guide to the molecular dynamics functionality inCASTEP. It isnot intended as an introduction to the molecular dynamics method.The reader is referred to the texts by Haile [4] and Allen and Tildesley [1] forsuch an introduction. For more advanced reading see the bookby Frenkel andSchmidt [3]. Details specific toab-inito MD can be found in the review article byMarx and Hutter [9] with particular reference to the plane wave pseudo-potentialmethod. It is assumed that the reader has some experience in running MD codes,and has gained sufficient proficiency in running CASTEP for e.g. single-pointtotal energy calculations.

This document will first outline the capabilities of the MD module and discussthe methods used. The steps involved in setting up an MD simulation will beillustrated with specific examples. An attempt has been madeto use computation-ally cheap examples to allow the reader to reproduce the results in a reasonabletime without access to expensive hardware, however allab-initio MD simulationsrequire patience!

Analysis of the MD output will also be considered with reference to the sameexamples. These will use a simple code which can be downloaded from thesepages. Importing CASTEP output into freely available analysis and visualisationcodes will be briefly covered.

1

Page 3: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

Chapter 2

Usage, Capabilities and Inputs

The molecular dynamics implementation in CASTEP follows the Born-Oppenheimerapproximation. i.e. forces are calculated from theground state electronic config-uration at each MD step. Within this scheme the NVE, NVT, NPH,and NPTensembles can be simulated. Temperature control is implemented via a chain ofNose-Hoover thermostats or by performing Langevin dynamics in the appropriatephase space. Hydrostatic pressure is regulated by the use ofeither an Andersen-Hoover or Parrinello-Rahman barostat. Any combination of these schemes is al-lowable within the limits of the desired ensemble.

A variety of user-specified or symmetry constraints can be imposed on the dynam-ics and these are discussed in 2.3. Check-pointing of MD calculations is discussedin section 2.5. Methods for speeding up MD calculations are described in section2.7.

Variable cell calculations lead to issues with the plane wave basis set which CASTEPattempts to eliminate. This is discussed where relevant, i.e. in sections 2.2.3 and2.6.

2.1 Basics

Fundamental to MD calculations is the calculation time-step. An appropriatevalue for the simulation should be specified in the parameters file in the followingway.

md_delta_t = 2 fs

2

Page 4: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 3

Any valid unit of time can be used when specifying the time-step. The number oftime-steps to perform is specified with e.g.

md_num_iter = 500

2.2 Ensembles

The following statistical ensembles can be simulated usingCASTEP.

2.2.1 NVE

In this ensemble the shape and size of the simulation cell remain constant as spec-ified in the cell file. The conserved energy is the Born-Oppenheimer HamiltonianE = DjHejE+ 12 NXi=1 NXj=1 ZiZjjRi �Rjj + NXi=1 P 2i2Mi (2.1)

in atomic units.

This ensemble is selected using the command

md_ensemble = nve

in the parameters file. The actual value of the conserved energy will be the resultof the initial self-consistent DFT calculation plus the kinetic energy of the initialionic velocities.

These ionic velocities are defined in one of three ways.� By explicit user definition of ionic velocities in the cell file, e.g.

%BLOCK IONIC_VELOCITIESauvH xxxxx yyyyy zzzzzH xxxxx yyyyy zzzzzO xxxxx yyyyy zzzzz%ENDBLOCK IONIC_VELOCITIES� By definition of an initial temperature in the parameters file, e.g.

Page 5: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 4

md_temperature = 293 K

Note that this can be specified using any valid unit of temperature. In thiscase initial velocities are assigned randomly such that thetotal linear mo-mentum is zero and the instantaneous temperature matches that specified.The system will reach an equilibrium with a somewhat different tempera-ture.� By continuation from an equilibrated run at the desired temperature. Thiscould be a run in any of the other available ensembles. This will also usethe cell and ionic positions from the continuation file. See the section oncontinuation for details.

Velocities read from a continuation file will always take precedence. If no contin-uation file is used, and bothmd_temperature and anIONIC_VELOCITIESblock are specified, themd_temperature keyword will be ignored.

By default, pressure is not calculated during an NVE run. To override this use thecommand

calculate_stress = true

in the parameters file.

2.2.2 NVT

This ensemble is selected with

md_ensemble = nvt

The system will be evolved to a specific temperature defined using themd_temperaturekeyword as used above. Initial velocities are assigned based on this temperature,read from anIONIC_VELOCITIES block in the cell file, or read from a contin-uation file in the same way as above.

Temperature control can be implemented by one of two methods, both of whichhave been shown to correctly sample the canonical ensemble.The first of these isthe Nose-Hoover chain method of Tuckerman et al [7] and is selected with

md_thermostat = nose-hoover

Page 6: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 5

in the parameters file. In the NVT case, a single Nose-Hooverchain is coupled toall particle degrees of freedom. The length of the chain can also be specified, e.g.

md_nhc_length = 5

for a chain of five thermostats. In the Nose-Hoover case witha chain ofMthermostats acting ofNf ionic degrees of freedom, the conserved quantity is thepseudo-HamiltonianH = DjHejE+12 NXi=1 NXj=1 ZiZjjRi �Rjj+ NXi=1 P 2i2Mi+ MXi=1 p2�i2Qi+NfkBT�1+kBT MXi=2 �i

(2.2)

where theQi are the thermostat fictitious masses assigned automatically from thespecified ion relaxation time and�i are the thermostat degrees of freedom. This isprinted with the label “Hamilt Energy:” at each time-step.

The second method of controlling temperature is the Langevin thermostat.

md_thermostat = langevin

In this case the printed Hamiltonian energy is the value of equation 2.1. This isnot conserved by the dynamics, but should exhibit no long term drift from theequilibrium value.

With either method, a suitable relaxation time for the thermostatic process shouldbe specified. This can use any supported unit of time, e.g

md_ion_t = 2.4 ps

for a thermostat relaxation time of 2.4 picoseconds.

As with the NVE ensemble, pressure is not calculated by default. This is overrid-den in the same way as the NVE case.

2.2.3 NPH

In this ensemble the size and (if desired) shape of the simulation cell varies toregulate pressure. No thermostat is applied.

This ensemble is specified with the following:

Page 7: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 6

md_ensemble = nph

The external pressure is set in the cell definition file using any valid unit of pres-sure. The required symmetry of the external pressure tensorimplies that only theupper triangular components need be specified, e.g.

%block external_pressureGPa0.5 0.0 0.0

0.5 0.00.5

%endblock external_pressure

to specify an isotropic external pressure of 0.5 Giga-Pascals. Note that MD cur-rently supports only isotropic external pressure. Off-diagonal components aretherefore ignored.

Velocities are assigned such that the initial temperature is equal tomd_temperature,or are read from the cell definition file/continuation file as in the NVE/NVT cases.

Two barostat schemes are available. The first restricts the dynamics of the cell toisotropic expansions and contractions. This follows the method of Andersen[2]and Hoover[5, 6] as corrected by Martynaet al.[8]. This is selected using:

md_barostat = andersen-hoover

In this case the printed Hamiltonian energy is the enthalpy,plus the kinetic energyassociated with the cell motion.H = DjHejE+ 12 NXi=1 NXj=1 ZiZjjRi �Rjj + NXi=1 P 2i2Mi + PextV + p2�=2W (2.3)

The alternative scheme implements the method of Parrinelloand Rahman [10, 11].Both the size and shape of the simulation cell are allowed to vary. The issue of cellrotations is eliminated by the use of a symmetrised pressuretensor. Note that asliquids cannot sustain shear, this method should only be used with solids. It shouldalso be noted that this scheme is based on the modified Parrinello-Rahman methodof Martyna, Tobias and Klien [8] which is modularly invariant, exactly obeys theappropriate tensorial virial theorem, but is only applicable to hydrostatic pressure.

The following line in the parameters file selects this barostat.

Page 8: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 7

md_barostat = parrinello-rahman

The cell dynamics contain nine degrees of freedom (of which six are independent)leading to a Hamiltonian energy ofH = DjHejE+ 12 NXi=1 NXj=1 ZiZjjRi �Rjj + NXi=1 P 2i2Mi + PextV + Tr[pgpTg ℄=2W

(2.4)

For both schemes, a relaxation time for the cell motions should be specified withan appropriate unit of time, for example:

md_cell_t = 20 ps

This time is used to calculate a fictitious massW for the cell dynamics.

The NPH equations of motion require that pressure is calculated at each MD time-step. The value ofcalculate_stress is therefore irrelevant in this case.

A variable cell implies variable reciprocal lattice vectors which has consequencesfor the plane-wave basis set. As the cell changes, the numberof plane wavesrequired to produce the specified cut-off energy changes.

The user therefore has two options. The first is to fix the size of the basis set.

fixed_npw = true

The cut-off energy is now variable as is the quality of the basis set. This optionshould therefore only be used for calculations in which the volume changes aresmall and which are over converged with respect to the numberof plane waves.

The second option is to change the basis set at each time-step.

fixed_npw = false

This keeps the cut-off energy approximately constant by adding or subtractingplane waves from the basis set at each time-step.

In either case, the effect of Pulay stress is reduced by applying a finite basis setcorrection to the pressure at each time-step. In the case of afixed number of planewaves, the constant correction to energy is ignored. With variable number of planewaves the energy correction is no longer constant and is recalculated at each step.More details on finite basis set corrections can be found in 2.6.

Note that not all exchange-correlation functionals can be used with variable cellcalculations. The choice is limited to LDA and GGA schemes only.

Page 9: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 8

2.2.4 NPT

The NPT ensemble is specified with the command:

md_ensemble = npt

Any combination of the thermostat and barostat schemes listed above is allowed,and is implemented in a dedicated routine. In all cases the dynamics can be shownto correctly sample the isothermal-isobaric ensemble [8, 12].

All options pertaining to the NPH and NVT ensembles apply.

In the case of Langevin dynamics at NPT, the printed Hamiltonian energy is thesame as in the NPH ensemble, i.e. that given by equation 2.3 or2.4. In the caseof Nose-Hoover NPT molecular dynamics, the Hamiltonian energy is given byH = DjHejE+12 NXi=1 NXj=1 ZiZjjRi �Rjj+ NXi=1 P 2i2Mi+PextV+p2�=2W+ MXi=1 p2�i2Qi+NfkBT�1+kBT MXi=2 �i+ MXi=1 p2�bi2Qbi+kBT MXi=1 �bi

(2.5)

in the case of isotropic cell dynamics, orH = DjHejE+12 NXi=1 NXj=1 ZiZjjRi �Rjj+ NXi=1 P 2i2Mi+PextV+Tr[pgpTg ℄=2W+ MXi=1 p2�i2Qi+NfkBT�1+kBT MXi=2 �i+ MXi=1 p2�bi2Qbi+9kBT�b1+kBT MXi=2 �bi(2.6)

in the Parrinello-Rahman case. Note that in each case the motion of the cell de-gree(s) of freedom couple to a second Nose-Hoover chain.

2.3 Constraints

2.3.1 User Constraints

Any combination of linear constraints can be specified in thecell file.

We assign the indexk to run over allNs species present in the cell, the indexj torun over theNk ions in each species, and the indexi to run over the three spatialco-ordinates of an ion. They co-ordinate of the 2nd ion in the 3rd species is then

Page 10: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 9rijk = r223. Associated with each of these degrees of freedom is a co-efficientaijk. The nth linear constraint can then be specified asNsXk=1 NkXj=1 3Xi=1 anijkrijk = Cn; (2.7)

where the constantCn is determined by the initial conditions. Specification ofthe nth linear constraint therefore reduces to specification of theco-efficientsanijk.These are input into the cell file in the following fashion.

%BLOCK IONIC_CONSTRAINTS1 S ja11jk a12jk a13jk1 S ja11jk a12jk a13jk2 O j a21jk a22jk a23jk2 O j a21jk a22jk a23jk2 O j a21jk a22jk a23jk%ENDBLOCK IONIC_CONSTRAINTS

For two constraints, one involving two sulfur ions, and another involving threeoxygen ions. All coefficients not specified are assumed to be zero.

The first column in the block gives a unique number to the constraint specified.The second specifies the species by either atomic symbol (S orO in the aboveexample) or atomic number. The third column is the index within a speciesj.The co-efficients of the three spatial co-ordinates for thision under the currentconstraint are then specified.

As an example, let us consider the case of restricting a single ion to move alongalong a plane parallel toy = x. The normal to this plane is(�1; 1; 0) and ourconstraint is that the dot product of this normal with the position vector of the ionin question is zero. If this is the second ion in the fourth species then(�1; 1; 0) � (r124; r224; r324) = 0 (2.8)

In this trivial example, we can see that we need (if the fourthspecies is say, sulfur)

%BLOCK IONIC_CONSTRAINTS1 S 2 -1 1 0%ENDBLOCK IONIC_CONSTRAINTS

to satisfy the above equation. We shall see an example of using multiple linearconstraints in section 4.1.3.

Page 11: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 10

A variety of constraints can be specified in this fashion. Forsimplicity, a specialcell file keyword is provided to fix the centre of mass in the MD calculation.

fix_com = true

This is particularly useful for Langevin dynamics simulations of small numbers ofatoms. Such simulations exhibit a wandering centre of mass (with no net resultantdrift) if the centre of mass is not constrained.

For calculations in the NPH or NPT ensembles, it is possible to fix the positionsof all ions and hence only conduct dynamics for the cell degrees of freedom usingthe following.

fix_all_ions = true

Similarly, it is possible to specify that all cell degrees offreedom remain fixed.

fix_all_cell = true

It is however advisable to work in a fixed cell ensemble instead. Fixing both thecell and ionic degrees of freedom in this way will eliminate all motions and willhence return an error.

Non-linear constraints, such as those used to fix the distance between two ions,are not yet supported. Constraints on individual cell degrees of freedom are alsonot yet supported.

2.3.2 Symmetry Constraints

Many systems that are studied using CASTEP exhibit one or more symmetries.The operations defining a symmetry can be manually specified as a combinationof a translation plus a rotation in the cell file. For example:

%BLOCK SYMMETRY_OPS0.00000000000 1.00000000000 0.00000000000

-1.00000000000 0.00000000000 0.000000000000.00000000000 0.00000000000 1.000000000000.75000000000 0.25000000000 0.75000000000

%ENDBLOCK SYMMETRY_OPS

Page 12: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 11

This represents an application of the rotation matrix0� 0 1 0�1 0 00 0 1 1Afollowed by a translation (in the basis of the cell vectors) of�34 ; 14 ; 34� :Any symmetries specified in this way will generate an extra constraint to themolecular dynamics. Only motions which preserve the specified symmetry op-eration(s) will be permitted.

It is also possible to automatically generate all symmetry operations present usingthe keyword

symmetry_generate

in the cell definition file. In this case all identified symmetry operations will bepreserved by the dynamics.

Symmetry constraints are not currently supported in variable cell ensembles.

2.4 Boundary Conditions

Boundary conditions in CASTEP are periodic in all three dimensions. However itis possible to simulate the dynamics of isolated clusters/molecules, provided thatthe size of the super-cell is sufficiently large that no atom interactions cross a cellboundary.

This involves careful convergence of the forces with respect to the size of thesuper-cell. This convergence should be especially strict for MD calculations asexpansion of the cluster may occur, causing it reach a state where it can interactwith itself, even if it did not in the initial cell. Variable cell ensembles should notbe used for isolated systems.

Slab and wire boundary conditions can also be simulated by increasing the size ofthe super-cell in one or two dimensions only. Again convergence with respect tothese dimensions is critical. Variable cell-shape simulations are possible in these

Page 13: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 12

Figure 2.1: Isolated pentane molecule simulated by converging the total energywith respect to the size of the super-cell.

cases, provided the cell is constrained in the non-periodicdirections. Alterna-tively, an isotropic variable cell simulation can be conducted using an orthogonalsuper-cell for which interactions across one or more of the three cell directionshave been eliminated by the addition of a vacuum gap. This is identically equiva-lent to application of pressure in the remaining periodic directions only.

2.5 Check-pointing, Continuation and Parameter Changes

As with any other calculation in CASTEP, checkpoint files arewritten at regularintervals. Should the calculation be interrupted for whatever reason, it is possibleto continue from the point at which a checkpoint file was written.

Check-pointing is performed by dumping all pertinent data to a .check file. Theinterval at which this check-pointing occurs can be controlled in two ways.

The first option is to specify the number of md steps between checkpoints.

num_backup_iter = 5

Alternatively, the wall-clock time (in seconds) between backups can be specifiedwith:

backup_interval = 60

Page 14: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 13

Figure 2.2: Slab boundary conditions, simulated with a vacuum gap in the ver-tical direction, used to simulate bulk terminated silicon.Bonds into the bulk aresatisfied by hydrogen passivation.

Both intervals can be used, i.e. a checkpoint file could be written every 60 secondsand every 5 MD steps. To disable either interval, set the corresponding parameterto zero.

The name of the checkpoint file will be the calculation seed-name followed by‘.check’. This can be overridden with:

checkpoint = my_md_run.check

To continue an MD calculation from a checkpoint file, ensure that the .check file,the .castep file and the .md file from the previous run are present in the currentdirectory. If the seed-name of the new run is the same as for the old, the command

continuation = default

will suffice. To continue the run from a checkpoint filemy_md_run.check use:

continuation = my_md_run.check

2.5.1 Changing Parameters on Continuation

Check-pointing is particularly useful for MD calculationswhere we often requiremany thousands of time-steps to extract useful information. Another important

Page 15: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 14

benefit is the ability to halt a calculation, and continue from a checkpoint witha revised set of MD parameters. For example one may wish to alter the targetthermostat temperature, or the cell relaxation time without having to restart therun from the unequilibrated configuration.

All options described in the above sections can be changed ona restart, i.e. it ispossible to change ensemble, thermostat and barostat schemes, relaxation times,time-step, constraints e.t.c by specifying new values in the input files for the newrun. It is not possible to change the number of atoms/electrons in the cell. Caremust be taken when changing parameters on a restart. For example a large dis-continuous change in the specified temperature or pressure will perturb a systemaway from equilibrium. In such cases the system should not besampled untilre-equilibrated.

Although it is possible to change electronic minimisation schemes/parameters ona restart, this is somewhat unwise for obvious reasons.

2.5.2 On-The-Fly Parameter Changes

In fact, molecular dynamics parameters can be changed without having to halt thecalculation at all! At the end of each MD step, the parametersfile is re-read. Anyparameters in this file which differ from those currently in use will be updatedbefore the next MD step commences. It is therefore possible to alter the stateof a running calculation by simply making changes to the parameters file whilethe calculation is running. The same considerations/restrictions which apply tochanging parameters on a restart apply to these “on the fly” changes.

2.6 Finite Basis Set Corrections

As previously indicated in section 2.2.3, finite basis set corrections in variablecall calculations are applied by default to reduce the effect of Pulay stress. Witha plane wave basis set, Pulay forces can be shown to vanish andhence in calcula-tions which do not calculate stress, such as NVE or NVT calculations, these cor-rections are off by default. The correction to the energy will be constant through-out the MD run, and so is ignored.

If however,calculate_stress is set to true in a fixed cell ensemble, the finitebasis set corrections will be turned back on by default. It ispossible to overridethis behavior using the parameterfinite_basis_corr, e.g.

finite_basis_corr = none

Page 16: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 15

To turn off the correction completely. Alternatively:

finite_basis_corr = manual

This sets the behavior of the correction to manual. In this case we are required tospecify the derivative dEele troni d lnE ut�off ;required for the correction using the command:

basis_de_loge = -0.365550 eV

Finally we can set the behavior to automatic.

finite_basis_corr = auto

Note that this does not mean the decision on whether or not to perform a correctionis automatic. In this case the correction will be performed regardless of ensembleor thecalculate_stress keyword. The calculation ofbasis_de_logewill be performed automatically by calculating the total energy at a series of cut-off energies. The default is to use 3 cut-off energies at a spacing of 5 eV. This canbe overridden using e.g.

finite_basis_npoints = 5finite_basis_spacing = 2 eV

CASTEP will return an error if two or more of the cut-off energies are sufficientlyclose together that they lead to the same number of plane waves for the given cell.

2.7 Go-Faster Stripes!

Reducing the cost of each MD step is highly desirable to allowa longer simulationfor a given computational cost. In this section we will examine the two methodsCASTEP provides for doing this.

Page 17: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 16

2.7.1 Wave-function Extrapolation

A significant speed up is obtained by not throwing away the Kohn-Sham wave-functions from the previous time-step. At the start of each new step, our self-consistent iteration process begins by minimising the electronic Hamiltonian dueto the charge density at the previous time-step. If the motion of the atoms over atime-step is small, this will then require fewer subsequentSCF iterations to findthe ground state than if we began from scratch.

While this re-use of the wave-functions between time-stepsdoes improve matters,we can go one step further and attempt to extrapolate the old Kohn-Sham wave-functions onto the new ionic positions at each time-step. This will give us an evenbetter starting point for the minimisation process and willtherefore require lessSCF cycles.

In variable cell calculations, in which either the number orinterpretation of planewave co-efficients changes between time-steps, wave-function extrapolation issomewhat more complex. However a speed-up of 2-3 times can still be gainedover unextrapolated calculations in CASTEP.

The extrapolation can be tweaked with themd_extrap parameter. e.g.

md_extrap = none

to disable wave-function extrapolation. The order of the extrapolation schemecan be specified with the value “first”, “ second” or “mixed” to alternatebetween the two. Second order extrapolation tends only to bebeneficial for sys-tems in which the ionic positions change by very little over an MD step.

2.7.2 Tweaking Electronic Convergence for MD

When minimising the total energy in CASTEP, the convergencecriteria is basedon awindow as indicated in figure 2.3.

The default height of the convergence window is1 � 10�5 eV per atom, and thedefault length of the window is 3 SCF iterations. For well behaved MD calcula-tions this can lead to more SCF calculations being performedper time-step thanis required for accurate calculation of forces. For this reason the ability to specifya different convergence window for use during MD simulations is available.

The length of the convergence window for MD can be reduced to aminimum of2 SCF iterations, e.g.

Page 18: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 17

3 4 5 6 7 8SCF Iteration

Ene

rgy

(eV

)

convergence window

Figure 2.3: Convergence of the energy minimisation calculation. The procedureis judged to have converged when the energy has not changed bymore than theheight of the convergence window during a number of SCF iterations equal to thelength of the convergence window.

md_elec_convergence_win = 2

Similarly the height of the convergence window can be increased so as to ensurethe extra iteration inside the window is performing useful minimisation work, e.g.

md_elec_energy_tol = 1.5E-4 eV

This is the energy tolerance per atom specified in any available energy unit.

These parameters are used entirely at your own risk, and you shouldalways com-pare results for a number of MD steps both with and without convergence tweak-ing to ensure convergence is adequate.

2.8 Input Parameters and Defaults

Any/all keywords set in the parameters file may be omitted, inwhich case thedefault values are used. These are listed below for reference.

Page 19: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 2. USAGE, CAPABILITIES AND INPUTS 18

Parameter Default Value

checkpoint¡seedname¿.checkcalculate_stressensemble dependedbackup_interval0num_backup_iter5fixed_npwtruefinite_basis_corrdepends on calculationmd_num_iter100md_delta_t1.0 fsmd_ensembleNVEmd_temperature300 Kmd_thermostatnose-hoovermd_barostatandersen-hoovermd_ion_t 10 xmd_delta_t for Nose-Hoover, 100 xmd_delta_t for Langevinmd_cell_t10 xmd_delta_tmd_nhc_length5md_extrapFIRSTmd_extrap_fittruemd_elec_energy_tolaselec_energy_tolmd_elec_convergence_winaselec_convergence_win

The cell file must contain at the absolute minimum a set of cellvectors and ionicpositions. By default the centre of mass is constrained if nouser or symmetryconstraints are specified. Default external pressure is zero.

Page 20: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

Chapter 3

Understanding the Output

In this chapter we shall briefly describe the output producedduring a CASTEPcalculation. Only the level of detail printed at iprint = 1 will be discussed.

We will show some of the output for the example calculation described in section4.2.

3.1 The .castep file

3.1.1 Header

As well as the usual information printed at the top of the output file, the moleculardynamics data specified in the parameters file is presented.

************************ Molecular Dynamics Parameters ************************

ensemble : NPTvariable cell method : fixed basis qualitypressure : see belowtemperature : 293.0 Kusing : Parrinello-Rahman barostatwith characteristic cell time : 26.00 psusing : Langevin thermostatwith characteristic ionic time : 16.95 pstime step : 0.2000E-02 psnumber of MD steps : 500000using best-fit first order extrapolation for wavefunctions

19

Page 21: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 3. UNDERSTANDING THE OUTPUT 20

backup results every : 5 steps

MD SCF energy / atom convergence tol. : 0.1000E-04 eVMD SCF convergence tolerance window : 3 cycles

**********************************************************************

This amount of information presented in this section will obviously vary depend-ing on the type of calculation being performed, but should beself-explanatory.

3.1.2 Initial cell

The information specified in the .cell file is then output, this will include the ionicpositions any user specified velocities if present, the usual pseudo-potential andk-point information, and details of any constraints. The total energy of the initialcell is then minimised, performing a finite basis set correction along the way ifappropriate.

The message

Starting MD

is then printed, and the MD calculation proper commences. Asthe first time-step will require data on forces, stress (for variable cell calculations) and energies,these are evaluated and printed at this point.

Forces are output in the following format, using the force unit specified by theuser, or the default of eV /A.

******************************** Forces ******************************** Cartesian components (eV/A)* --------------------------------------------------------------------* x y z** Si 1 -0.02632 -0.02632 -0.02632* Si 2 -0.02653 -0.02617 -0.02617* Si 3 -0.02617 -0.02617 -0.02653* Si 4 -0.02617 -0.02653 -0.02617* Si 5 0.00075 0.05164 0.00075

Page 22: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 3. UNDERSTANDING THE OUTPUT 21

* Si 6 0.05204 0.05204 0.05204* Si 7 0.05164 0.00075 0.00075* Si 8 0.00075 0.00075 0.05164***********************************************************************

The stress tensor (if calculated) is output in the specified units of pressure, alongwith the corresponding scalarT = 0 pressure, i.e. one third of the trace of thestress tensor.

***************** Stress Tensor ****************** ** Cartesian components (GPa) ** --------------------------------------------- ** x y z ** ** x 0.009981 1.140649 1.140649 ** y 1.140649 0.009981 1.140649 ** z 1.140649 1.140649 0.009981 ** ** Pressure: -0.0100 ** **************************************************

The current time and MD energies are then printed in the user specified energyunits. Here potential energy refers to the total configurational energy of electronsplus ions obtained from the DFT calculation. Kinetic energyis the classical kineticenergy of theions. Total energy refers to the sum of these two energies.

The enthalpy and the relevant Hamiltonian energy for the ensemble as quoted insection 2.2 is then printed.

The temperature is also output at this point. Note that this is the ionic temperatureonly. If performing a calculation with finite temperature electrons (i.e. EDFT) theelectron temperature may not be the same. Finally total pressure, i.e. the trace ofthe stress tensor plus the kinetic (ideal gas) pressure is printed in the user specifiedpressure units.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx MD Data: xx x

Page 23: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 3. UNDERSTANDING THE OUTPUT 22

x time : 0.000000 ps xx xx Potential Energy: -865.882944 eV xx Kinetic Energy: 0.265113 eV xx Total Energy: -865.617832 eV xx Enthalpy: -865.617735 eV xx Hamilt Energy: -865.617735 eV xx xx Temperature: 293.000000 K xx T/=0 Pressure: 0.172231 GPa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

3.1.3 Iteration

The MD simulation proper now begins.

=================================================================Starting MD iteration 1 ...

=================================================================

Following this message the current cell information is printed and the energy isre-minimised to determine the new forces. The MD step is thenperformed andthe updated force, stress and energy information is printedin the same manner asabove.

-----------------------------------------------------------------... finished MD iteration 1

-----------------------------------------------------------------

The process repeats until the calculation is killed, or the specified number of MDiterations is completed.

3.2 The .md file

The .md file is provided as a single source for the all the dynamical data producedby a CASTEP calculation. In all cases, data is printed in Hartree atomic units.Fortran formating data will be given here for all entries in this file for those whowish to import it into their own analysis codes.

Page 24: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 3. UNDERSTANDING THE OUTPUT 23

Note that unlike the .castep file, the .md file from a previous calculation with thesame seedname will be overwritten, unless the new calculation is a continuationof the original.

3.2.1 Header

At the top of every .md file a header is written as below. The total length is fourlines including blanks. The comments written are taken fromthe cell/parameterfiles.

BEGIN header

This is 8 atom cubic Si cellEND header

This is followed by a blank line. There is a single space at thestart of each non-blank line. This header is written once only.

3.2.2 Time and Energy Data

The next entry will be the data for the first MD step. This begins with the currenttime on the first line, followed by the Total, Hamiltonian, and Kinetic energy onthe second line with the label<-- E.

0.00000000E+000-3.18206146E+001 -3.18108683E+001 9.74270683E-003

Formatting:

format(12x,es18.8e3)format(9x,3(3x,es18.8e3),’ <-- E’)

3.2.3 Thermodynamic Data

The current temperature is then printed with the label<-- T. If the output isfrom a variable cell calculation, orcalculate_stress has been explicitly setto true, the pressure is also printed with the label<-- P.

Page 25: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 3. UNDERSTANDING THE OUTPUT 24

9.27876841E-045.85402338E-06

Formatting:

format(12x,es18.8,T73, ’ <-- T’)format(12x,es18.8,T73, ’ <-- P’)

3.2.4 Cell Data

For all calculations, the current matrix of cell vectors is printed with the label<-- h. Each row gives the three Cartesian components of one of the cell vectors.

1.01599045E+001 0.00000000E+000 0.00000000E+0001.29430839E-017 1.01599045E+001 0.00000000E+0001.29430839E-017 1.29430839E-017 1.01599045E+001

Formatting:

format(9x,3(3x,es18.8e3),’ <-- h’)format(9x,3(3x,es18.8e3),’ <-- h’)format(9x,3(3x,es18.8e3),’ <-- h’)

The remaining cell data is only printed for variable cell calculations, regardlessof the value ofcalculate_stress. First the velocity of each cell vector isprinted with the label<-- hv.

2.80052926E-008 -1.42751448E-007 -1.35787248E-007-1.42751448E-007 2.76907508E-008 -1.44694219E-007-1.35787248E-007 -1.44694219E-007 2.71532850E-008

Formatting:

format(9x,3(3x,es18.8e3),’ <-- hv’)format(9x,3(3x,es18.8e3),’ <-- hv’)format(9x,3(3x,es18.8e3),’ <-- hv’)

The full pressure tensor (including kinetic contributions) is then printed with thelabel<-- S in a similar fashion.

Page 26: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 3. UNDERSTANDING THE OUTPUT 25

-6.21684372E-006 3.03062374E-005 3.23291890E-0053.03062374E-005 -6.06171719E-006 3.31426773E-0053.23291890E-005 3.31426773E-005 -5.79666096E-006

Formatting:

format(9x,3(3x,es18.8e3),’ <-- S’)format(9x,3(3x,es18.8e3),’ <-- S’)format(9x,3(3x,es18.8e3),’ <-- S’)

3.2.5 Ionic Data

Data on the current ionic configuration is then printed. Atoms are identified bytheir chemical symbol in the first column, and number of the atom within thespecies in the second.

First the position vectors of all ions are printed with the label<-- R.

Si 1 1.04834750E-002 1.15560090E-002 7.82230990E-003Si 2 -3.20400394E-003 5.07172565E+000 5.10986361E+000Si 3 5.07271954E+000 5.11656710E+000 -2.45225140E-003Si 4 5.10789066E+000 -2.63240242E-002 5.09753015E+000Si 5 7.57309188E+000 2.52845762E+000 7.57612741E+000Si 6 2.55271297E+000 2.54057876E+000 2.53924276E+000Si 7 2.53422324E+000 7.64091983E+000 7.62428191E+000Si 8 7.63167143E+000 7.59610368E+000 2.52717191E+000

Formatting (for each atom):

format(1x,a3,1x,i4,3(3x,es18.8e3),’ <-- R’)

Velocities are then printed in a similar fashion.

Si 1 5.77278549E-005 7.23673746E-005 4.30349159E-005Si 2 -1.72415752E-005 -5.23270551E-005 1.75385181E-004Si 3 -4.17085102E-005 2.14539848E-004 -1.78769096E-005Si 4 1.58756714E-004 -1.60916056E-004 9.49147966E-005Si 5 -2.70431102E-004 -7.18757382E-005 -2.43440176E-004Si 6 7.51663795E-005 8.70332331E-008 -8.82271461E-006Si 7 -4.19898677E-005 1.31687892E-004 3.60873179E-005Si 8 7.97201068E-005 -1.33563298E-004 -7.92824105E-005

Page 27: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 3. UNDERSTANDING THE OUTPUT 26

Formatting (for each atom):

format(1x,a3,1x,i4,3(3x,es18.8e3),’ <-- V’)

Finally forces are printed.

Si 1 -4.23569381E-003 2.52214252E-003 -2.46018145E-003Si 2 3.06338418E-003 -2.16206923E-003 -5.29928454E-003Si 3 7.37259995E-004 -4.73479365E-003 -2.20030945E-003Si 4 -6.89050954E-003 -2.25153379E-003 -8.37626756E-003Si 5 4.53551291E-003 3.34757083E-003 1.02791157E-002Si 6 2.06737343E-003 2.05175887E-003 2.70990363E-003Si 7 -1.41457164E-003 -9.15433604E-004 1.54850432E-003Si 8 2.13724448E-003 2.14235805E-003 3.79851935E-003

Formatting (for each atom):

format(1x,a3,1x,i4,3(3x,es18.8e3),’ <-- F’)

A blank line is then printed, and the process repeats with thedata from the nexttime-step.

Page 28: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

Chapter 4

Example Calculations

4.1 Isolated Nitrogen molecule (NVE)

This example requires minimal computational effort and should be reproducibleon just about any modern desktop system.

4.1.1 The DFT calculation

As this is a simulation of an isolated molecule, we will use a single k-point (�point) in the electronic structure calculation. The cell file that we will use is givenbelow.

!Example isolated and strained N2 molecule

%BLOCK LATTICE_ABC ! In Angstroms6.2 6.2 6.290.0 90.0 90.0

%ENDBLOCK LATTICE_ABC

%block POSITIONS_FRACN 0.406932 0.500000 0.500000N 0.593068 0.500000 0.500000%endblock POSITIONS_FRAC

%BLOCK SPECIES_POT

27

Page 29: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 28

Figure 4.1: Charge density of the N2 molecule converged w.r.t. basis set size andcell volume.

N N_00.usp%ENDBLOCK SPECIES_POT

%BLOCK KPOINTS_LIST0.0 0.0 0.0 1%ENDBLOCK KPOINTS_LIST

The energy is converged w.r.t. basis set size to within 0.004eV at a cut-off energyof 320 eV. Convergence w.r.t. the size of the super-cell indicates similar accuracywith a cell dimension of 6.2A. The ionic positions have then been contracted tothe resulting equilibrium positions using the BFGS geometry optimiser.

4.1.2 Finding a Suitable Time-step

We now identify a suitable time-step for the md calculation.The ultimate aim isto simulate the longest possible time with the smallest amount of computationaleffort. The choice of time-step is therefore a compromise between a large valuewhich will require less MD steps for a given simulated time, and a small valuefor which better re-use of the previous wave-function will be made allowing each

Page 30: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 29

time-step to be calculated faster. We must also make sure that the time-step issufficiently small that the dynamics correctly conserve thetotal (Hamiltonian)energy of the system.

As a first guess, we will examine the performance with a time-step of 1 fs usingthe following parameters file. Note that the N2 molecule is at its equilibrium bondlength and so will only begin to oscillate if we assign initial velocities. We willset setmd_temperature to 300 K to give the ions some initial velocity.

comment = example NVE dynamics input filetask = molecular dynamics

cut_off_energy = 320 eVfix_occupancy = truexc_functional = LDA

md_ensemble = NVEmd_delta_t = 1.0 fsmd_num_iter = 1000md_temperature = 300 K

rand_seed = 1

We have used a fixed random number seed to ensure results will match those givenhere. Also add

fix_com = .true.

to the cell file. This will keep the N2 molecule in the centre of our cell. Afterrunning with a time-step of 1 fs, repeat the calculation using time-steps of 0.5 fsand 2 fs. It is useful to compare the conservation of the Hamiltonian for each ofthe three runs graphically as in figure 4.2.

Examination of this figure indicates a small but noticeable drift from the initialvalue of the Hamiltonian in the 2 fs case. No advantage in the cpu time per time-step is gained by decreasing to 0.5 fs, and therefore we conclude that the optimaltime-step is around our initial guess of 1 fs.

4.1.3 Eliminating Rotations

In the above MD simulations, velocities were assigned randomly to match an ini-tial temperature, including components not along the direction defined by the N-N

Page 31: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 30

0 500 1000 1500 2000Time (fs)

-540.80-540.79-540.78-540.77-540.76

Ene

rgy

(eV

)HamiltonianPotential Energy

0 500 1000 1500 2000Time (fs)

-540.80-540.79-540.78-540.77-540.76

Ene

rgy

(eV

)

0 500 1000 1500 2000Time (fs)

-540.80-540.79-540.78-540.77-540.76

Ene

rgy

(eV

)

∆t = 0.5 fs

∆t = 1.0 fs

∆t = 2.0 fs

Figure 4.2: Hamiltonian and potential energy for the N2 molecule at 300 K usingthree different time-steps.

bond. This leads to rotation of the molecule as is easily confirmed by visualisa-tion. Two methods for eliminating these rotations are givenbelow.

Specifying Initial Conditions

We can easily eliminate rotations by either specifying the initial velocities manu-ally to only include components in a single direction, or alternatively by specifyingzero initial temperature (and hence zero velocity) and applying a stretch to the N2bond, i.e.

md_temperature = 0 K

in the parameters file, and in the cell file make the following alteration.

%block POSITIONS_FRACN 0.403932 0.500000 0.500000N 0.596068 0.500000 0.500000%endblock POSITIONS_FRAC

This stretches the bond by 0.372Ain the x-direction only. If we now run thissimulation, we should see no rotations.

Page 32: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 31

Using Constraints

A second way of ensuring that the atoms only move in the x-direction, is to specifyconstraints for the y and z co-ordinates of each atom. This requires specificationof four linear constraints in the cell file. We will also keep the centre of massconstrained as before. Note that we cannot allow thefix_com keyword to dothis as it will generate constraints for all three components of the centre of mass,including those we have already constrained by specifying fixed y and z. Wetherefore specify the centre of mass constraint as manual constraint number 5 asbelow.

%BLOCK IONIC_CONSTRAINTS1 N 1 0 1 02 N 2 0 1 03 N 1 0 0 14 N 2 0 0 15 N 1 1 0 05 N 2 1 0 0%ENDBLOCK IONIC_CONSTRAINTS

fix_com = .false.

This method is preferred over the initial conditions method, as it avoids having todetermine the specific initial conditions that would cause the molecule to oscillateat the desired temperature.

4.1.4 Results

After running the simulation for 1000 time-steps, we are in aposition to extractuseful data from the output. The mechanics of this will be discussed later andcan involve either converting the.md file into a format suitable for an analysisprogram, or using UNIX utilities like grep and awk to extractspecific data.

As an example we will examine some properties of the N2 bond. A plot of thebond length as a function of time is shown in figure 4.3 along with its Fouriertransform.

From these plots it is trivial to extract that the average bond length is 1.294Aandthat the bond frequency is 0.0725 fs�1.If we were interested in taking this examplefurther, we could examine the temperature dependence of thebond length andfrequency, and determine the bond dissociation temperature.

Page 33: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 32

0 100 200 300 400 500Time (fs)

1.25

1.3

1.35

r 12 (

Ang

)

0 0.1 0.2 0.3 0.4 0.5

Frequency (fs-1

)

00.0050.01

0.0150.02

FF

T

Figure 4.3: Length of the N2 bond as a function of time, and the correspondingFourier Transform.

4.2 Crystalline Silicon (Parrinello-Rahman NPT)

In our second example, we will use Langevin Parrinello-Rahman dynamics toinvestigate structural fluctuations in silicon. While eachtime-step is computation-ally cheap, this example will require many thousands of MD steps to obtain usefulresults.

4.2.1 The DFT calculation

We will use the following cell file for the MD calculation. This represents thegeometry optimised structure converged with respect to plane wave basis size at250 eV, and with respect to the k-point grid at 2x2x2 k-points. An offset in theMonkhorst-Pack grid appropriate for the diamond structurehas been used. Anexternal pressure of approximately atmospheric has been applied.

%block LATTICE_ABCAng5.37639 5.37639 5.3763990.0 90.0 90.0%endblock LATTICE_ABC

%block POSITIONS_FRACSi 0.000000 0.000000 0.000000Si 0.000000 0.500000 0.500000Si 0.500000 0.500000 0.000000

Page 34: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 33

Si 0.500000 0.000000 0.500000Si 0.750000 0.250000 0.750000Si 0.250000 0.250000 0.250000Si 0.250000 0.750000 0.750000Si 0.750000 0.750000 0.250000

%endblock POSITIONS_FRAC

%block SPECIES_POTSi Si_00.usp%endblock SPECIES_POT

%block external_pressureMPa0.1 0.0 0.0

0.1 0.00.1

%endblock external_pressure

kpoints_mp_grid 2 2 2kpoints_mp_offset 0.125 0.125 0.125

fix_com=true

4.2.2 Molecular Dynamics Parameters

Again we follow a similar procedure to that given in section 4.1.2 to identify asuitable time-step of 2 fs. We also need to identify suitablerelaxation times forthe thermostat and barostat. As discussed in ref.[12], we may wish to compute abulk memory function using an empirical potential for silicon, as well as studyingthe phonon density of states, to compute parameters which will most accuratelyreproduce the bulk dynamics. For this example we will simplyuse “best-guess”parameters which will sacrifice some accuracy in short-termdynamics in favor ofincreased sampling efficiency.

cut_off_energy = 250 eVfix_occupancy = truetask = MOLECULARDYNAMICS

md_num_iter = 500000md_delta_t = 2 fs

Page 35: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 34

0 1 2 3 4 5 6 7 8 9 10Time (ps)

90

91

92

Ang

le αβγ

0 1 2 3 4 5 6 7 8 9 10Time (ps)

5.37

5.38

5.39

Leng

th (

Ang

)

abc

Figure 4.4: Fluctuations in the cell angles and lengths during the first 2000 stepsof the MD run described in the text.

md_ensemble = NPTmd_temperature = 293 Kmd_ion_t = 7.0 psmd_cell_t = 20.0 psmd_thermostat = LANGEVINmd_barostat = PARRINELLO-RAHMANfixed_npw = false

4.2.3 Results After 2000 Time-Steps

[N.B. with long calculations such as this, the unix command

grep -c ’<-- E’ myrun.md

is very useful for counting how many time-steps have been written to the .md file.]

After 2000 steps the system has begun to settle into its equilibrium fluctuations oftemperature and density. Fluctuations in the cell parameters are shown below.

Note that this number of time-steps is insufficient to produce a correctly con-verged distribution of temperature and volume samples. With many thousandsmore steps, it is possible to calculate heat capacity, bulk modulus, and expansioncoefficient from these distributions. See ref.[12] for an example.

Page 36: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 35

Figure 4.5: Structure of n-pentane

4.3 Constrained Pentane Molecule

In this example we will consider the following isomer of pentane (n-pentane).

Note that the five carbon atoms seem to lie in a plane. Here we shall determinehow planar the molecule remains at finite temperature. To do this we will constrainfour of the carbon atoms to lie in a plane, and observe the motion of the fifthcarbon atom relative to the plane.

4.3.1 The DFT Calculation

We will use the following cell file for this simulation. The cell parameters usedrepresent convergence of the total energy with respect to the cell size to with<0.01 eV.

%block lattice_abc7.5 13.0 7.090 90 90%endblock lattice_abc

%block positions_absang

Page 37: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 36

C 3.8907 5.2248 2.3681C 3.3763 6.6756 2.3664C 4.5722 7.6442 2.3695C 4.0585 9.0947 2.3669C 2.6949 4.2567 2.367H 4.4474 5.0677 1.5524H 4.4449 5.0688 3.1857H 2.8231 6.8319 1.5481H 2.8185 6.8323 3.1814H 5.1251 7.4882 3.188H 5.1303 7.4871 1.5548H 4.8356 9.724 2.369H 3.5002 9.2526 3.1815H 3.5054 9.2515 1.5487H 3.0285 3.3141 2.3681H 2.1401 4.4125 1.5496H 2.1376 4.4136 3.1824%endblock positions_abs

%block species_potC C_00.uspH H_00.usp%endblock species_pot

kpoints_mp_grid 1 1 1

A similar convergence with respect to the basis set size is obtained atE ut�off =370 eV.

To constrain all but one carbon atom to lie in its initial of constant z, and to fix thecentre of mass, we add the following constraint informationto the cell file.

%block ionic_constraints1 C 1 0 0 12 C 2 0 0 13 C 3 0 0 14 C 5 0 0 1%endblock ionic_constraints

fix_com=true

Page 38: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 37

i.e. we are insisting that the z co-ordinate of each carbon atom is constant, otherthan the fourth which is located at the end of the chain.

4.3.2 Molecular Dynamics Parameters

We will use the following parameters. These will conduct an NVE ( the onlyensemble appropriate for an isolated molecule ) simulationfor 500 steps, of 1 fseach which was identified as appropriate in the usual way.

task = moleculardynamics

cut_off_energy = 370 eV

md_temperature = 300 kmd_num_iter = 500md_delta_t = 1 fsmd_ensemble = NVE

rand_seed = 1

We have again fixedrand_seed to ensure the results presented here are repro-ducible by the reader. This simulation should run in less than 18 hours on a 2.8GHz Pentium IV.

4.3.3 Results

Plots of the z co-ordinate of each of the five carbon atoms are shown below. Itis clear that the four constrained atoms do not move from their initial z positions.The z co-ordinate of the final carbon atom fluctuates with r.m.s. deviation fromthe mean of just 0.022A.

Page 39: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 4. EXAMPLE CALCULATIONS 38

0 100 200 300 400 5002.32.42.5

Z (

Ang

)

0 100 200 300 400 5002.32.42.5

Z (

Ang

)

0 100 200 300 400 5002.32.42.5

Z (

Ang

)

0 100 200 300 400 5002.32.42.5

Z (

Ang

)

0 100 200 300 400 500Time (fs)

2.32.42.5

Z (

Ang

)

Figure 4.6: Z co-ordinate of the five carbon atoms throughoutthe constrained MDrun.

Page 40: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

Chapter 5

Trajectory Analysis

Although it is expected that most users of CASTEP will wish toimport MD datainto their own analysis codes, a simple such code, tentatively named MDTEP, isavailable below. MDTEP is by no means a comprehensive analysis program, butusers of CASTEP are welcome to use it as a base for more complexcodes.

Users of the Accelrys Materials studio package will of course have access to theincluded visualisation/analysis tools.

5.1 MDTEP Analysis Program

This is available for download by clicking the following link. mdtep.tar.gz1

The included makefile should be easily modified for any system. MDTEP hasbeen tested only on Intel Linux and Sun Solaris platforms, but no problems onother systems are anticipated. Note that GNUMake must be used with this make-file.

Once compiled, an MDTEP input file should be placed in the samedirectory asthe .md and .castep file from which information is to be extracted. The programshould then be invoked with:

mdtep myinputfile.input

The structure of the input file uses FORTRAN name-lists. An example is shownbelow.

1mdtep.tar.gz

39

Page 41: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 5. TRAJECTORY ANALYSIS 40

&RunNameSeedName = ’mymdrun’ Seedname of CASTEP calculation/&Positions MD step at which to begin analysisStart = 1 MD step at which to begin analysisFinal = 800 MD step at which to end analysis/&CalcFlagsCalcRDF = .TRUE. Calculate radial distribution functionCalcVAC = .TRUE. Calculate velocity autocorrelation functionCalcMSD = .TRUE. Calculate mean square displacementCalcHeatCap = .TRUE. Use fluctuations to calculate heat capacityCalcAlphaP = .TRUE. Use fluctuations to calculate expansion coef-ficientCalcBetaT = .TRUE. Use fluctuations to calculate bulk modulusCalcTempDist = .TRUE. Calculate distribution of temperature samplesCalcVolDist = .TRUE. Calculate distribution of volume samplesXmolFile = .TRUE. Generate ¡seedname¿.xmol for visualisationXFSFile = .TRUE. Generate ¡seedname¿.axsf for visualisation/&VACParamsVACLength = 128 Length in MD steps over which VACF calcu-latedVACInterval = 1 Steps between VACF functions to be aver-aged over/&MSDParamsMSDLength = 128 Length in steps over which MSD is calculatedMSDInterval = 1 Steps between MSDs to be averaged over/

Notes:� Quantities calculated from fluctuations require many thousands of MD stepsto produce accurate quantities.� Heat capacity calculations are only valid for simulations using a thermostat.� Expansion coefficient and bulk modulus calculations shouldonly be per-formed for variable cell MD runs.

Page 42: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 5. TRAJECTORY ANALYSIS 41� All calculations based on fluctuations invoke a blocking analysis to estimatethe error in the calculated quantity - see Haile [4] for details.� The distribution of temperature samples is written to file along with the idealcase for large N.� The distribution of volume samples is written to file along with the idealcase calculated assuming the estimate of�T obtained is accurate.

Each calculated quantity is written to a separate output file, prefixed with thecalculation seedname. The names of these files should be selfexplanatory.

As well as computing the quantities specified in the input file, MDTEP writesthe following files, the first three of which are suitable for direct plotting in e.g.gnu-plot or xmgrace.

Energy.dat

This file contains four columns of data, the first being the elapsed simulationtime in picoseconds. The subsequent columns list the total ionic kinetic energy,the Hamiltonian energy for the appropriate ensemble, and the value of the Born-Oppenheimer Hamiltonian.

Cell.dat

This file lists for each time-step (in picoseconds) the nine components of the ma-trix of cell vectors in atom units of length.

Sample.dat

This file contains four columns, listing time in picoseconds, temperature in Kelvin,pressure in mega-pascals, and volume in atomic units.

Forces.dat

This file lists the three components of the force of each atom.The inner loop isover the number of atoms, and the outer loop over the number oftime-steps.

Page 43: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 5. TRAJECTORY ANALYSIS 42

Production.out

This is an intermediate format used when creating .xmol and .xsf files.

5.2 Visualisation

Brief notes on the three visualisation programs which the author finds useful aregiven below.

5.2.1 Jmol

Perhaps the most intuitive visualisation program is jmol, available from http://jmol.sf.net2.As this is Java based, it will run on any platform provided theappropriate run-timeenvironment is installed. Jmol will read xmol files as written by MDTEP withoutmodification.

Jmol allows specification of lattice vectors and hence replication of the CASTEPsuper-cell over space. It will also animate the atomic trajectory. Functionality isavailable to measure inter-atomic distances, bond angles and dihedrals. Jmol isnot however able to animate cell vectors.

5.2.2 GopenMol

Gopenmol is an OpenGL based visualisation package, available from http://www.csc.fi/gopenmol/3.Like jmol it will read and animate xmol files. Features include the ability to out-put a time series of bond lengths and angles, and the ability to superimpose anisosurface of a scalar field such as charge or spin density.

It is available as source-code, or as binaries for Intel-Linux, IBM-AIX, and SG-IRIX.

5.2.3 XCrysDen

XCrysDen can be obtained from http://www.xcrysden.org4. Although it can readxmol files, the axsf files written by MDTEP are the native format. This format

2http://jmol.sf.net3http://www.csc.fi/gopenmol/4http://www.xcrysden.org

Page 44: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 5. TRAJECTORY ANALYSIS 43

Figure 5.1: Jmol showing a snapshot from the 8 atom silicon example simulationdiscussed in section 4.2.

Page 45: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 5. TRAJECTORY ANALYSIS 44

Figure 5.2: Gopenmol showing a snapshot from the constrained n-pentane simu-lation discussed in section 4.3.

includes information about variable cell vectors, making XCrysDen very usefulfor visualisation of variable cell MD calculations.

XCrysDen includes many of the features of Jmol, with the capability to visualisescalar fields at single points in time. It is available as source code or as binariesfor Intel-Linux.

Page 46: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

CHAPTER 5. TRAJECTORY ANALYSIS 45

Figure 5.3: XCrysDen showing a snapshot from the 8 atom silicon example sim-ulation discussed in section 4.2.

Page 47: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

Bibliography

[1] M. P. Allen and D. J. Tildesley.Computer Simulation of Liquids. OxfordUniversity Press, New York, 1987.

[2] H. C. Andersen. Molecular dynamics simulations at constant pressure and/ortemperature.J. Chem. Phys., 71:2384, 1980.

[3] D. Frenkel and B. Smit.Understanding Molecular Simulation: From Algo-rithms to Applications. Academic Press, San Diego, 1996.

[4] J. M. Haile. Molecular Dynamics Simulation - Elementary Methods. Wiley,New York, 1992.

[5] W. G. Hoover. Canonical dynamics - equilibrium phase-space distributions.Phys. Rev. A, 31:1695–1697, 1985.

[6] W. G. Hoover. Constant-pressure equations of motion.Phys. Rev. A,34:2499–2500, 1986.

[7] G. J. Martyna, M. L. Klein, and M. Tuckerman. Nose-hooverchains - thecanonical ensemble via continuous dynamics.J. Chem. Phys., 97:2635–2643, 1992.

[8] G. J. Martyna, J. T. Tobias, and M. L. Klein. Constant pressure moleculardynamics algorithms.J. Chem. Phys., 101(5):4177–4189, 1994.

[9] D. Marx and J. Hutter. Ab initio molecular dynamics: Theory and imple-mentation. In J. Grotendorst, editor,Modern Methods and Algorithms ofQuantum Chemistry, pages 301–449. NIC, FZ Julich, 2000.

[10] M. Parinello and A. Rahman. Crystal structure and pair potentials: Amolecular-dynamics study.Phys. Rev. Lett., page 1196, 1980.

[11] M. Parrinello and A. Rahman. Polymorphic transitions in single-crystals - anew molecular- dynamics method.J. Appl. Phys., 52:7182–7190, 1981.

46

Page 48: Molecular Dynamics In CASTEP - TCM Group · md_ensemble = nvt The systemwillbe evolvedto a specific temperature defined us ingthe md_temperature keyword as used above. Initial velocities

BIBLIOGRAPHY 47

[12] D. Quigley and M. I. J. Probert. Langevin dynamics in constant pressureextended systems.J.Chem.Phys, 120(24):11432–11442, 2004.


Recommended