• Non ci sono risultati.

Canonical sampling through velocity rescaling

N/A
N/A
Protected

Academic year: 2021

Condividi "Canonical sampling through velocity rescaling"

Copied!
7
0
0

Testo completo

(1)

Canonical sampling through velocity rescaling

Giovanni Bussi,a兲Davide Donadio, and Michele Parrinello

Computational Science, Department of Chemistry and Applied Biosciences, ETH Zürich, USI Campus, Via Giuseppe Buffi 13, CH-6900 Lugano, Switzerland

共Received 22 September 2006; accepted 17 November 2006; published online 3 January 2007兲 The authors present a new molecular dynamics algorithm for sampling the canonical distribution. In this approach the velocities of all the particles are rescaled by a properly chosen random factor. The algorithm is formally justified and it is shown that, in spite of its stochastic nature, a quantity can still be defined that remains constant during the evolution. In numerical applications this quantity can be used to measure the accuracy of the sampling. The authors illustrate the properties of this new method on Lennard-Jones and TIP4P water models in the solid and liquid phases. Its performance is excellent and largely independent of the thermostat parameter also with regard to the dynamic properties. © 2007 American Institute of Physics.关DOI:10.1063/1.2408420兴

I. INTRODUCTION

Controlling the temperature and assessing the quality of the trajectories generated are crucial issues in any molecular dynamics simulation.1,2 Let us first recall that in conven-tional molecular dynamics the microcanonical ensemble

NVE is generated due to the conservation laws of Hamilton’s

equations. In this ensemble the number of particles N, the volume V, and the energy E are kept constant. In the early days of molecular dynamics the temperature was controlled by rescaling the velocities until the system was equilibrated at the target temperature. Energy conservation was also closely monitored in order to check that the correct NVE ensemble was being sampled and as a way of choosing the integration time step. Furthermore, energy conservation pro-vided a convenient tool for controlling that the code was free from obvious bugs.

Only in 1980, in a landmark paper,3Andersen suggested that ensembles other than the microcanonical one could be generated in a molecular dynamics run in order to better mimic the experimental conditions. Here we only discuss his proposal for generating the canonical ensemble NVT, in which the temperature T rather than the energy E is fixed. Andersen’s prescription was rather simple: during the simu-lation a particle is chosen randomly and its velocity extracted from the appropriate Maxwell distribution. While formally correct, Andersen’s thermostat did not become popular. A supposedly poor efficiency was to blame, as well as the fact that discontinuities in the trajectories were introduced. How-ever, its major drawback was probably the fact that one had to deal with an algorithm without the comforting notion of a conserved quantity on which to rely. Another type of stochas-tic dynamics which leads to a canonical distribution is Langevin dynamics.4Such a dynamics is not often used be-cause it does not have an associated conserved quantity, the integration time step is difficult to control, and the trajecto-ries lose their physical meaning unless the friction coefficient is small. For similar reasons, an algorithm5which is close to

the simplified version of ours discussed in Sec. II A has been even less popular. Inspired by the extended Lagrangian ap-proach introduced in Andersen’s paper to control the external pressure, Nosé introduced his by now famous thermostat.6 Differently from Andersen’s thermostat, the latter allowed to control the temperature without using random numbers. Fur-thermore, associated with Nosé’s dynamics there was a con-served quantity. Thus it is not surprising that Nosé’s thermo-stat is widely used, especially in the equivalent form suggested by Hoover.7However, Nosé thermostat can exhibit nonergodic behavior. In order to compensate for this short-coming, the introduction of chains of thermostats was suggested,8 but this spoils the beauty and simplicity of the theory and needs extra tuning.

Alternative thermostats were suggested such as that of Evans and Morriss9in which the total kinetic energy is kept strictly constant. This leads to a well defined ensemble, the so-called isokinetic ensemble, which, however, cannot be ex-perimentally realized. Another very popular thermostat is that of Berendsen et al.10 In this approach Hamilton’s equa-tions are supplemented by a first-order equation for the ki-netic energy, whose driving force is the difference between the instantaneous kinetic energy and its target value. Ber-endsen’s thermostat is stable, simple to implement, and physically appealing; however, it has no conserved quantity and is not associated with a well defined ensemble, except in limiting cases. In spite of this, it is rather widely used.

