Hoover NPT dynamics for systems varying in shape and size

12
MOLECULAR PHYSICS, 1993, VOL. 78, No. 3, 533-544 Hoover NPT dynamics fur systems varying in shape and size By SIMONE MELCHIONNA Dipartimento di Fisica, Universita 'La Sapienza', Piazzale Aldo Moro, 2, 00185 Roma, Italy GIOVANNI C1CCOTTI.f Centre Europken de Calcul Atomique et Molkulaire, Bhtiment 506, Universit6 Paris-Sud, 91 405 Orsay, France and BRAD LEE HOLIAN Los Alamos National Laboratory, Los Alamos, New Mexico 87545, USA (Received 9 Jme 1992; accepted I3 July 1992) 'In this paper we write down equations of motion (following the approach pioneered by Hoover) for an exact isothermal-isobaric molecular dynamics simulation, and we extend them to multiple thermostating rates, to a shape-vary- ing cell and to molecular systems, coherently with the previous 'extended system method'. An integration scheme is proposed together with a numerical illustra- tion of the method. 1. Introduction The molecular dynamics simulation of a system in conditions of fixed temperature and pressure is commonly achieved using techniques that have been developed in recent years 11-1 5j. In particular, we refer to the techniques developed by Andersen [l], Parrinello-Rakrnan [14, 151, Nos6 [10-121 and Hoover [g, 91. In the original Andersen method, the MD cell is allowed to change its size isotropically following the deviations of internal pressure from a preset value. In the Parrinello-Rahman extension of Andersen dynamics, the cell can change, more generally, in shape and size. Nos6 added to Andersen dynamics a new degree of freedom that generates, via dynamic scaling of time, the NPT ensemble. The egua- tions of motion of the extended system method are cumbersome to implement in an MD code, especially for the shape-varying box of Parrinello and Rahman. The Hoover version of the N o d and Andersen methods [g] is simpler to un- derstand and to use. However, while the canonical case is well reproduced, the so-called NPT simulation of Hoover has a distribution function which does not correspond exactly to the NPT ensemble. In this paper we improve upon Hoover's equations in order to generate the right NPT trajectory without adding extra degrees of freedom. With this formulation, the extension of the method to multiple thermostats [12], to an equivalent version of the Parrinello-Rahman dynamics [l 4, 151 and to constrained dynamics is fast and nat- 7 Permanent address: Dipartimento di Fisica, Universitri 'La Sapienza', Piazzale Aldo Moro, 2, 00185 Roma, Italy. 0026-8976/93 $10.00 @ 1993 Taylor & Francis Ltd

Transcript of Hoover NPT dynamics for systems varying in shape and size

MOLECULAR PHYSICS, 1993, VOL. 78, No. 3, 533-544

Hoover NPT dynamics fur systems varying in shape and size

By SIMONE MELCHIONNA Dipartimento di Fisica, Universita 'La Sapienza', Piazzale Aldo Moro, 2,

00185 Roma, Italy

GIOVANNI C1CCOTTI.f Centre Europken de Calcul Atomique et Molkulaire, Bhtiment 506,

Universit6 Paris-Sud, 91 405 Orsay, France

and BRAD LEE HOLIAN Los Alamos National Laboratory, Los Alamos, New Mexico 87545, USA

(Received 9 Jme 1992; accepted I 3 July 1992)

'In this paper we write down equations of motion (following the approach pioneered by Hoover) for an exact isothermal-isobaric molecular dynamics simulation, and we extend them to multiple thermostating rates, to a shape-vary- ing cell and to molecular systems, coherently with the previous 'extended system method'. An integration scheme is proposed together with a numerical illustra- tion of the method.

1. Introduction The molecular dynamics simulation of a system in conditions of fixed temperature

and pressure is commonly achieved using techniques that have been developed in recent years 11-1 5j. In particular, we refer to the techniques developed by Andersen [l], Parrinello-Rakrnan [14, 151, Nos6 [10-121 and Hoover [g, 91.

In the original Andersen method, the MD cell is allowed to change its size isotropically following the deviations of internal pressure from a preset value. In the Parrinello-Rahman extension of Andersen dynamics, the cell can change, more generally, in shape and size. Nos6 added to Andersen dynamics a new degree of freedom that generates, via dynamic scaling of time, the NPT ensemble. The egua- tions of motion of the extended system method are cumbersome to implement in an MD code, especially for the shape-varying box of Parrinello and Rahman.

The Hoover version of the N o d and Andersen methods [g] is simpler to un- derstand and to use. However, while the canonical case is well reproduced, the so-called NPT simulation of Hoover has a distribution function which does not correspond exactly to the NPT ensemble.

In this paper we improve upon Hoover's equations in order to generate the right NPT trajectory without adding extra degrees of freedom. With this formulation, the extension of the method to multiple thermostats [12], to an equivalent version of the Parrinello-Rahman dynamics [l 4, 151 and to constrained dynamics is fast and nat-

7 Permanent address: Dipartimento di Fisica, Universitri 'La Sapienza', Piazzale Aldo Moro, 2, 00185 Roma, Italy.

0026-8976/93 $10.00 @ 1993 Taylor & Francis Ltd

534 S. Melchionna et al.

ural. These dynamics are described together with demonstrations that the distribution function corresponds exactly to the NPT ensemble.

2. Isotropic volume fluctuations The extended system method, namely the Nosk-Andersen set of equations [IO],

combines the pioneering works of Andersen [l] and Nos6 [l l] in order to simulate a system in conditions of fixed temperature and pressure. The extended system is a 'virtual' mechanical system whose coordinates and momenta are related to the real variables through a noncanonical transformation. A scaling in space and time of the virtual variables, obtained via the introduction of auxiliary dynamic quantities, produces an isothermal-isobaric trajectory in the phase space of the real system. Temperature and pressure are external parameters kept fixed. They are called T,,, and P,,, respectively.

In the real variables, for a d-dimensional monoatornic system of N particles contained in an isotropically fluctuating volume V, the Nos6-Andersen equations of motion are

st' 3 P = - S + w ( P ( f ) - P,,), where T ( t ) is the instantaneous temperature and P(t) is the sum of the kinetic and virial pressure terms, v, is the thermostating rate, and W plays the role of the mass of the piston. Nos6 [l l] discussed extensively the proper choice for the parameters v, and W, while Ciccotti and Ryckaert [l71 extended the method to molecular systems. In this formulation, the quantity

is a constant of the motion but is not the Harniltonian, and the equations of motion cannot be derived from the canonical equations of motion (k is Boltzmann's constant).

The Nos&-Andersen method is cumbersome to implement in a MD code. Even more critical is the case of the Nos6 thermostat coupled with a cell with time-varying shape, as in the Rahman-Parrinello extension of the method. Moreover, it is not easy to generalize the equations of motion to use more than one thermostating rate. This is of practical interest when dealing with degrees of freedom that relax to equilibrium with different time scales (e.g. translationJrotation versus bond vibration in molecular systems or mixtures with very different atomic masses).

Equations (1) simplify if the volume is kept fixed (constant-temperature Nos6 dynamics). Following Hoover's formulation 181, the constant-temperature dynamics can be obtained by rewriting the equations of motion as

Hoover NPT dynamics 535

where 5 is a 'frictional' coefficient which evolves in time following the deviation of ins tan taneous temperature from the corresponding external parameter.

The NosC-Hoover set fonns a closed set of differential equations and can be integrated easily. A conserved quantity which helps to check the dynamics is, to within a constant, the HeZmholtz free energy [q:

In the same paper, Hoover extended his equations to the isothermal-isobaric case:

V = dVq, where X, = ri/V'Id are the reduced coordinates and v, is the barostating rate.

These dynamics have the unusual equilibrium distribution function

and, consequently, the evolution trajectory in the (v,g,,Y) subspace does not sample exactly the NPT ensemble @? = l /kTm).

We have modified Hoover's equations so that the isothermal-isobaric trajectory is generated:

where R. = &rniri/Xpzj is the centre-of-mass of the system. The piston variable q acts as a strain-rate factor In order to balance the deviations of the instantaneous pressure from the preset value P,, .

Defining the enthalpy (including c n t b u n for the thermostat and barostat) as

536 S. Melchionna et al.

and, following the method of derivation introduced by Hoover [g] and Nos6 [12], it can be shown that the equilibrium distribution function in the variables @,-,pi, V,q,() is proportional to exp[- BNT]:

To show this, let us use the general probability flow equation

where { x k ) are the dynamic variables. Using equations (7), it follows that

On the other hand, since Z,F, = 0,

Comparing the two results we get

or, in other words, we obtain the NPT distribution function. Just as the constant of motion for Nose-Hoover NVT mechanics is the Helmholtz

free energy, here the NPT dynamics conserves the Gibbs free energy

(By definition, the total momentum P = Xipi is zero.)

3. Extension of the equations of motion The simplicity of equations (7) allows us to generalize them to multiple thermo-

stats and to a MD cell of varying shape.

3.1. Multiple thermostats Let US consider n heat baths, each one associated with a subset of g, degrees of

freedom (rai and p,, are the corresponding coordinates and momenta and v, the thermostating rates). For an atomic system consisting of N particles one has x:=1gu = N.

From each class the quantity Ta(t) is calculated from the partial kinetic energy

Hoover NPT dynamics

while P ( t ) i s calculated from the total system

In this case equations (7) become

A demonstration analogous to the one with one temperature control variable can be carried out. Now izYT must be replaced with

The constant of motion is

3.2. Shape-varying box The extension of equations (7) to a box varying in shape, which is particularly well

suited for the simulations of solids, is easily achieved in the framework suggested by Hoover, and is a simple variant of the Parrinello-Rahman approach.

For a crystalline solid, let us replace the internal hydrostatic pressure by the stress tensor P and the variable by the tensor q. The diagonal elements of q tend to adjust the internal pressure to the preset hydrostatic value P,,,, while the off-diagonal elements tend to eliminate nonzero fluctuations of the off-diagonal elements of the stress tensor P. The equation for V is replaced by an equation for the box matrix B = (A,B,C), where A,B,C are the basis vectors of the box. The volume V is given by V = C X B - A = det(h). Instead of equations (7) we can now write

538 S. Melchionna et al.

h = qli. The trace of = hh-' has the property

which we demonstrate now for later use. Let T be the canonical transformation that instantaneously diagonalizes h ( A being

the diagonal counterpart):

Since ii = - T - l TT-'AT + T I L T + T-W (26)

tr(q) = tr(h-l&) = ~ ~ [ ( T - ~ A - I T)(- T-' ~ T - ~ L T + T - ~ I T + T- 'AT) ] = tr[- T-'A,-' TT-' TT-'AT + T-I.4-l TT- 'AT + T-'A-' T T - ~ A ~ ]

Total rotations are avoided when h is a symmetric tensor or else are frozen when h is triangular. P symmetric implies the same for q bat not for h. A way out of this problem is to take all the matrices and tensors appearing in equations (19-23) as triangular [17]. This requires taking in equation (21), in place of the (symmetric) tensor P, its upper triangular part. Triangular matrices form a closed algebra, and therefore the time evolution will conserve the triangular nature of both q and h. The fact that h is triangular is very important to demonstrate that the ensemble is still isothermal-isobaric. Indeed, when h is triangular the only elements of A which are explicitly coupled to the dynamics are the diagonal ones (only det h appears in equation (22) and for h triangular det h = n,h, depends only on the diagonal elements), while the off-diagonal elements are redundant variables (neglecting the possible effect of the boundary conditions) which, then, do not appear in the distribu- tion function (see equation (30)).

The demonstration is performed by calculating the time derivative of

where A : B is the contraction of A and B, A : B = tr(AB). After some algebra one obtains

+ G, p + dNk(T(t) - T,,)(' + V q : P - VPe,,tr(q) = -cdNkText(. (29)

T o obtain the last equation we have used equation (24). For the density function f ( ( r , p ) , ~ , ( q u ~ ,haa)) the flux equation imposes that

Hoover W T dynamics

Using equation (29) it follows that the trajectory is isothermal-isobaric. Now the conserved quantity is

4. Case of constrained dynamics The extension of the present equations to molecular systems is straightforward. As

in the extended system method 13, 5, 13, 17, in the presence of intramolecular geometrical constraints the piston variable q will be coupled only to the centre-of- mass of the single molecules, while the heat bath variable c couples to all degrees of freedom.

Consider a system composed of N molecules, each one made of n atoms. The n atoms are bound between them with K rigid constraints:

cf(IrNi)) = 0, r = 1 , ~ ; p = I ,N, (32) where here and in the following the Greek indices refer to the molecules. The constraining forces acting on the atoms can be written [3]

K acf G,. = - C Af-, l - l ar,

where (A?) are the associated Lagrange multipliers. In the presence of constraints the Parrinell-Rahman dynamics can induce pos-

sible overall rotations of the box, as shown by Nod and Klein [13]. This effect is due to the fact that the stress tensor for molecular systems is no longer symmetrical. To avoid this problem we can take in our equations for the upper triangular part of the syrnmetrized stress tensor which, therefore, will evolve in time, keeping a triangular f o m exactly as described in section 3.2. If we call PTr the upper triangular part of the stress tensor, equations (19-23) become

P& = - + q(R, - R,,) m@

where

S. Melchionna et al.

and instantaneous pressure and temperature are defined as

Notice that, in the case of molecular crystals, the microscopic stress tensor can be nonsymmetric. However, its average value will be symmetric, so that our choice to take only the upper triangular part of it is arbitrary but not dangerous.

To find the distribution function corresponding to the dynamics given by equations (34) together with constraints (32), we can as usual derive first the flux equation (10), compute it, neglecting the constraints, to find

Then we compared equation (37) with the time derivative of

namely

to find the usual result, equation (l 3). The apparent result

is not yet the answer, since it does not consider the constraints. The last step is easily achieved by remembering that a distribution function subjected to constraints is obtained from the unconstrained one by using the general relation [3]

where Zb) is the K X K matrix related to constraints (33) by the relation [17]

Hoover NPT dynamics 54 1

Since the new factors in equation (41) do not depend on (,vap or h, one can again integrate over these variables and find the standard distribution function correspond- ing to the isothermal-isobaric ensemble.

Dealing with a fixed-shape box, equations (34) become

## = F,, + Gd - (c-@ + %P,) M P

where P(t ) is the hydrostatic pressure. It is easy to see that a demonstration similar to the case of a box varying in shape can be performed,

5. Integration of the equations of motion The numerical integration of equations (7, 16 and 19-23) can be performed using

different schemes [6, 31. One way [3] is easily obtained using the Verlet central difference scheme, modified to handle velocity-dependent accelerations.

For example, we can rewrite equations (7):

. . dv2, (In V ) = -

NW,, V ( P ( t ) - Pot).

An efficient approach is to compute the velocities of {r,), In V and C for the step at time (t + h) as a first guess from the formula

and keep these values in memory for the subsequent step, where current pressure and temperature are computed via the momenta p,,(t ):

New particle positions at step ( t + h) are obtained from the standard Verlet algorithm

and velocities at time t from

542 S. Melchionna et al.

The only difference, using the Parrinello-Rahman extension of the equations, is to work with the matrix 1 and use the following scheme.

(1) Predict the velocities of ( r , ) and at time (t + h) using equation (45); (2) Compute, with the standard Verlet algorithm, values for (r , ) and C at time

(t + h) and their velocities at time t. (3) Having computed current box acceleration through

compute now h(t + h) and k( t ) with the standard Verlet algorithm (4) Finally, predict hg(t + h) via equation (45) and %(t + h) using

Such a scheme is efficient, stable and minimal in memory requirements. The numerical results, shown in the subsequent section, encourage the use of this integration scheme.

6. A numerical illustration In this section we report an illustration of the techniques previously described

applied to an atomic solid made of 256 palladium atoms and to an interstitial solid mixture made of 256 palladiums and 20 deuteriums. For both systems the Parrinello- Rahman equations of motion were integrated with a time step of 1 0 - I s S over a length of 50 000 time steps, i.e., 50 ps.

For pure Pd the potential energy was chosen to be 1161

with r, = 3.89A, p = 10.8055A-', q = 3.7301 A-', A = 0*17408eV, and B = 1.7084eV.

For the mixture the additional potential terms were the embedding energy of the deuterium in the electronic gas and the doubly screened Coulombic terms between the ion cores as described in reference [4]. In reference [4] there is also a list of the functional forms and of the parameters we chose. The cut-offs were taken at 6-35 a for all terms.

For pure Pd, a comparison is made with the extended system method integrated as described in reference [S]. For the mixture PdD, two thermostats are applied for the two chemical species. A comparison with the extended system method is not really useful since a single thermostat is able to control only the total kinetic energy of the system and not the partial ones. As a result, if the ratio of masses is large enough (S 50 in our case), the partial kinetic energies fluctuate around different average values without thermalizing in a reasonable span of time.

In the three simulations, external temperature and pressure were set to T,, =z

200 K and P,, = 30 k bar (bar = lo5Pa). The thermostating rates were taken to be v,, = 1-Ops-l, v,, = 2-Ops-l, with a barostating rate v, = 0.1 PS-', while for the extended system method the piston pseudomass was W = 20 amu A4/pd .

The dynamics are entirely satisfactory for the time evolution of the mechanical quantities, and the average temperature and pressure quickly reach a relative plateau. Total momentum stays rigorously zero (within the computer accuracy) in the one- thermostat dynamics and fluctuates around zero for the two-thermostat dynamics, which is not a limitation in many practical cases.

Hoover NPT dynamics

544 S. Melchionna et al.

7. Conclusion In this paper we have used Hoover's approach to write down simple equations of

motion that simulate a system in the NPT ensemble with a fixed-shape volume. The equations improve upon the ones that Hoover gave in reference [a] by introducing the centre-of-mass.

Furthermore, the equations have been extended to more than one thermostat, to Parrinello-Rahman dynamics and to constrained dynamics. In all cases, it has been shown that nearly the same set of equations can be used to bring the correct phase space trajectory, with slight modifications to switch from one dynamics to the other.

The integration scheme we present here is practical, stable, efficient, and easily implemented. No significant differences were found in the simulation of a system performed with the method we described here and with the extended system method.

This work was partially supported by grants from the Italian CNR via the Cray project on statistical mechanics and the Progetto Finalizzato "Sistemi informatici e Calcolo Parallelo". We would also like to thank M. Ferrario for very useful discussions.

References [l] ANDERSEN, H. C., 1980, J. chem. Plays., 72, 2384. 121 BRA&KA, A., and PARRINELLU, M-, 1986, Molec. Phys., 58,989. [3] CICCOTTI, G., and RYCKAERT, J. P-, 1986, Comp. Phys. Rep., 4, 345. [4] DAW, M. S., and BASKES, M. I., 1984, Phys. Rev. B, 29,6443. [5] FERRARIO, M., and RYCKAERT, J. P., 1985, Molec. Phys., 54, 587. [6] HOLIAN, B. L., DE GROOT, A. J., HOOVER, W. G., and HOOVER, C. G., 1990, Phys- Rev.

A, 41,4552. [7] HOLIAN, B. L., POSCH, H. A., and HOOVER, W. G., 1990, Phys. Rev. A, 42,3196. [8] HOOVER, W. G., 1985, Phys. Rev. A, 31, 1695. [9] HOOVER, W. G., 1986, Phys. Rev. A, 34,2499.

[l01 N d , S., 1984, Molec. Phys., 52, 255. [Ill Nos& S., 1984, J. chem. Phys., 81, 511. [l21 No&, S., 1986, Molec. Phys., 57, 187. [l 31 No&, S., and KLEIN, M. L., 1983, Molec. Phys., 50, 1055. [l41 PARRINELLO, M-, and RAHMAN, A., 1981, J. appl. Phys., 52, 7182. [l51 PARRINELLO, M-, and RAHMAN, A., 1982, J. chem. Phys., 76,2662. [l61 ROSATO, V,, GUILLOPE, M-, and LEGRAND, B., 1989, Phi!. MM. A, 59,321. [l71 RYCKAERT, J. P-, and CICCOTTI, G., 1983, J. c h . Phys., 78, 7368.