In this paper we propose a new method for controlling the temperature that removes many of the difficulties men-tioned above. Our method is an extension of the Berendsen thermostat to which a properly constructed random force is added, so as to enforce the correct distribution for the kinetic energy. A relaxation time of the thermostat can be chosen such that the dynamic trajectories are not significantly af-fected. We show that it leads to the correct canonical distri-bution and that there exists a unified scheme in which Ber-endsen’s, Nosé’s, and our thermostat can be formulated. A remarkable result is that a quantity can be defined which is constant and plays a role similar to that of the energy in the microcanonical ensemble. Namely, it can be used to verify a兲Electronic mail: gbussi@ethz.ch

(2)

how much our numerical procedure generates configurations that belong to the desired NVT ensemble and to provide a guideline for the choice of the integration time step. It must be mentioned that all the algorithms presented here are ex-tremely easy to implement.

In Sec. II we shall first present a simpler version of our algorithm which is an extension of the time honored velocity rescaling. Later we shall describe its more general formula-tion, followed by a theoretical analysis of the new approach, a comparison with other schemes, and a discussion of the errors derived from the integration with a finite time step. The following Secs. III and IV are devoted to numerical checks of the theory and to a final discussion, respectively. II. THEORY

A. A canonical velocity-rescaling thermostat

In its simplest formulation, the velocity-rescaling method consists in multiplying the velocities of all the par-ticles by the same factor␣, calculated by enforcing the total kinetic energy K to be equal to the average kinetic energy at the target temperature, K¯ =Nf/ 2␤, where Nfis the number of degrees of freedom and ␤is the inverse temperature. Thus, the rescaling factor␣ for the velocities is obtained as

␣=

K

¯

K. 共1兲

Since the same factor is used for all the particles, there is neither an effect on constrained bond lengths nor on the cen-ter of mass motion. This operation is usually performed at a predetermined frequency during equilibration, or when the kinetic energy exceeds the limits of an interval centered around the target value. The sampled ensemble is not explic-itly known but, since in the thermodynamic limit the average properties do not depend on the ensemble chosen, even this very simple algorithm can be used to produce useful results. However, for small systems or when the observables of in-terest are dependent on the fluctuations rather than on the averages, this method cannot be used. Moreover, it is ques-tionable to assume that this algorithm can be safely com-bined with other methods which require canonical sampling, such as replica-exchange molecular dynamics.11

We propose to modify the way the rescaling factor is calculated, so as to enforce a canonical distribution for the kinetic energy. Instead of forcing the kinetic energy to be exactly equal to K¯ , we select its target value Kt with a sto-chastic procedure aimed at obtaining the desired ensemble. To this effect we evaluate the velocity-rescaling factor as

␣=

Kt

K, 共2兲

where Ktis drawn from the canonical equilibrium distribu-tion for the kinetic energy:

P

¯ 共Kt兲dKt⬀ Kt共Nf/2−1兲e−␤KtdKt. 共3兲

This is equivalent to the method proposed by Heyes,5where one enforces the distribution in Eq. 共3兲 by a Monte Carlo procedure. Between rescalings we evolve the system using

Hamilton’s equations. The number of integration time steps can be fixed or randomly varied. Both the Hamiltonian evo-lution and the velocity rescaling leave a canonical probabil-ity distribution unaltered. Under the condition that the Hamiltonian evolution is ergodic in the microcanonical en-semble, it follows that our method samples the canonical ensemble.12 More precisely, Hamilton’s equations sample a phase-space surface with fixed center of mass and, for non-periodic systems, zero angular momentum. Since the rescal-ing procedure does not change these quantities, our algo-rithm samples only the corresponding slice of the canonical ensemble. We shall neglect this latter effect here and in the following as we have implicitly done in Eq.共3兲.

B. A more elaborate approach

The procedure described above is very simple but dis-turbs considerably the velocities of the particles. In fact, each time the rescaling is applied, the moduli of the velocities will exhibit a fast fluctuation with relative magnitude

1 / Nf. Thus, we propose a smoother approach in which the rescal-ing procedure is distributed among a number of time steps. This new scheme is somehow related to what previously described in the same way as the Berendsen thermostat is related to standard velocity rescaling.

First we note that it is not necessary to draw Ktfrom the distribution in Eq.共3兲at each time step: the only requirement is that the random changes in the kinetic energy leave a canonical distribution unchanged. In particular, the choice of

Ktcan be based on the previous value of K so as to obtain a smoother evolution. We propose a general way of doing this by applying the following prescriptions:

共1兲 Evolve the system for a single time step with Hamil-ton’s equations, using a time-reversible area-preserving integrator such as velocity Verlet.13

共2兲 Calculate the kinetic energy.

共3兲 Evolve the kinetic energy for a time corresponding to a single time step using an auxiliary continuous stochas-tic dynamics.

共4兲 Rescale the velocities so as to enforce this new value of the kinetic energy.

The choice of the stochastic dynamics has some degree of arbitrariness, the only constraint being that it has to leave the canonical distribution in Eq. 共3兲 invariant. Here we choose this dynamics by imposing that it is described by a first-order differential equation in K. Since the auxiliary dy-namics on K is one dimensional, its associated Fokker-Planck equation14must exhibit a zero-current solution. It can be shown that under these conditions the most general form is dK =

D共K兲log P ¯K + ⳵D共K兲K

dt +

2D共K兲dW, 共4兲

where D共K兲 is an arbitrary positive definite function of K,

dW a Wiener noise, and we are using the Itoh convention.14

(3)

dK =

NfD共K兲 2K¯ K 共K¯ − K兲 −D共K兲 K + ⳵D共K兲K

dt +

2D共K兲dW, 共5兲

which can be used to generate the correct canonical distribu-tion. This result is independent of the choice of the function

D共K兲, but different choices can lead to different speeds of

equilibration. Here we choose

D共K兲 =2KK ¯ Nf

, 共6兲

where the arbitrary parameter ␶ has the dimension of time and determines the time scale of the thermostat such as in Berendsen’s formulation. This leads to a very transparent expression for the auxiliary dynamics

dK =共K¯ − K兲dt ␶ + 2

KK¯ Nf dW

␶. 共7兲

Without the stochastic term this equation reduces to that of the standard thermostat of Berendsen. In the limit ␶= 0, the stochastic evolution is instantly thermalized and this algo-rithm reduces exactly to the stochastic velocity-rescaling ap-proach described in Sec. II A. On the other hand, for␶→⬁, the Hamiltonian dynamics is recovered. When a system is far from equilibrium, the deterministic part in Eq.共7兲dominates and our algorithm leads to fast equilibration like the Ber-endsen’s thermostat. Once the equilibrium is reached, the proper canonical ensemble is sampled, at variance with Be-rendsen’s thermostat.

There is no need to apply additional self-consistency procedures to enforce rigid bond constraints, as in the case of Andersen’s thermostat, since the choice of a single rescaling factor for all the atoms automatically preserves bond lengths. Furthermore, the total linear momentum and, for nonperiodic systems, the angular momentum are conserved. The formal-ism can also be trivially extended to thermalize indepen-dently different parts of the system, e.g., solute and solvent, even using different parameters ␶ for the different sub-systems. Interestingly, dissipative particle dynamics15can be included in our scheme if different thermostats are applied to all the particle pairs that are within a given distance.

We have already noted that Berendsen’s thermostat can be recovered from ours by switching off the noise. Also Nosé’s thermostat can be recast in a form that parallels our formulation. To this effect, it is convenient to rewrite the auxiliary variable ␰ of the Nosé-Hoover thermostat in adi-mensional from ␰=␨/␶ and the mass of the thermostat as 共Nf/␤兲␶2. In our scheme, Nosé-Hoover dynamics is obtained through these auxiliary equations for␨and K:

dK = − 2Kdt ␶, 共8a兲 d␨=

K K ¯ − 1

dt ␶. 共8b兲

The corresponding Liouville equation for the probability dis-tribution P共K,␨兲 is ␶⳵P共K,;t兲t = 2␨P + 2KP共K,;t兲K

K − 1

P共K,;t兲 ⳵␨ , 共9兲

which is stationary for

P

¯ 共K,兲dKd⬀ K共Nf/2−1兲e−␤Ke−Nf␨2/2dKd␨ 共10兲

which is the desired distribution. By comparing this formu-lation of the Nosé-Hoover thermostat with our scheme, we see that the variable␨plays the same role as the noise. In the Nosé-Hoover scheme, the chaotic nature of the coupled equations of motion leads to a stochastic␨. When the system to be thermostated is poorly ergodic,␨is no longer stochastic and a chain of thermostats is needed.8

C. Controlling the integration time step

When integrating the equations of motion using a finite time step, a technical but important issue is the choice of an optimal value for the time step. The usual paradigm is to check if the constants of motion are properly conserved. For example, in the microcanonical ensemble, sampled using the Hamilton’s equations, the check is done on the total energy of the system which is given by the Hamiltonian H共x兲, where

x =共p,q兲 is a point in phase space. When the Nosé-Hoover

thermostat is used, the expression for the conserved quantity

HNoséis more complex and can be recast in the form

HNose= H共x兲 + Nf

␨2 2 +

0 t dt

␶ ␨共t

. 共11兲

In this section we propose a quantity that can play the same role for our thermostat, even though we are dealing with a stochastic process.

Let us consider a deterministic or stochastic dynamics aimed at sampling a given probability distribution P¯ 共x兲. It is convenient to consider a discrete form of dynamics. This is not a major restriction and, after all, on the computer any dynamics is implemented as a discrete process. Starting from a point x0in the phase space, we want to generate a sequence of points x1, x2, . . ., distributed according to a probability as close as possible to P¯ 共x兲. Let M共xi+1←xi兲 dxi+1 be the con-ditional probability of reaching the point xi+1 given that the system is at xi. In order to calculate statistical averages which are correct independent of M, each visited point has to be weighted by wi which measures the probability that xiis in the target ensemble. The ratio between the weights of suc-cessive points is

(4)

wi+1 wi =M共xi *← x i+1 * 兲P¯共x i+1 * M共xi+1← xi兲P¯共xi兲 , 共12兲

where the conjugated point xi* is obtained from xiinverting the momenta, i.e., if x =共p,q兲, x*=共−p,q兲. If the dynamics exactly satisfies the detailed balance one must have wi+1/ wi = 1, which implies that w must be constant. However, if P¯ 共x兲 is sampled in an approximated way, the degree to which w is constant can be used to assess the accuracy of the sampling. Rather than in terms of weights, it is convenient to ex-press this principle in terms of an effective energy

H ˜

i= − 1

ln wi. 共13兲

The evolution of H˜ is given by

H ˜

i+1− H˜i= − 1

␤ln

M共xi*← xi+1* 兲P¯共xi+1* 兲 M共xi+1← xi兲P¯共xi兲

= − 1

␤ln

M共xi*← xi+1* 兲

M共xi+1← xi兲

+ H共xi+1兲 − H共xi兲,

共14兲 where the last line follows in the case of a canonical distri-bution P¯ 共x兲⬀e−␤H共x兲.

Let us now make use of this result in the context of our dynamics. This is most conveniently achieved if we solve the equations of motion alternating two steps. One is a velocity Verlet step or any other area-preserving and time-reversible integration algorithm. In a step with such property, M共xi* ←xi+1

* 兲=M共xi+1←xi兲 and the change in H˜ is equal to the change in H. The other is a velocity-rescaling step in which the scaling factor is determined via Eq. 共7兲. If we use the exact solution of Eq. 共7兲 derived in the Appendix, this step satisfies the detailed balance and therefore does not change

H˜ . An idealized but realistic example of time evolution of H

and H˜ is shown in Fig.1.

If we use this analysis and go to the limit of an infini-tesimal time step, we find

H ˜ 共t兲 = H共t兲 −

0 t 共K¯ − K共t

兲兲dt

␶ − 2

0 t

K共t

兲K¯ Nf dW共t

␶ , 共15兲 where the last two terms come from the integration of Eq.共7兲 along the trajectory. Note that a similar integration along the path is present in HNosé. However, in our scheme a stochastic integration is also necessary. In the continuum limit the changes in energy induced by the rescaling compensate ex-actly the fluctuations in H. For a finite time step this com-pensation is only approximate and the conservation of H˜ provides a measure on the accuracy of the integration. This accuracy has to be interpreted in the sense of the ability of generating configurations representative of the ensemble. The physical meaning of Eq.共15兲is that the fluxes of energy between the system and the thermostat are exactly balanced. A further use of H˜ is possible whenever high accuracy results are needed and even the small error derived from the use of a finite time-step integration needs to be eliminated. In practice, one can correct this error by reweighting16 the points with wi⬀e−␤H˜i. Alternatively, segments of trajectories can be used in a hybrid Monte Carlo scheme17 to generate new configurations which are accepted or rejected with prob-ability min共1,e−␤共⌬H˜兲兲.

From the discussion above one understands that in many ways H˜ has a role similar to E in the microcanonical en-semble. It is, however, deeply different: while in the micro-canonical ensemble E defines the ensemble and has a physi-cal meaning, in the canoniphysi-cal ensemble the value of H˜ simply depends on the chosen initial condition. Thus, the value of H˜ can be only compared for points belonging to the same trajectory.

III. APPLICATIONS

In this section we present a number of test applications of our thermostating procedure. Moreover, we compare its properties with those of commonly adopted thermostats, such as the Nosé-Hoover and the Berendsen thermostat. To test the efficiency of our thermostat, we compute the energy fluctuations and the dynamic properties of two model sys-tems, namely, a Lennard-Jones system and water, in their crystalline and liquid phases. All the simulations have been performed using a modified version of theDL POLYcode.18,19 We adopt the parameterization of the Lennard-Jones po-tential for argon, and we simulate a cubic box containing 256 atoms. Calculations have been performed on the crystalline solid fcc phase at a temperature of 20 K and on the liquid phase at 120 K. The cell side is 21.6 Å for the solid and 22.5 Å for the liquid. Water is modeled through the com-monly used TIP4P potential:20water molecules are treated as rigid bodies and interact via the dispersion forces and the electrostatic potential generated by point charges. The long-range electrostatic interactions are treated by the particle mesh Ewald method.21 The energy fluctuations and the dy-namic properties, such as the frequency spectrum and the diffusion coefficient, have been computed on models of

liq-FIG. 1. Schematic time series for H共upper兲 and H˜ 共lower兲, in units of the root-mean-square fluctuation of H. Time is in unit of the integration time step. The solid lines represent the increments due to the velocity Verlet step, which is almost energy preserving. The dashed lines represent the incre-ments due to the velocity rescaling. Since only the changes due to the velocity Verlet steps are accumulated into H˜ , this quantity is almost con-stant. On the other hand, H has the proper distribution.

(5)

uid water and hexagonal ice Ih, in cells containing 360 water molecules with periodic boundary conditions. The model of ice Ih, with a fixed density of 0.96 g / cm3, has been equili-brated at 120 K, while the liquid has a density of 0.99 g / cm3 and is kept at 300 K.

A. Controlling the integration time step

As discussed in Sec. II C, the effective energy H˜ can be used to verify the sampling accuracy and plays a role similar to the total energy in the microcanonical ensemble. In Fig.2 we show the time evolution of H˜ for the Lennard-Jones sys-tem at 120 K with two different integration time steps, namely, ⌬t=5 fs and ⌬t=40 fs. In both cases, we use ␶ = 0.1 ps for the thermostat time scale. With⌬t=5 fs the in-tegration is accurate and the effective energy H˜ is properly conserved, in the sense that it does not exhibit a drift. More-over, its fluctuations are rather small, approximately 0.3 kJ/ mol: for a comparison, the root-mean-square fluctua-tions in H are on the order of 16 kJ/ mol. When the time step is increased to ⌬t=40 fs, the integration is not accurate and there is a systematic drift in the effective energy. For a com-parison we show also the time evolution of E in a conven-tional NVE calculation. The fluctuations and drifts for E in the NVE calculation are similar to the fluctuations and drifts for H˜ in the NVT calculation. We notice that, while in the

NVE calculation the system explodes at some point, the NVT

calculation is always stable, thanks to the thermostat. How-ever, in spite of the stability, the drift in H˜ indicates that the sampling is inaccurate under these conditions.

B. Energy fluctuations

While the average properties are equivalent in all the ensembles, the fluctuations are different. Thus we use the square fluctuations of the configurational and kinetic ener-gies, which are related to the specific heat of the system,1to check whether our algorithm samples the canonical en-semble. Therefore we perform 1 ns long molecular dynamics runs using our thermostat with different choices of the pa-rameter ␶, spanning three orders of magnitude. An integra-tion time step⌬t=5 fs is adopted, which yields a satisfactory

conservation of the effective energy, as verified in the previ-ous section. For comparison, we also calculate the fluctua-tions using the Nosé-Hoover thermostat, which is supposed to sample the proper ensemble. The results for the Lennard-Jones system, both solid and liquid, are presented in Fig.3. The fluctuations are plotted in units of the ideal-gas kinetic-energy fluctuation. For the liquid 关panels 共c兲 and 共d兲兴, the Nosé-Hoover and our thermostat give consistent results for a wide range of values of ␶for both the kinetic and configu-rational energy fluctuations. The Nosé-Hoover begins to fail only in the regime of small␶, due to the way the extra vari-able of the thermostat is integrated. For the solid关panels 共a兲 and 共b兲兴, the ergodicity problems of the Nosé-Hoover ther-mostat appear for ␶⬎0.2 ps, in terms of poor sampling. We notice that increasing␶, the fluctuations tend to their value in the microcanonical ensemble. On the other hand, our proce-dure is correct over the whole␶range, both for the solid and for the liquid. In Fig.3 we also plot the fluctuations calcu-lated using the Berendsen thermostat. It is clear that both for the liquid and for the solid the results are strongly dependent on the choice of the␶parameter. In the limit␶→0 the Ber-endsen thermostat tends to the isokinetic ensemble, which is consistent with the canonical one for properties depending only on configurations:9thus, the fluctuations in the configu-rational energy tend to the canonical limit, while the fluctua-tions in the kinetic energy tend to zero. In Fig.4we present a similar analysis done on water关panels 共c兲 and 共d兲兴 and ice 关panels 共a兲 and 共b兲兴. For this system the equations of motion have been integrated with a time step ⌬t=1 fs. In this case we only performed the calculation with the Nosé-Hoover thermostat and with ours. The Nosé-Hoover thermostat is not efficient for ice in the case of␶larger than 0.2 ps and also for water in the case of␶larger than 2 ps. On the other hand, the performance of our thermostat is again fairly independent from the choice of␶.

FIG. 2. 共Color online兲 Total energy E 共left axis兲 and effective energy H˜ 共right axis兲, respectively, for an NVE simulation and for an NVT simulation using our thermostat, with␶= 0.1 ps, for Lennard-Jones at 120 K. In the upper panel, the calculation is performed with a time step⌬t=5 fs, and E 共or H˜ 兲 does not drift. In the lower panel, the calculation is performed with a

time step⌬t=40 fs and E 共or H˜ 兲 drifts.

FIG. 3. Square fluctuations of the kinetic energy⌬K2and of the potential

energy⌬U2, in units of N

fkB2T2/ 2, for a Lennard-Jones solid at 20 K关panels

共a兲 and 共b兲兴 and liquid at 120 K 关panels 共c兲 and 共d兲兴, using the Berendsen 共쎲, dashed-dotted兲, the Nosé-Hoover 共䊊, dashed兲 and our 共⫻, solid兲 ther-mostat, plotted as function of the characteristic time of the thermostat␶. In these units the analytical value for the fluctuations of the kinetic energy is 1.

(6)

C. Dynamic properties

In order to check to what extent our thermostat affects the dynamic properties of the systems, we have computed the vibrational spectrum of the hydrogen atoms in ice Ihfrom the Fourier transform of the velocity-velocity autocorrelation function. The spectra have been computed, sampling 100 ps long trajectories in the NVT ensemble every 2 fs, at a tem-perature of 120 K, with two different values of the relaxation time␶of the thermostat 共see Fig.5兲. They are compared to the spectrum of frequencies obtained in a run in the micro-canonical ensemble. In all these runs the integration time step⌬t has been reduced to 0.5 fs. Two main regions can be distinguished in the vibrational spectrum of ice: a low fre-quency band corresponding to the translational modes 共on the left in Fig. 5兲 and a band at higher frequency related to the librational modes. Due to the use of a rigid model the high frequency intramolecular modes are irrelevant. All the features of the vibrational spectrum of ice Ih are preserved

when our thermostat is used. When compared with the spec-trum obtained from the NVE simulation, no shift of the fre-quency of the main peaks is observed for ␶= 2 ps and the changes in their intensities are within numerical errors. It is worth noting that, although the thermostat acts directly on the particle velocities, it does not induce the appearance of fictitious peaks in the spectrum. The simulation done with

␶= 0.002 ps shows that with a very short␶the shape of the first translational broad peak is slightly affected共see the inset in Fig. 5兲.

The performances of our thermostat have been tested also with respect to the dynamic properties of liquids, com-puting the self-diffusion coefficient D of TIP4P water. D is computed from the mean square displacement, through Ein-stein’s relation, on 100 ps long simulations equilibrated at a temperature of 300 K. The results for different values of ␶ are reported in TableI and compared to the value of D ex-tracted from an NVE simulation. The results obtained by applying our thermostat are compatible with the values of D reported in literature for the same model of water22and are consistent with the one extracted from the microcanonical run. A marginal variation with respect to the reference value occurs for very small ␶= 0.002 ps.

IV. CONCLUSION

We devised a new thermostat aimed at performing mo-lecular dynamics simulations in the canonical ensemble. This scheme is derived from a modification of the standard veloc-ity rescaling with a properly chosen random factor and gen-eralized to a smoother formulation which resembles the Be-rendsen thermostat. Under the assumption of ergodicity, we proved analytically that our thermostat samples the canonical ensemble. Through a proper combination with a barostat, it can be used to sample the constant-pressure–constant-temperature ensemble. We check the ergodicity assumption on realistic systems and we compare the ergodicity of our procedure with that of the Nosé-Hoover thermostat, finding our method to be more ergodic. We also use the concept of sampling accuracy rather than trajectory accuracy to assess the quality of the numerical integration of our scheme. To this aim, we introduce a new quantity, which we dub effec-tive energy, which measures the ensemble violation. This formalism allows a robust check on the finite time-step errors and can be easily extended to other kinds of stochastic mo-lecular dynamics, such as the Langevin dynamics.

FIG. 4. Square fluctuations of the kinetic energy⌬K2and of the potential

energy⌬U2, in units of N

fkB2T2/ 2, for ice at 120 K关panels 共a兲 and 共b兲兴 and

water at 300 K关panels 共c兲 and 共d兲兴, using the Nosé-Hoover 共䊊, dashed兲 and our共⫻, solid兲 thermostat, plotted as function of the characteristic time of the thermostat␶. In these units the analytical value for the fluctuations of the kinetic energy is 1.

FIG. 5. Vibrational density of states for the hydrogen atom in ice Ih at

120 K. The spectra obtained with different values of the relaxation time␶of our thermostat共dashed and dotted lines兲 are compared to a simulation in the

NVE ensemble共solid line兲.

TABLE I. The diffusion coefficient D of water at 300 K, as a function of the relaxation time␶ of the thermostat. For a comparison, also the value ob-tained from an NVE trajectory is shown.

␶共ps兲 D共10−5cm2/ s 0.002 3.63± 0.01 0.02 3.44± 0.06 0.2 3.51± 0.05 2.0 3.53± 0.01 NVE 3.47± 0.03

(7)

ACKNOWLEDGMENTS

The authors would like to thank Davide Branduardi for useful discussions. Also Gabriele Petraglio is acknowledged for carefully reading the paper.

APPENDIX: EXACT PROPAGATOR FOR THE KINETIC ENERGY

For the thermostat designed here it is essential that the exact solution of Eq.共7兲is used. In the search for an analyti-cal solution, we are inspired by the fact that if each indi-vidual momentum is evolved using a Langevin equation, then the evolution of K is described by the same Eq. 共7兲. Thus we first define an auxiliary set of Nf stochastic pro-cesses xi共t兲 with the following equation of motion:

dxi共t兲 = −xi共t兲 2 dt ␶ + dWi共t兲

␶ . 共A1兲

This is the equation for an overdamped harmonic oscillator which is known also as the Ornstein-Uhlenbeck processes for which an analytical solution exists:23

xi共t兲 = xi共0兲e−t/2␶+

1 − e−t/␶Ri, 共A2兲 where the Ri’s are independent random numbers from a Gaussian distribution with unitary variance. Then we define the variable y y共t兲 = 1 Nf

i=1 Nf xi 2共t兲. 共A3兲

The equation of motion for y is obtained applying the Itoh rules14to Eq.共A1兲and recalling that the increments dWiare independent, dy共t兲 = 共1 − y共t兲兲dt ␶ + 2

y共t兲 Nf dW共t兲

␶ . 共A4兲

Since the equation of motion for x is invariant under rotation, we can assume without loss of generality that at t = 0 the multidimensional vector 兵xi其 is oriented along its first com-ponent,

兵xi共0兲其 = 兵

Nfy共0兲,0, ... 其. 共A5兲

Combining Eqs. 共A3兲 and 共A2兲 we obtain for y共t兲 at finite time, y共t兲 = e−t/␶y共0兲 + 共1 − e−t/␶

i=1 Nf Ri 2 Nf + 2e−t/2␶

1 − e−t/␶

y共0兲 Nf R1. 共A6兲

We now observe that with the substitution y共t兲=Kt/ K, Eq. 共A4兲is equivalent to Eq.共7兲. Thus, with simple algebra, we

find the desired expression for the rescaling factor,

␣2= e⌬t/␶+ NfK 共1 − e⌬t/␶兲共R 1 2+

i=2 Nf Ri2兲 + 2e−⌬t/2␶

K ¯ NfK 共1 − e−⌬t/␶兲R 1. 共A7兲

We observe here that there is no need to draw all the Ri’s Gaussian numbers, because 兺i−2NfR

i

2 can be drawn directly

from the Gamma distribution p共N

f−1兲/2共x兲

= x共Nf−1兲/2−1e−x/⌫共共Nf− 1兲/2兲 if Nf− 1 is even or by adding a

squared random Gaussian number to that extracted from

p共N

f−2兲/2共x兲=x

共Nf−2兲/2−1e−x/⌫共共Nf− 2兲/2兲 if Nf− 1 is odd.24 A

routine that evaluates Eq.共A7兲is available upon request. 1M. P. Allen and D. J. Tildesley, Computer Simulation of Liquids共Oxford

University Press, Oxford, 1987兲.

2D. Frenkel and B. Smit, Understanding Molecular Simulation, 2nd ed.

共Academic, New York, 2002兲.

3H. C. Andersen, J. Chem. Phys. 72, 2384共1980兲. 4T. Schneider and E. Stoll, Phys. Rev. B 17, 1302共1978兲. 5D. M. Heyes, Chem. Phys. 82, 285共1983兲.

6S. Nosé, J. Chem. Phys. 81, 511共1984兲. 7W. G. Hoover, Phys. Rev. A 31, 1695共1985兲.

8G. J. Martyna, M. L. Klein, and M. Tuckerman, J. Chem. Phys. 97, 2635

共1992兲.

9D. J. Evans and G. P. Morriss, Comput. Phys. Rep. 1, 297共1984兲. 10H. J. C. Berendsen, J. P. M. Postma, W. F. van Gunsteren, A. DiNola, and

J. R. Haak, J. Chem. Phys. 81, 3684共1984兲.

11Y. Sugita and Y. Okamoto, Chem. Phys. Lett. 314, 141共1999兲. 12V. I. Manousiouthakis and M. W. Deem, J. Chem. Phys. 110, 2753

共1999兲.

13W. C. Swope, H. C. Andersen, P. H. Berens, and K. R. Wilson, J. Chem.

Phys. 76, 637共1982兲.

14C. W. Gardiner, Handbook of Stochastic Methods, 3rd ed.共Springer, New

York, 2003兲.

15T. Soddemann, B. Dünweg, and K. Kremer, Phys. Rev. E 68, 046702

共2003兲.

16W. H. Wong and F. Liang, Proc. Natl. Acad. Sci. U.S.A. 94, 14220

共1997兲.

17S. Duane, A. D. Kennedy, B. J. Pendleton, and D. Roweth, Phys. Lett. B 195, 216共1987兲.

18W. Smith, M. Leslie, and T. R. Forester,

DL POLY code, Version 2.16, CCLRC Daresbury Laboratory, Daresbury, England.

19W. Smith and T. R. Forester, J. Mol. Graphics 14, 136共1996兲. 20W. L. Jorgensen, J. Chandrasekhar, J. F. Madura, R. W. Impey, and M. L.

Klein, J. Chem. Phys. 79, 926共1983兲.

21T. Darden, D. York, and L. Pedersen, J. Chem. Phys. 98, 10089共1993兲. 22D. van der Spoel, P. J. van Maaren, and H. J. C. Berendsen, J. Chem.

Phys. 108, 10220共1998兲.

23H. Risken, The Fokker-Planck Equation, 2nd ed.共Springer, New York,

1989兲.

24W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery,

Nu-merical Recipes in FORTRAN: The Art of Scientific Computing, 2nd ed.

Riferimenti

Documenti correlati

The frequency separation between the reference laser and the + laser beam is measured with a Fabry-Perot spectrum analyzer and the ring laser perimeter length is corrected in order

Aim of the present work is to evaluate individual response to DAV-therapy in patients affected by MM in relation to genetic polymorphism of two metabolic enzymes,

PTMs on the N-terminal region play a critical role in modulating the APE1 dynamics, as the charge status of this protein domain modulates the catalytic function of APE1 [91, 124],

Detection threshold of Acit, as obtained by simplex-PCR, confirmed that DNA extraction with DNeasy Plant Mini Kit (Qiagen) gives the highest value (1 artificially contaminated

Figure 3: The generalised Hough method applied to a buried pipe of finite diameter in a medium of unknown velocity.. Measurements from up to 4 probe positions are taken, taking

We collect some new results relative to the study of the spectral analysis of matri- ces arising in Galerkin methods based on generalized B-splines with high smoothness.. We

ANNOTAZIONE: Questo è un “author draft” (la prima versione di un articolo successivamente pubblicato, così come è stata inviata dall’autore alla redazione della rivista)..

Allah nous a dit «Il se peut que vous detestiez une chose alors qu elle vous soit unbien et il se peut que vous aimiez une chose alors qu elle vous estnefaste... “- purifier