Simulation Techniques for Calculating Free Energies - de Pablo

0 downloads 0 Views 5MB Size Report
2 Department of Chemical and Biological Engineering, University of ..... simple physical interpretation (e.g., crystalline order in Sect. 3.4). Typically, a canonical .... stages by the transfer of incorrect information, the temperature accumulators can be reset at the ...... D. A. McQuarrie (1976) Statistical Mechanics. HarperCollins ...
Simulation Techniques for Calculating Free Energies M. M¨ uller1 and J.J. de Pablo2 1

2

Institut f¨ ur Theoretische Physik, Georg-August- Universit¨ at, 37077 G¨ ottingen, Germany [email protected] Department of Chemical and Biological Engineering, University of Wisconsin-Madison, Madison Wisconsin 53706-1691, USA [email protected]

Marcus M¨ uller and Juan J. de Pablo

M. M¨ uller and J.J. de Pablo: Simulation Techniques for Calculating Free Energies, Lect. Notes Phys. 703, 67–126 (2006) c Springer-Verlag Berlin Heidelberg 2006 DOI 10.1007/3-540-35273-2 3 

68

M. M¨ uller and J.J. de Pablo

1

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

2

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

2.1 2.2 2.3 2.4 2.5

Weighted Histogram Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multicanonical Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wang-Landau Sampling and DOS Simulations . . . . . . . . . . . . . . . . . . Successive Umbrella Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configurations Inside the Miscibility Gap and Shape Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

70 71 74 84 86

3

Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

3.1 3.2 3.3 3.4 3.5 3.6

Liquid-Vapor Coexistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Demixing of Binary Blends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Compressible Blends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Crystallization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Interface Free Energies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 Protein Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

4

Conclusions and Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

Simulation Techniques for Calculating Free Energies

69

1 Introduction The study of phase transitions has played a central role in the study of condensed matter. Since the first applications of molecular simulations, which provided some of the first evidence in support of a freezing transition in hardsphere systems, to contemporary research on complex systems, including polymers, proteins, or liquid crystals, to name a few, molecular simulations are increasingly providing a standard against which to measure the validity of theoretical predictions or phenomenological explanations of experimentally observed phenomena. This is partly due to significant methodological advances that, over the past decade, have permitted study of systems and problems of considerable complexity. The aim of this chapter is to describe some of these advances in the context of examples taken from our own research. The application of Monte Carlo simulations for the study of phase behavior in fluids attracted considerable interest in the early 90’s, largely as a result of Monte Carlo methods, such as the Gibbs ensemble technique [1], which permitted direct calculation of coexistence properties (e.g., the orthobaric densities of a liquid and vapor phases at a given temperature) in a single simulation, without a need of costly thermodynamic integrations for the calculation of chemical potentials. Perhaps somewhat ironically, some of the latest and most powerful methods for the study of phase behavior have reverted back to the use of thermodynamic integration, albeit in a different form from that employed before the advent of the Gibbs ensemble technique. One of the central concepts that paved the way for the widespread use of free-energy based methods in simulations of phase behavior was the conceptually simple, but highly consequential realization that histograms of data generated at one particular set of thermodynamic conditions could be used to make predictions about the behavior of the system over a wide range of conditions [2, 3]. The so-called weighted histogram analysis or histogram-reweighing technique constitutes an essential component of the methods presented in this chapter, and we therefore begin with a brief description of its implementation. We then discuss multicanonical simulation techniques, Wang-Landau sampling and extensions, and successive umbrella sampling. We close this section on Methods with a discussion of the configurations that one encounters when one uses the order parameter of a first order phase transition as a reaction coordinate between the two coexisting phases. The methodological section is followed by several applications that illustrate the computational methods in the context of examples drawn from our own research. The chapter closes with a brief look ahead.

70

M. M¨ uller and J.J. de Pablo

2 Methods 2.1 Weighted Histogram Analysis In the simplest implementation of a molecular simulation, data corresponding to a specific set of thermodynamic conditions (e.g., number of particles, n, volume, V , and temperature, T , for a canonical ensemble) are used to estimate the ensemble or time average of a property of interest. For a canonical ensemble, for example, the outcome of such a simulation would be a pressure p corresponding to n, V , and T . Histogram reweighting techniques permit calculation of ensemble averages over a range of thermodynamic conditions without having to perform additional simulations. The underlying ideas, introduced by Ferrenberg and Swendsen in the late 80’s [2, 3], provide a simple means for extrapolating data generated at one set of conditions to nearby points in thermodynamic space. For a canonical ensemble, the probability of observing a configuration having energy E at an inverse temperature β = 1/kB T (where kB is Boltzmann’s constant) takes the form Pβ (E) =

Ω(E) exp(−βE) , Z(β)

(1)

where Ω(E) is the density of states of the system and Z(β) is the canonical partition function, given by  Z(β) = Ω(E) exp(−βE) . (2) E

The probability distribution at a nearby inverse temperature, denoted by β  , can be expressed in terms of the distribution at β according to Pβ (E) exp[(β − β  )E] . Pβ  (E) =   E Pβ (E) exp[(β − β )E]

(3)

In other words, by using (3) one can extrapolate data generated at temperature T to nearby temperature T  . The same idea can be used to interpolate data generated from multiple simulations [3]. Consider a series of canonical ensemble Monte-Carlo simulations conducted at r different temperatures. The nth simulation is performed at βn , and the resulting data are stored and sorted in Nn (E) histograms, where the total number of entries is nn . The probability distribution corresponding to an arbitrary temperature β is given by r Nn (E) exp(−βE) Pβ (E) = r n=1 (4) n n=1 n exp(−βn E − fn ) where exp[fn ] =

 E

Pβn (E) ,

(5)

Simulation Techniques for Calculating Free Energies

71

and where fn is a measure of the free energy of the system at temperature βn . The value of fn can be found self-consistently by iterating (4) and (5). Multiple histogram reweighing can therefore yield probability distributions over a broad range of temperatures, along with the corresponding relative free energies corresponding to that range. Equation (4) was derived by minimizing the error that arises when all histograms are recombined to provide thermodynamic information over the entire range of conditions spanned by distinct simulations. Note that histograms corresponding to neighboring conditions must necessarily overlap in order for (4) to be applicable. 2.2 Multicanonical Simulations The range of applicability of histogram extrapolation is large if the fluctuations that arise during the course of the simulation sample states that are also representative of neighboring thermodynamic conditions. This is often the case for small systems, or in the vicinity of a critical point. For large systems, or remote from a critical point, fluctuations are smaller and it is advantageous to sample configurations according to a non-Boltzmann statistical weight, thereby coercing the system to sample configurations that are representative of a wide interval of thermodynamic conditions. Thermal averages, such as the internal energy, E, can then be obtained via a time average over the weighted sequence of visited states. Note, however, that in such a sampling scheme the entropy, S, or free energy, F , cannot be calculated in a direct manner because those quantities cannot be expressed as a function of the particle coordinates; special simulation techniques are required to estimate S and F . We now discuss several techniques that generate configurations according to weights that are generally constructed in such a way as to provide a more uniform sampling of phase space than the Boltzmann weight. It is instructive to note that a number of simulation methods e.g., multicanonical [4, 6, 21] or Wang-Landau techniques [7,8], have been originally formulated in terms of the pair of thermodynamically conjugated variables consisting of the temperature and the energy. Such methods, however, can be carried over to arbitrary pairs of order parameter or reaction coordinate and conjugated field, e.g., (magnetization and magnetic field), (composition and exchange potential), or (number of particles and chemical potential), by simply replacing the energy by the order parameter and the temperature by the thermodynamically conjugated field. The free energy, F , can be obtained by thermodynamic integration of the specific heat, cV , from a reference state interval along a thermodynamically reversible path:    T  S S0  cV (T ) βF = βE − = βE − + dT . (6) kB kB kB T  T0 The specific heat can in turn be obtained in canonical-ensemble simulations from the fluctuations of the internal energy,

72

M. M¨ uller and J.J. de Pablo

cV ≡

E 2  − E2 dE = . dT kB T 2

(7)

In order to estimate the free energy many canonical simulations at different temperatures are necessary; furthermore, it is often difficult to define a suitable reference state with a known entropy S0 . Two alternatives can be followed to overcome these difficulties: (i) expanded ensemble methods and (ii) multicanonical methods. In the expanded ensemble method [9], one considers the conjugated field as a Monte Carlo variable and one introduces moves that allow for altering the conjugated field. Each thermodynamic integration can be cast into this form. The conjugated field over which one integrates (e.g., temperature) can adopt discrete values T1 ≤ Ti ≤ T2 in the interval of interest, including the boundary values. The values have to be chosen such that the order parameter distributions in the canonical ensemble overlap for neighboring values of the conjugated fields, Ti and Ti+1 . States of the expanded ensemble are characterized by the particle coordinates, {ri }, and the conjugated field, Ti . The partition function of the expanded ensemble takes the form    e−w(Ti ) Z(n, V, Ti ) = e−w(Ti ) D[{ri }] exp(−βi E[{ri }]) Zex = T1 ≤Ti ≤T2

T1 ≤Ti ≤T2

(8) where Z(n, V, Ti ) = e−βi F denotes the canonical-ensemble partition function. Here we have introduced weight factors, w(Ti ), that depend only on the value of the conjugated field but not on the microscopic particle configuration, {ri }. They have to be chosen in such a way as to generate an approximately uniform sampling of the different conjugated fields, Ti , throughout the course of the simulation. The probability of finding the system in state Ti is given by P (Ti ) =

e−w(Ti ) Z(n, V, Ti ) . Zex

(9)

To achieve uniform sampling of the different canonical ensembles within an expanded ensemble simulation, the weights should ideally obey P (Ti ) ≈ const



w(Ti ) ≈ ln Z(n, V, Ti ) + const.

(10)

The free energy is then given by: βF = −w(T ) − ln P (T ) − ln Zex .

(11)

Formally, these equations are valid for an arbitrary choice of the weight factors; a “bad” choice, however, does not allow for sufficient sampling of all values of the conjugated field and dramatically reduces the efficiency of the method. The problem of calculating the free energy is therefore shifted to that of obtaining appropriate weights. An optimal choice of the weights, however, requires a working estimate of the free energy difference between the states.

Simulation Techniques for Calculating Free Energies

73

The second scheme – multicanonical simulations [4, 6] – generates configurations according to a non-Boltzmann distribution designed to sample all values of the order parameter (energy) that are pertinent to the interval of the thermodynamic field (temperature) of interest. Multicanonical methods are advantageous for the study of first order phase transitions, where the order parameter connects the two coexisting phases via a reversible path (see Sect. 2.5), or in circumstances where the conjugated field does not have a simple physical interpretation (e.g., crystalline order in Sect. 3.4). Typically, a canonical simulation can only be reweighted by histogram extrapolation techniques [2] in the vicinity of the temperature at which the canonical distribution was sampled. In contrast, a single multicanonical simulation permits calculation of canonical averages over a range of temperatures which would require many canonical simulations. This feature led to the name “multicanonical” [10]. A multicanonical simulation generates configurations according to the partition function  (12) Zmuca = D[{ri }]e−w(E[{ri }]) where w(E) is a weight function that only depends on the internal energy but not explicitly on the particle coordinates, {ri }. If Ω(E) denotes the density of states that corresponds to a given value of the order parameter (i.e., the microcanonical partition function, if we utilize the energy), then the probability of sampling a configuration with order parameter E is given by: Pmuca (E) ∼ Ω(E)e−w(E)

(13)

and the choice w(E) = ln Ω(E) + C, where C is a constant, leads to uniform sampling of the energy range of interest. Boltzmann averages of an observable O at temperature T can be obtained by monitoring the average of this observable, O(E), at a given energy, E, using   dE Ω(E)e−βE O(E) dE Pmuca (E)ew(E)−βE O(E)   = (14) OnV T ≡ dE Ω(E)e−βE dE Pmuca (E)ew(E)−βE Note that for the specific choice, w(E) = E/kB T0 , a multicanonical simulation corresponds to a canonical simulation at temperature T0 , and the equation above corresponds to the Ferrenberg-Swendsen weighted histogram analysis [2, 3] (cf. (4)). The goal of multicanonical sampling is to explore a much wider range of energies in the course of the simulation, thereby enlarging the extrapolation range. The free energy can be obtained from   βF ≡ − ln dE Ω(E)e−βE = − ln dE Pmuca (E)ew(E)−βE + C . (15) Formally, these equations are valid for an arbitrary choice of the weight function, w(E), but a failure to sample all configurations that significantly contribute to canonical averages for a temperature in the interval T1 < T < T2

74

M. M¨ uller and J.J. de Pablo

introduces substantial sampling errors. A necessary condition is that the simulation samples all energies in the interval [EnV T1 : EnV T2 ] with roughly equal probability. Again, the problem of efficient multicanonical sampling is shifted to that of obtaining the appropriate weights. The optimal choice of the weights, however, requires a working estimate of the density of states with a given order parameter. Several methods to obtain these weights are discussed in the following section. 2.3 Wang-Landau Sampling and DOS Simulations As described above, traditional multicanonical algorithms [5] provide an estimate of the density of states through “weights”, w(E), constructed to facilitate or inhibit visits to particular state points according to the frequency with which they are visited. The calculation of the weights is necessarily iterative and, depending on the nature of the problem (e.g., the “roughness” of the underlying free energy profile), can require considerable oversight. In recent years, a different class of algorithms has emerged for direct calculation of the density of states from Monte Carlo simulations [7,8,11,12]. We refer to these algorithms as “density-of-states” (DOS) based techniques. In a recent, powerful implementation of such algorithms by Wang and Landau, a random walk in energy space has been used to visit distinct energy levels [7]; the density of states corresponding to a particular energy level is modified by an arbitrary factor when that level is visited. By controlling and gradually reducing that factor in a systematic manner, an estimate of the density of states is generated in a self-consistent and “self-monitoring” manner. The algorithm relies on a histogram of energies to dictate the rate of convergence of a simulation [7]. A random walk is generated by proposing random trial moves, which are accepted with probability p = min [1, Ω(E1 )/Ω(E2 )], where E1 and E2 denote the potential energy of the system before and after the move, respectively. Every time that an energy state E is visited, a running estimate of the density of states is updated according to Ω(E) = f Ω(E), where f is an arbitrary convergence factor. The energy histogram is also updated; once it becomes sufficiently flat, a simulation “stage” is assumed to be complete, the energy histogram is reset to zero, and √ the convergence factor f is decreased in some prescribed manner (e.g., f = f ). The entire process is repeated until f is very close to 1 (the original literature recommends that ln(f ) attain a value of 10−9 ). Wang and Landau’s original algorithm focused on an Ising system in the canonical ensemble [7]. It was later extended to systems in a continuum and to other ensembles [8, 13–16] and found to be highly effective. Because the running estimate of the density of states changes at every step of the simulation, detailed balance is never satisfied. In practice, however, the convergence factor decreases exponentially, and its final value can become so small as to render the violation of detailed balance essentially non-existent. Given that the convergence factor decreases as the simulation proceeds, configurations generated at different stages of the simulation do not contribute

Simulation Techniques for Calculating Free Energies

75

equally to the estimated density of states. In the final stages of the simulation the convergence factor is so small that the corresponding configurations make a negligible contribution to the density of states. In other words, many of the configurations generated by the simulation are not used efficiently. As described below, one can alleviate this problem by integrating the temperature [17, 18]. The internal energy of a system is related to entropy S and volume V through dE = T dS − p dV, (16) where p is the pressure. The temperature of the system is related to the density of states Ω(n, V, E) by Boltzmann’s equation [19] according to     ∂S ∂ ln Ω(n, V, E) 1 = = kB . (17) T ∂E V ∂E V Equation (17) can be integrated to determine the density of states from knowledge of the temperature: 

E

ln Ω(n, V, E) = E0

1 dE. kB T

(18)

Equation (18) requires that the temperature be known as a function of energy. Evans et al. [20] have shown that an intrinsic temperature can be assigned to an arbitrary configuration of a system. This so-called “configurational temperature” is based entirely on configurational information and is given by    ∇i · Fi − 1 i  , =  (19) kB Tconfig  2 |Fi | i

where subscript i denotes a particle, and Fi represents the force acting on that particle. This configurational temperature can be particularly useful in Monte Carlo simulations, where kinetic energy is not explicitly involved. In the past it has been proposed as a useful tool to diagnose programming errors [21]. The estimator for the configurational entropy can be exploited in the context of DOS simulations in the following way: Four histograms are collected during a simulation; one for the density of states, one for the potential energy, one for the numerator of (19), and one for its denominator [17]. Note that two independent sets of density of states are available at the end of each stage: one from the original density-of-states histogram, and one from the configurational temperature, which can be integrated to provide Ω. In principle, either set can be used as a starting point for the next stage of a simulation. In practice, however, using a combination of these is advantageous.

76

M. M¨ uller and J.J. de Pablo

In the early stages of the simulation, detailed balance is grossly violated as a result of the large value of f . The resulting estimates of configurational temperature are therefore incorrect. In order to avoid contamination of late stages by the transfer of incorrect information, the temperature accumulators can be reset at the end of the early stages, once the density of states is calculated from the temperature. For small enough convergence factors (e.g., ln f < 10−5 ), the slight violations of detailed balance incurred by the method become negligible, and the temperature accumulators need no longer be reset at the end of each stage. Clearly, in the proposed “configurational temperature” algorithm, the dynamically modified density of states only serves to guide a walker through configuration space. The “true”, thermodynamic density of states is calculated from the configurational temperatures accumulated in the simulation. Because all configurations generated in the simulation contribute equally to the estimated temperature, configurations generated at various stages of the simulation contribute equally to Ω. For lattice systems, or for systems interacting through discontinuous potential energy functions (e.g., hard-spheres), (19) cannot be used. In such cases, one can introduce a temperature by resorting to a microcanonical ensemble formulation [22, 23] of the density-of-states algorithm [18]. Figure 1 shows results for a truncated-and-shifted Lennard-Jones fluid (the potential energy is truncated at rc = 2.5σ); σ and  denote the length and energy scale of the potential. Results are shown for a system of n = 400 particles at a density of ρσ 3 = 0.78125, well within the liquid regime [17]. For the random walk algorithm with configurational temperature, the energy window is set to −1930 ≤ E/ < −1580; for the multi-microcanonical ensemble simulation, the energy window is −1500 ≤ E/ < −500. In both cases, the energy window corresponds roughly to temperatures in the range 0.85 < T ∗ ≡ kB T / < 1.5 (i.e. above and below the critical point). In random walk simulations with configurational temperature, the calculations are started with a convergence factor f = exp(0.1). When f > exp(10−5 ), the density of states calculated from the temperature is used as the initial density of states for the next stage, the convergence factor is re1/10 duced by fk+1 = fk , and the temperature accumulators are reset to zero at the end of each stage. For later stages, e.g., f < exp(10−5 ), the density of states generated by the random walker is carried over√to the next stage and the convergence factor is reduced according to fk+1 = fk . The simulation is terminated when the convergence factor satisfies f < exp(10−10 ). To estimate the statistical errors in the estimated density of states, 7 independent simulations are conducted, with exactly the same code, but with different random-number generator seeds. The calculated density of states always contains an arbitrary multiplier; the estimated densities of states from these 7 runs are matched by shifting each ln Ω(E) in such a way as to minimize the total variance.

Simulation Techniques for Calculating Free Energies

77

Statistical Errors in lnΩ(E)

100

10

1

0.1

0.01

−10

10

−8

10

−6

10

10

−4

−2

10

1

Convergence Factor (ln f)

Fig. 1. Statistical errors in the density of states as a function of convergence factor [17]

The diamonds in Fig. 1 show results from the Wang and Landau original algorithm. These errors exhibit two distinct regimes. For large f (e.g., √ f > 10−4 ), the statistical error is proportional to f . In the small f regime (f < 10−6 ), the error curve levels off, and asymptotically converges to a limiting value of approximately 0.1. The main reason for this is that in the Wang-Landau algorithm, configurations generated at different stages of the simulation do not contribute equally to the histograms. The Wang-Landau algorithm leaves the density of states essentially unchanged once f is reduced to less than 10−6 ; additional simulations with smaller f only “polish” the results locally, but do little to decrease the overall quality of the data. If phase space has not been ergodically sampled by the time f reaches about 10−6 , the final result of the simulation is likely to be inaccurate. Using a more stringent criterion for “flatness” only alleviates the problem partially, because the computational demands required to complete a stage increase dramatically. The squares in Fig. 1 show the statistical errors in the density of states calculated from configurational temperature. In contrast to the curve generated through a conventional random walk, the errors steadily decrease as the simulation proceeds. The figure also shows that the statistical errors from the configurational temperature method proposed here are always considerably smaller than those from the Wang-Landau technique. At the end of a simulation, the statistical error from a Wang-Landau calculation is approximately 5 times larger than that from configurational temperature. In other words, thermodynamic-property calculations of comparable accuracy would be 25 times faster in the proposed configurational algorithm than in existing random-walk algorithms.

78

M. M¨ uller and J.J. de Pablo

Systematic Errors in lnΩ(E)

0.10

0.05

0

−0.05

−0.10 −1930

−1830

−1730

−1630

Potential Energy (E)

Fig. 2. Systematic errors in configurational temperatures in the first 4 stages of the simulation. With decreasing magnitude of the errors, the corresponding modification factors are ln f = 0.1, 0.01, 0.001, and 0.0001, respectively

Figure 2 shows the difference between the configurational temperature corresponding to the first 4 stages and the final configurational temperature. The figure shows that in the first few stages, the calculated configurational temperature differs from the “true” value in a systematic manner. The reason for such deviations is that in the first few stages the detailed balance condition is grossly violated. For a large convergence factor, the system is expelled into neighboring energy levels, even if the trial configuration does not conform to that energy level. The figure also shows that at the fourth stage (ln f = 10−4 ), such systematic deviations have already become negligible and are smaller than the random errors; the configurational temperature accumulators need not be reset at the end of each stage once ln f ≤ 10−5 . Figure 3 compares the statistical errors in the heat capacity calculated from a Wang-Landau algorithm, from multi-microcanonical ensemble simulations, and from configurational temperature, as a function of actual CPU time. The error in the original Wang-Landau algorithm becomes almost constant once the simulation is longer than about 8 hours [17]. The error from multi-microcanonical ensemble and configurational-temperature simulations are smaller, and continue decreasing as the simulation proceeds. Recently, it has been proposed that a more efficient version of the original Wang-Landau algorithm can be devised by removing the flatness constraint from the energy histograms [24]. The underlying premise behind non-flat histograms is that the algorithm should maximize the number of round trips of a random walk within an energy range. While that idea has been shown to be effective in the context of spin systems, it is of limited use in the context of complex fluids. The method requires a good initial guess of the density of

Simulation Techniques for Calculating Free Energies

79

Statistical Errors in Cv*

0.1

0.01

0.001 1

10

100

CPU Time (Hour)

Fig. 3. Statistical errors in heat capacity as a function of CPU time. The squares are the results from the Wang-Landau algorithm; the circles are the results from configurational temperature calculations, and the diamonds are the results from multi-microcanonical ensemble simulations [17]

states, which can only be obtained after considerable effort (or multiple iterations of the Wang-Landau algorithm). Our experience suggests that it is more effective to resort to a configurational temperature approach, with multiple overlapping windows [17, 18] whose width and number is adjusted to sample “difficult” regions of phase space more or less exhaustively. The implementation of configurational temperature density-of-states simulations is illustrated here in the context of a protein. The particular protein discussed in this case is the C-terminal fragment of protein G, which has often been used as a benchmark for novel protein-folding algorithms [14]. This 16-residue peptide is believed to assume a β-hairpin configuration in solution. In this example it is modelled using an atomistic representation and the CHARMM19 force field with an implicit solvent [14, 25, 26]. The total energy range of interest is broken up into smaller but slightly overlapping energy windows [Ek− : Ek+ ] (see Fig. 4). In the spirit of parallel tempering [27], neighboring windows are allowed to exchange configurations. The width of individual windows can be adjusted in such a way as to have more configurations in regions where sampling is more demanding. As shown in Fig. 5, high-energy windows include unfolded configurations, whereas low-energy windows are populated by folded configurations. This density of states can subsequently be used to determine any thermodynamic property of interest over the energy range encompassed by the simulation. The heat capacity, for example, which can be determined from fluctuations of the energy according to (7), can be determined to high accuracy and used to extract a precise temperature for the folding transition of this polypeptide. Furthermore, these high accuracy

80

M. M¨ uller and J.J. de Pablo (a) 600

Potential Energy (U) kJ/mol

400 200 0 -200 -400 -600 -800 -1000 -1200 0

0.5

1

1.5

2 6 x 10

MC Steps

(b) 3000

Histogram H (U)

2500

2000

1500

1000

500

0

-1200

-1000 - 800 - 600 - 400 -200

0

200

400

600

Potential Energy (U) kJ/mol

Fig. 4. (a) Evolution of energy in different energy windows during a configurationaltemperature DOS simulation of the C-terminal fragment of Protein G. (b) Representative histogram of visited energy states in overlapping windows [18]

estimates of cv over a relatively wide energy range can be generated on the order of 100 hours of CPU time on a Pentium architecture. Our description thus far of DOS-based methods has centered on calculation of the density of states. A particularly fruitful extension of such methods involves the calculation of a potential of mean force (Φ), or PMF, associated with a specified generalized reaction coordinate, ξ(r) [28,29]. A PMF measures the free energy change as a function of ξ(r) (where r represents a set of Cartesian coordinates). This potential is related to the probability density of finding the system at a specific value ξ of the reaction coordinate ξ(r): P (ξ(r) = ξ) ≡ Ce−βΦ(ξ) ,

(20)

where C is a normalization constant. As we shall later see, the methods of umbrella sampling rely on (20) for estimating free energy changes by altering the potential function with a biasing function designed to sample phase space more efficiently. This bias is later removed and the simulation data are

Simulation Techniques for Calculating Free Energies

81

Fig. 5. Representative configurations of the C-terminal fragment of protein G corresponding to different energy ranges

reweighted to arrive at the correct probability distribution. The potential of mean force is then calculated from: Φ(ξ) = −kB T ln P (ξ) + C .

(21)

Other methods arrive at the potential of mean force by calculating the derivative of the free energy with respect to the constrained generalized coordinate   ξ in a series of simulation runs. A mean force, F ξ = − ∂(Φ(ξ)) ∂(ξ) , can be integrated numerically to yield the corresponding PMF. These simulations involve constraints, and an appropriate correction term must therefore be accounted for in the calculation of the PMF. For a system with no constraints and consisting of N particles with Cartesian coordinates r = (r 1 , r 2 , . . . , r N ), the mean force can be written as:     ∂r ∂ ln |J | ∂E + kB T − δ(ξ(r) − ξ) ∂ξ ∂r ∂r   Fξ = , (22) ˆ − ξ) δ(ξ(r)

82

M. M¨ uller and J.J. de Pablo

where E is the potential energy function and J is the Jacobian associated with the transformation from Cartesian to generalized coordinates. To compute the mean force acting on the end-to-end distance of a molecule, for example, a suitable reaction coordinate is provided by ξ = rij = |r i − r j |, where rij represents the distance between the two terminal sites i and j. The Jacobian, |J |, is a function of the separation rij and can be taken out of the ensemble average to yield [29]:     ∂E 2kB T F ξ= − . (23) + ∂ξ ξ ξ The mean force therefore includes a contribution from the average mechanical force and another contribution arising from the variations of the volume element associated with the reaction coordinate ξ. The free energy change between two states ξ1 and ξ2 can be obtained by integrating (23) according to     ξ2  ξ2 ∂E Φ(ξ2 ) − Φ(ξ1 ) = . (24) dξ − 2kB T ln ∂ξ ξ1 ξ1 Constrained simulations rely on the calculation of the first term of (23) from a series of simulations conducted at different values of ξ. This average force is then corrected by adding the second term of (23), and then numerically integrated to give a potential of mean force for the desired range of ξ. As noted above, the density-of-states method described earlier can be extended to yield accurate estimates of the potential of mean force. The weight factors that dictate the walk in the ξ space can be computed “on the fly” during a simulation in a self-consistent manner. The simulation can be performed without any constraints, which means that the resulting weights can be used directly as in (21) to give the potential of mean force. One can also accumulate the forces acting on the particles that define the reaction coordinate and then use (24) to get the PMF. The computed PMF is therefore available as a continuous function of ξ. In recent work [28,29] we have explored the use of DOS methods in the context of expanded ensembles, where intermediate states are introduced to facilitate the transition between configurations separated by large energy barriers. We refer to the resulting methods through the acronym EXEDOS (for Expanded Ensemble Density of States). The expanded states are usually defined by some reaction coordinate, ξ, and the sampling in ξ space is governed by unknown weights. This so-called expanded-ensemble density of states method has been employed for studies of suspensions of colloidal particles in liquid crystals [28], colloidal suspensions in polymer solutions [30], and proteins on a surface [31]. In one of the examples at the end of this chapter we discuss it in the context of reversible, mechanical stretching of proteins [32]. In that example, the reaction coordinate, ξ, is chosen to be the end-to-end distance between the N and C terminus of the molecule being stretched. In a different

Simulation Techniques for Calculating Free Energies

83

example we discuss it in the context of crystallization [33], where a more elaborate order parameter is necessary. The goal of the method is to perform a random walk in ξ space. Consider a system consisting of N particles interconnected to form a molecule, and having volume V and temperature T . The end-to-end distance of the molecule (ξ) can be discretized into distinct states; each state is characterized by its end-to-end distance, ξ, in some specified range of interest [ξ− ,ξ+ ]; ξ− and ξ+ represent a lower and an upper bound, respectively. The partition function Ω of this expanded ensemble is given by   (25) Ω = Q(N, V, T, ξ)g(ξ)dξ = Qξ g(ξ)dξ , where Qξ is the canonical partition function for that particular state ξ, and g(ξ) is the corresponding weight factor. The probability of visiting a state having extension ξ can be written as P (ξ) =

Qξ g(ξ) . Ω

(26)

The free energy difference between any two states can therefore be calculated from the weight factors, and the population density can be determined from   P (ξ2 ) Qξ g(ξ1 ) Φ(ξ2 ) − Φ(ξ1 ) − kB T ln 2 = −kB T ln + ln . (27) Qξ1 g(ξ2 ) P (ξ1 ) If each state is visited with equal probability, the second term on the right of (27) disappears and the PMF can be computed from Φ(ξ) = −kB T ln g(ξ) + C .

(28)

In the method discussed here, a running estimate of the weight factors can be computed and refined in a self-consistent and self-monitoring manner. At the beginning of a simulation, g(ξ) is assumed to be unity for all states. Trial Monte Carlo moves are accepted with probability   g(ξ1 ) exp(−β∆E) , (29) Pacc (ξ1 → ξ2 ) = min 1, g(ξ2 ) where ξ1 and ξ2 are the end-to-end distances of the system before and after a trial move. After each trial move, the corresponding weight factor is updated by multiplying the current, existing value by a convergence factor, f , that is greater than unity (f > 1), i.e., g(ξ) → g(ξ) f . Every time that g(ξ) is modified, a histogram H(ξ) is also updated. As before, this g(ξ) refinement process continues until H(ξ) becomes sufficiently flat. Once this condition is satisfied, the convergence factor is reduced by an arbitrary amount. We use √ again fnew = fold . The histogram is then reset to zero (H(ξ) = 0), and a

84

M. M¨ uller and J.J. de Pablo

new simulation stage is started. The process is repeated until f is sufficiently small. In addition to computing these weight factors from the histograms of visited states, one can obtain a second estimate from the integration of the mean force, as given by (24). The first term on the right hand side of (23) can be estimated in a density of states simulation. The component of the total force acting on the two sites that define the reaction coordinate along the end-toˆ is accumulated as a function of ξ. At the end of the simulation end vector, ξ, this mean force is corrected by adding the corresponding second term of (23), and then integrated to yield the PMF. As mentioned above, in the earlier stages of the simulation (ln f > 10−5 ), when the convergence factor is large, detailed balance is severely violated. As a result, thermodynamic quantities computed during this time (including average forces) are incorrect. To avoid carrying this error into later stages, the accumulators for average forces are reset at the end of early stages. As the convergence factor decreases (e.g., ln f < 10−5 ), the violation of detailed balance has a smaller effect, and the accumulators need not be reset anymore. 2.4 Successive Umbrella Sampling A complementary and alternative technique to reweighting methods are umbrella sampling strategies. The guiding idea of umbrella sampling [34] is to divide the pertinent range of the order parameter, E, into smaller windows and to investigate one small window after the other. If the windows are sufficiently narrow, the free energy profile will not substantially vary within a window, and a crude estimate of the “weights” is often sufficient to ensure uniform sampling [35]. In the limiting case, the windows just consist of two neighboring values of the order parameter. A histogram Hk (E) monitors how often each state is visited in the k th window [Ek− : Ek+ ]. Care must be exercised at the boundaries of a window to fulfill detailed balance [36]: If a move attempts to leave the window, it is rejected and H(window edge) is incremented by unity. Another question which may arise from the discussion of the boundary is the optimum amount of overlap to minimize the uncertainty of the overall ratio. Here we choose the − . This minimal overlap of one state at the interval boundaries, i.e., Ek+ = Ek−1 is simple to implement and sufficient to match the probability distributions at their boundaries. A larger overlap may reduce the uncertainty but requires a higher computational effort. Let Hk− ≡ Hk (Ek− ) and Hk+ ≡ Hk (Ek+ ) denote the values of the k th histogram at its left and right boundary, and Rk ≡ Hk+ /Hk− characterize their ratio. After a predetermined number of Monte Carlo steps per window, the (unnormalized) probability distribution can recursively be estimated according to:

Simulation Techniques for Calculating Free Energies

P (E) Hk (E) Hk (E) H0+ H1+ k−1 · ··· = Πi=1 Ri · − = H0− H1− Hk− Hk− P (E0 )

85

Hi+ , Hi− (30) when E ∈ [Ek− : Ek+ ]. The ratios in (30) correspond to the Boltzmann factor associated with the free energy difference across the order parameter interval i. We now consider how the overall error depends on the choice of the window size [35]: For clarity, we assume that no sampling difficulties are encountered in our system, i.e., the order parameter in which we reweight (e.g., the energy, E, or the particle number, n) is suitable to flatten and overcome all barriers in the (multidimensional) free energy landscape and the restriction of fluctuations of the average order parameter by the window size does not impart sampling errors onto the simulation [37]. Under these circumstances, it has been suggested [38, 39] that small windows reduce computational effort by a factor of Nk , where Nk denotes the total number of windows into which the sampling range is subdivided: The time τ to obtain a predetermined standard deviation δ of the ratio Rk in a single window is proportional to the square of the window size, ∆k = Ek+ − Ek− . With τ ∼ ∆2k , we get a total computation time (for all windows) of tcpu ∼ Nk ∆2k , implying that the overall error of the simulation is also δ. This contrasts the behavior of a single large  = 1 and ∆m = Nk ∆k yield tcpu = (Nk ∆k )2 = Nk tcpu , which window; Nm suggests that a window size as small as possible should be chosen [38, 39]. Being interested in localizing phase coexistence, however, the pertinent error is related to the free energy difference of the two end points of the order parameter interval that corresponds to the distinct phases. In this case, we have to account for error propagation in (30) and we obtain for the error, ∆, of the + )/P (E1− ) ratio P (EN k  ∆≡δ

+ P (EN ) k

P (E1− )



with

! Nk ! # δRk2 ∼ O(δ Nk ) . ="

Ri ≡

(31)

k=1

Due to error propagation across the windows, the error of each√individual subinterval has to be smaller than the total error, ∆, by a factor of Nk . Thus, √ the time that must be spent in each window to achieve an error of δ = ∆/ Nk is Nk τ and the total simulational effort is Nk2 τ ∼ (Nk ∆k )2 ∼ Nk tcpu , which is identical to the time required for a single large window. This argument implies that the statistical error for a given computational effort is independent from the window size, i.e., the number of intervals the range of order parameter is divided into. A more detailed analysis including possible systematic errors due to (i) estimating probability ratios and (ii) correlations between successive windows can be found in [35]. The computational advantage from subdividing the range of order parameter into windows does not stem from an increased statistical accuracy due to the small correlation times within a window, but from the fact that successive umbrella sampling does not require the independent and computationally costly generation of high-quality “weights”. Making the window size small we

86

M. M¨ uller and J.J. de Pablo

reduce the variation of the free energy across a single interval and achieve sufficiently uniform sampling without or with a very crude approximation of the “weights”. In this sense, successive umbrella sampling is as efficient as a multicanonical simulation with very good “weights”, except that now the “weights” need not be known beforehand. Additionally, the scheme is easy to implement on parallel computers and the range of order parameter can be easily enlarged by simply adding more windows. This computational scheme has successfully been applied to study phase equilibria and interface properties in polymer-solvent mixtures [40,41], polymer-colloid mixtures [42–45] and liquid crystals [46, 47]. As we are sampling one window after the other, efficiency can be increased by combining the scheme with the multicanonical concept. In a multicanonical simulation we replace H(E) in (30) by H(E) exp[w(E)]. In principle, one could use Wang-Landau sampling to estimate the “weights” on the fly. Given that the free energy differences are small a rather crude method often suffices: After P (E) is determined according to (30), w(E) = ln[P (E)] is extrapolated into the next window. The first window is usually unweighted. If, in this case, states are not accessible, w(E) can be altered by a constant amount of kB T in each iteration step. In the limit that each window only contains two states we use linear extrapolation for the second and quadratic extrapolations for all subsequent windows. Then, extrapolated and true values for P (E) only differ by a few percent. The basic idea behind this kind of extrapolation is to flatten the free energy landscape even in the small windows. Depending on the steepness of the considered landscape, this may lead to a significant reduction of the error vis-` a-vis unweighted umbrella sampling. Additionally, one should keep in mind that multicanonical simulations in a single, one-dimensional order parameter are not always sufficient when free energy landscapes become more complex, and that the restriction of fluctuations of the average order parameter in a window can impart sampling problems. The problem of simulating too small windows with umbrella sampling is well known, but difficult to quantify [34]. Hence, in practice, the optimum choice of the window size is a compromise between a small value, which allows for a efficient sampling even in the absence of accurate “weights”, and a value large enough to avoid getting trapped kinetically. This compromise depends on the specific system of interest and its size. A particular aspect of these general issues is discussed further in the next section. 2.5 Configurations Inside the Miscibility Gap and Shape Transitions In the previous section we have outlined computational methods to accurately obtain free energy profiles as a function of an order parameter, E. On the one hand, these one-dimensional free energy profiles contain a wealth of information. On the other hand, the configuration space is of very high dimension and a one-dimensional order parameter might not be sufficient to construct

Simulation Techniques for Calculating Free Energies

87

a thermodynamically reversible path, i.e., even if the histogram of the order parameter is flat the system might still be forced to overcome barriers in order to sample the entire interval of order parameters. This is readily observable in the time sequence of the order parameter: For a “good” choice of the order parameter, E, the system performs a random walk in E. For a “bad” choice of the order parameter the histogram of E is flat, but the range of E can be divided into subintervals. Within a subinterval the different values of the order parameter are sampled in a random walk-like fashion but there is a barrier associated with crossing from one subinterval to another. The seldom crossing of the barriers between subintervals can slow down the simulation considerably even if the “weights” are optimal. The success of the multicanonical method depends on an appropriate identification of the order parameter (or reaction coordinate) that “resolves” all pertinent free energy barriers. We illustrate the behavior for a first order transition between a vapor and a dense liquid in the framework of a simple Lennard-Jones model. The condensation of a vapor into a dense liquid upon cooling is a prototype of a phase transition that is characterized by a single scalar order parameter – the density, ρ. The thermodynamically conjugated field is the chemical potential, µ. The qualitative features, however, are general and carry over to other types of phase coexistence, e.g., Sect. 3.4. At a given temperature, T , and chemical potential, µcoex (T ), a liquid and a vapor coexist if they have the same pressure, pcoex : pliq (T, µcoex ) = pvap (T, µcoex ) = pcoex

(32)

The two coexisting phases are characterized by the two values of their order parameter, ρliq and ρvap . If one prepares a macroscopic system of volume V , at a fixed density, ρvap < ρ < ρliq , inside the miscibility gap, it will phase separate into two macroscopic domains in which the densities attain their coexistence values. The volumes of the domains, Vliq and Vvap , are dictated by the lever rule: Vliq Vvap + ρvap =ρ. (33) ρliq V V The pressure of the system inside the miscibility gap is pcoex independent from density. This macroscopic behavior is in marked contrast to the vander-Waals loop of the pressure, p, which is predicted by analytic theories that consider the behavior of a hypothetical, spatially homogeneous system inside the miscibility gap. Using multicanonical simulation techniques we can sample all configurations in the pertinent interval of density (order parameter) and determine their free energy. It is important to note that the simulation samples all states at a fixed order parameter with the Boltzmann weight of the canonical ensemble. What are the typical configurations that a finite system of volume V adopts inside the miscibility gap in the canonical ensemble [48–55]? Let us consider the condensation of the vapor phase as we increase the density at coexistence. If the excess number of particles, ∆n = (ρ − ρvap )V , is

88

M. M¨ uller and J.J. de Pablo

small, they will homogeneously distribute throughout the simulation cell and form a supersaturated vapor. In this case the excess free energy defined by ∆F (ρ) ≡ F (ρ) − Fvap − takes the form: ∆Fsv (ρ) =

Fliq − Fvap (ρ − ρvap ) ρliq − ρvap

(34)

V ∆ρ2 . 2κ

(35) ρ−ρ

is the where κ denotes the compressibility of the vapor and ∆ρ = ρliq −ρvap vap normalized distance across the miscibility gap. Increasing the excess number of particles (or ∆ρ) we increase the excess free energy quadratically and the curvature is proportional to the compressibility. In a macroscopic system a supersaturated vapor, ∆µ ≡ µ − µcoex > 0, is metastable and the excess number of particles will condense into a drop of radius R that consists of the thermodynamically stable liquid. In the framework of classical nucleation theory, the excess free energy of such a spatially inhomogeneous system can be decomposed into a surface and a volume contribution: Fdrop (R) ≈ Fvap + 4πγR2 −

4π 3 R (ρliq − ρvap )∆µ. 3

(36)

The first term describes the increase of the free energy due to the formation of a liquid-vapor interface and γ denotes the interface free energy per unit area (interface tension). The second term describes the free energy reduction by the formation of the thermodynamically stable phase. In the simplest approximation we assume that (i) all excess particles condense into a single drop and (ii) the density of the drop’s interior corresponds to the liquid, ρliq , and its interface tension is given by the macroscopic value γ. These assumptions are reasonable for large drops. Then the size of the drop is given by the lever rule: 4π 3 R (ρliq − ρvap ) = (ρ − ρvap )V . (37) 3 Since Fliq − Fvap = −∆µV (ρliq − ρvap ) the excess free energy of a droplet is given by the surface contribution ∆Fdrop (R) ≈ 4πγR2 .

(38)

Note that the conjugated field, ∆µ, does not have a direct interpretation in a multicanonical simulation. The two equations, (37) and (38), allow us to calculate the excess free energy as a function of the excess density. To first order we obtain, R ∼ ∆ρ1/3 and ∆Fdrop = g(V ∆ρ)2/3 with g = (4π/9)1/3 γ. A more accurate expression can be obtained by not condensing all excess particles into the drop but allowing the density, ρ , of the surrounding vapor to increase [56]. This increases the free energy of the vapor but it decreases the drop’s radius and the associated

Simulation Techniques for Calculating Free Energies

89

interface free energy. Then one obtains the excess free energy by minimizing with respect to the drop’s radius, R and the vapor density, ρ   3 V − 4π 2  2 3 R (ρ − ρvap ) ∆Fdrop (∆ρ) = min 4πγR + (39) R,ρ 2κ under the constraint ρ V +

4π 3 R (ρliq − ρ ) = V ρ . 3

(40)

This refinement qualitatively captures that the chemical potential for a drop configuration is not ∆µ = µ − µcoex = 0 but rather ∆µ = ∂∆F/∂n. The shift of the chemical potential increases with the interface tension and decreases as the size becomes larger (Kelvin’s equation). If ∆ρ increases further, the drop grows until its size becomes comparable to the linear dimension V 1/3 of the simulation cell. At that point it becomes favorable to form a liquid slab which is separated from the vapor by two interfaces of area V 2/3 . In this case the excess free energy ∆Fslab = 2γV 2/3

(41)

is independent from the excess density ∆ρ. As both, the drop and the slab excess free energies scale like γV 2/3 , the transition from a drop to a slab occurs at a fixed ∆ρ which depends on the aspect ratio of the simulation cell, but which is independent from its volume or the interface tension. Hence, the largest drops that are observable have a radius Rmax ∼ V 1/3 . Increasing the excess density further one observes the reverse set of configurations: From a slab-like configurations one goes to a bubble of vapor surrounded by liquid, and finally to an undersaturated but spatially homogeneous liquid. The free energy profile obtained from Monte Carlo simulations of a small Lennard-Jones monomer system and the above approximations utilizing values of the interface tension and compressibility extracted from independent simulations are shown in Fig. 6. Of course, the simple expressions overestimate the value of the excess free energy, but the qualitative shape of the free energy profile is predicted well. Snapshots of the simulations are presented in Fig. 7. These corroborate the correct identification of the dominant system configurations. From the dependence of the free energy profile on the excess density it is apparent that the free energies of the supersaturated vapor and the drop will exhibit an intersection point. For small excess densities the homogeneous supersaturated vapor, ∆Fsv ∼ ∆ρ2 , has the lower free energy while for larger excess densities the drop configuration, ∆Fdrop ∼ ∆ρ2/3 , will be more stable. The “transition” between the supersaturated vapor and the configuration containing a drop is called droplet evaporation/condensation [50,54,55]. From the two simple expressions we can readily read off that droplet condensation occurs at

90

M. M¨ uller and J.J. de Pablo 2

F=2L γ

80

∆F

60

2

4πR γ

40 20 k1∆ρ

0

0

2

0.2

k2∆ρ

0.4

0.6

0.8

2

1

∆ρ Fig. 6. Grand-canonical simulation of a Lennard-Jones monomer system. Particles interact and potential of the form: ELJ = ' truncated Lennard-Jones $% & via %a shifted √ &6 12 127 for distances, r ≤ 2 6 2σ, and E = 0 for larger particle 4 σr − σr + 16384 separations. The free energy profile ∆F (in units of ) has been obtained from the probability distribution of the order parameter, ρ, in grand-canonical simulations for a cubic simulation cell of linear dimension L = 11.3 σ and kB T / = 0.78. The phenomenological expressions (35), (38), and (41) for the free energy are also indicated using γ = 0.291 σ2 . Circles mark densities at which typical configurations are visualized in Fig. 7

Fig. 7. Typical system configurations for the same parameters as in Fig. 6. The density is ∆ρ = 0, 0.184, 0.286, 0.498. Only a thin slice of the simulation box is shown in the right-most image. Each monomer is represented by a sphere of diameter 1.12 σ, which corresponds to the minimum of the Lennard-Jones potential

∆ρdc = (2κg)3/4 V −1/4

(42)

where g is defined on p. 88. Of course, for any finite simulation cell going from a supersaturated vapor to a drop is not a sharp transition in a thermodynamic sense because the free energy difference between the two states remains finite. Thus the “transition” will be rounded over a range of densities δρ = ∆ρ − ∆ρdc where the free energy difference between the two states – supersaturated vapor and drop – is comparable to the thermal energy scale, δF = |∆Fdrop −

Simulation Techniques for Calculating Free Energies

91

∆Fsv | ∼ O(kB T ). Using the above expressions one can expand the free energy difference between the drop and the supersaturated vapor as a function of the distance from the droplet evaporation/condensation: ) )3/4 ( 3( ∆ρ − (2κg)3/4 V −1/4 , (43) [2κ]−1/3 gV δF ≈ − 4 % &−3/4 This estimate yields δρ ∼ κ−1/3 gV for the width of the transition region. As we increase the system size, the excess density at which the supersaturated homogeneous vapor is stable decreases like V −1/4 but the smallest drops that are observable at that density are of radius Rmin ∼ V 1/4 , i.e., they increase with system size. In the following we illustrate in somewhat more detail the droplet evaporation/condensation in a finite-sized system of Lennard-Jones monomers. In order to accurately locate the droplet condensation, we regard the derivative of the free energy ∆µ ≡ ∂∆F/∂n. The results for such a system are shown in Fig. 8. Inside the miscibility gap and for finite V , ∆µ does not remain constant inside the miscibility gap as suggested by macroscopic arguments. First the chemical potential, ∆µ, linearly increases with the excess density, ∆ρ. This behavior characterizes the homogeneous, supersaturated vapor. Further inside the miscibility gap, ∆µ exhibits an s-shaped variation as a function of ∆ρ. At the densities marked by the symbol ◦ we store configurations for further analysis. After the simulation, the distribution, P (Nc ), of cluster sizes was determined. Any ensemble of particles whose distance is smaller than 1.5σ is assumed to belong to the same cluster (Stillinger criterion) [57]. For

∂β∆µ / ∂n

0.8

β∆µ

0.7

0.6

320 340 360 380 400

n

0.5

0.4 320

340

360

380

400

420

n

Fig. 8. Plot of ∆µ/kB T vs. the number of particles n, for a Lennard-Jones fluid in a cubic simulation box of size L = 22.5σ at kB T / = 0.68. ∆µ = µ − µcoex is the distance from bulk coexistence. ◦ denote states at which configurations have been stored for further analysis (Figs. 9 and 10). The inset shows the derivative of ∆µ w.r.t. the number of particles. From MacDowell et al. [55]

92

M. M¨ uller and J.J. de Pablo

N=380

N=375

P(µ)

ln P(Nc)

N=370

N=365

n=355 n=365

N=360

n=370 N=355

n=380

0

40

80

120 160 200 240 Nc

3.8

4

4.2 -βµ

4.4

4.6

Fig. 9. Distribution P (Nc ) of the cluster size Nc for several choices of particle number, n, (left) and the corresponding distribution of the chemical potential of the supersaturated gas P (∆µ) obtained by Widom’s particle insertion attempts (right). System parameters are the same as in Fig. 8. From MacDowell et al. [55]

n ≤ 350, i.e., on the ascending branch of the ∆µ vs. n curve in Fig. 8, P (Nc ) is monotonically decreasing with cluster size, Nc (not shown). This distribution characterizes the homogeneous supersaturated vapor. For larger supersaturation, n ≈ 355, a peak around Nc ≈ 120 appears. This maximum becomes more pronounced and moves to larger sizes, Nc , as n increases. It corresponds to a single large liquid drop. Such a liquid drop, however, cannot be found in all sampled configurations; but rather some configurations contain a drop while others correspond to a supersaturated vapor. This is most clearly observed when we investigate the probability distribution of the chemical potential, ∆µ. This quantity has been calculated by performing Widom’s particle insertion attempts into the stored configurations. For small particle numbers, n, the distribution of chemical potentials consists of a single peak that characterizes the supersaturated vapor. Upon increasing the particle number a second peak occurs at more negative values of µ. These lower values correspond to configurations with a drop: Some of the excess particles have condensed into the drop and the concomitant reduction of the density of the surrounding vapor gives rise to a lower chemical potential. Therefore the decrease of the chemical potential upon increasing of the particle number in Fig. 8 indicates the droplet evaporation/condensation and gives rise to the s-shaped behavior of the ∆µ vs. ∆ρ curve. From the broad distributions and the fact that supersaturated vapor and drop configurations can be observed over an extended interval of particle numbers (or temperature) it is apparent that in

Simulation Techniques for Calculating Free Energies

93

Fig. 10. Two snapshots of configurations at the transition point (n = 365 particles): homogeneous, supersaturated vapor (left) and drop (right). System parameters are the same as in Fig. 8. From MacDowell et al. [55]

a finite-sized system the “transition” is not a sharp one but rather a gradual crossover from configurations dominated by a homogeneous distribution of particles to configurations that contain a drop occurs. Two typical snapshots of these configurations at the same number of particles are presented in Fig. 10. In the course of the simulations the system switches from one to the other conformation forth and back. The dependence on the system size is explored in Fig. 11: In the left panel we plot the chemical potential vs. density for system sizes ranging from L = 11.3σ to 22.5σ. The turning point of the curves shifts closer to the coexistence density of the vapor, ∆ρ → 0, as we increase the system size. Also the maximum slope increases with increasing L, indicating that for L → ∞ a sharp transition occurs. The right panel of Fig. 11 presents the probability distribution of the energy, U , at the droplet evaporation/condensation for different system sizes. In qualitative agreement with the expectations the droplet evaporation/condensation becomes sharper and both states (the supersaturated vapor and drop) become more separated as we increase the system size. From the turning points of the ∆µ vs. ∆ρ curves we estimate the location of the droplet evaporation/condensation. The inset of Fig. 11 (right) shows the dependence of ∆ρdc on the system size. The data are compatible with an effective power law ∆ρdc ∼ V −0.35 , while the phenomenological consideration (see (42)) yields an exponent −1/4. The deviations can be traced back to the small system sizes: (i) the drop evaporation/condensation still occurs far inside the miscibility gap such that the simple compressibility approximation in (35) breaks down and (ii) the drop is not large enough to neglect additional contributions to the excess free energy, e.g., due to curvature effects. Similarly, only the gross qualitative features of ∆F (∆ρ) in Fig. 6 are described by equations

94

M. M¨ uller and J.J. de Pablo 1 ρ-ρc = 0.604*L

P(-βU)

L=11.3σ

β∆µ

-1.065

ρ-ρc

0.8

0.6 L=13.5σ

L L=15.8σ

0.4 L=22.5σ

0.2

0

0.02

L=20.3σ

0.04

0.06 3

ρ-ρc [1/σ ]

L=22.5σ L=20.3σ L=18σ L=15.8σ

L=18.3σ

0.08

0.1

0

0.5

1

1.5 -βU [ε]

2

2.5

Fig. 11. Left panel: Chemical potential vs density loops for T /kB T = 0.68 and several system sizes as indicated in the key. Right panel: Distribution of the energy per particle for different system sizes at the droplet condensation. Inset: ρ − ρvap as a function L = V 1/3 . (ρ − ρvap (L = 15.8 σ) = 0.0320 σ13 , ρ − ρvap (L = 18 σ) = 0.0277 σ13 , ρ − ρvap (L = 20.3 σ) = 0.0244 σ13 , ρ − ρvap (L = 22.5 σ) = 0.0220 σ13 ). From MacDowell et al. [55]

(35,38,41), but there are quantitative differences. If one insists on identifying the drop’s radius according to (38) (and thereby lumps all approximations into the estimate of the interface tension), these deviations correspond to a reduction of the effective interface tension of small drops of the order 20%. This simulation study illustrates what kind of qualitatively different conformations are sampled inside the miscibility gap and what macroscopic quantities, γ and κ, can be obtained from the free energy profile. It is important to realize that the interval of excess densities in which supersaturated vapor or drops can be observed depends on the system size. In the limit of large system size, the droplet evaporation/condensation shifts towards the coexistence curve, ∆ρdc → 0. This corresponds to the macroscopic phase coexistence where the excess free energy ∆F vanishes across the miscibility gap. For a finite system, however, the interface contribution will be important – the system chooses a balance between an inhomogeneous density distribution with the corresponding free energy costs associated with the interfaces and the free energy cost of increasing the bulk density homogeneously. The free energy will vary with density and its scale can be estimated by the excess free energy at ∗ ∼ √1V . the droplet evaporation/condensation, ∆F V There are two important consequences for simulations: • In a finite size simulation box of volume, V , drops of linear dimension R can only be observed in a very limited range of excess densities. The size is limited by V 1/4 ∼ Rmin < R < Rmax ∼ V 1/3 . Consequentially, to study the dependence of the free energy on the drop’s radius one also has to vary the system size. Note that the equilibrium drops observed in the canonical ensemble correspond to critical drops in the nucleation

Simulation Techniques for Calculating Free Energies

95

theory at a supersaturation ∆µ = ∂∆F/∂n. At fixed volume, the density of the surrounding vapor (mother phase) does depend on the drop’s size. Hence, one cannot study the growth of a drop at fixed supersaturation – the situation assumed in nucleation theory – without a systematic study of finite size effects. • The “transitions” from the supersaturated vapor to the drop and from the drop to the slab configurations represent barriers in the configuration space which are not removed by the multicanonical reweighting scheme. Hence, these shape “transitions” limit the applicability of reweighting methods in the study of phase equilibria. The last issue can be clearly observed in the time sequence of the order parameter in the simulation. With a very good reweighting function the probability distribution sampled in the simulation is flat but the system does not perform a random walk in the order parameter. Rather one finds a banded structure of the time evolution where the system explores the configurations within a typical shape – homogenous vapor, drop, slap, bubble, or homogeneous liquid – in a random walk-like manner but only occasionally jumps between different shapes [58]. Typically the free energy barrier associated with “transitions” from one shape to another is a small fraction of the free energy barrier associated with the formation of the interfaces in the slab-like configurations. Neuhaus and Hager [58] pointed out the slowing down of simulations due to these shape “transitions”. For a two-dimensional simulation cell of square geometry, L × L, they investigated the barrier for the “transition” between a drop (spot) and a slab (stripe) and compared simulation results of the Ising model with a transition state that had earlier been suggested by Leung and Zia [59]. It consists of a lens-shaped domain whose two arc ends touch each other via the periodic boundaries. The opening angle of the arc is chosen such that the enclosed area of the lens equals the area, L2 /π, at the drop–to–slab transition. Simple geometric considerations yield the arc length 1.135L which is larger than the length of the liquid-vapor interface (line), L. Thus the free energy barrier associated with the shape “transition” is 13.5% of the free energy barrier due to the interfaces. Given that this free energy barrier should not exceed the thermal free energy scale kB T by an order of magnitude total free energy barriers, i.e., 2γL2 on the order 102 kB T can be efficiently sampled.

3 Applications 3.1 Liquid-Vapor Coexistence In the first application will will exemplify the accurate localization of the condensation transition for a coarse-grained bead-spring polymer model. As discussed above, the order parameter of the liquid-vapor transition is the monomer number density, ρ. The equation of state of the polymer solution is

M. M¨ uller and J.J. de Pablo 6

3.2

kBT/ε

3

pσ /ε

4

3.6

kBT/ε=5 kBT/ε=4 kBT/ε=3 kBT/ε=2.5 kBT/ε=1.68 TPT1

2

θ

2.8

TPT1

2.4

MC

2.0 1.6

p=0

1.2 0.8 0.4

0 0.0

0.2

0.4 3 ρσ

0.6

0.8

0.0 0

0.2

0.4

0.6 3 ρσ

0.8

glassy behavior

96

1

Fig. 12. Equation of state (a) and phase diagram (b) of a bead-spring polymer model. Monomers interact via a truncated and shifted Lennard-Jones potential as in Fig. 6 and neighboring monomers along a molecule are bonded together via a finitely non-linear elastic potential of the form: EFENE (r) = ) ( extensible −15(R0 /σ)2 ln 1 −

r2 2 R0

with R0 = 1.5σ. Each chain is comprised of N = 10

monomeric units. The pressure of the bulk system in panel (a) has been extracted from canonical Monte Carlo simulations using the virial expression (symbols). Lines show the result of Wertheim’s perturbation theory (TPT1). The phase diagram (b) has been obtained from grand-canonical Monte Carlo simulations. Binodal compositions are shown as full lines, while the corresponding results from Wertheim’s perturbation theory are presented by dashed lines. Filled and open circles mark the location of the critical point in the simulations and the TPT1 calculations, respectively. The Θ-temperature is indicated by an arrow on the left hand side. The diamonds present the results of constant pressure simulations indicating the densities that correspond to vanishing pressure, which are a good approximation for the coexistence curve at low temperatures. Adapted from M¨ uller and Mac Dowell [60]

presented in Fig. 12 (a) and the Monte Carlo results (symbols) are compared to Wertheim’s thermodynamic perturbation theory (TPT1) represented by lines without adjustable parameter [60]. As we reduce the temperature, the pressure decreases and the analytic theory predicts a van-der-Waals loop with negative pressures for a hypothetical homogeneous system. In the simulation, however, the system spatially separates into two coexisting phases – a lowdensity vapor and a dense liquid. The monomer number density, ρ = nN/V (n being the number of chains and N the number of monomers per chain), distinguishes the two phases. The sequence of typical configurations inside the miscibility gap has been discussed in Sect. 2.5. Upon increasing the system size the equation of state does not exhibit a loop but develops a plateau, pcoex , in the miscibility gap. The grand-canonical ensemble is particularly well suited for studies of liquid-vapor phase coexistence: (i) Fluctuations of the order parameter, i.e., the density, are efficiently relaxed. Since the density is not conserved, spatial fluctuations do not decay via slow diffusion of polymers but relax much faster through insertion/deletion moves. In the grand-canonical ensemble one controls the temperature, T , the volume, V , and the chemical potential, µ,

Simulation Techniques for Calculating Free Energies

97

in the simulations and the number of particles, n, fluctuates. To realize this ensemble in Monte Carlo simulations, insertion/deletion moves are utilized to supplement canonical moves that displace particles and alter the conformations of the polymers. Note that insertion of extended particles into a dense liquid is difficult, and several methods have been devised to overcome the concomitant sampling difficulties. In our application we utilize configurational bias Monte Carlo [61] to grow the polymer chains into the system. (ii) The key quantity to monitor in the simulation is the probability distribution of the number of particles in the simulation cell. It contains much information about the coexisting phases and the interface that separates them (c.f. Sect. 2.5). Additionally, there exist sophisticated methods to control finite-size effects and to accurately locate critical points. In the vicinity of the phase coexistence, µ = µcoex (T ), the distribution P (ρ) exhibits two pronounced peaks that are separated by a deep “valley”. The corresponding free energy profile, F (ρ) = −kB T ln P (ρ), for polymers that are comprised of N = 10 effective segments and temperature kB T / = 1.68, is presented in Fig. 13. The location of phase coexistence can be accurately estimated by the equal-weight rule [63]: Two phases coexist if the weights of the two corresponding peaks in the distribution function of the order parameter are equal. It is important for the system to “tunnel” often between the two phases in −20

0.12

vapor

interface

liquid

0.10

0.06 γLV/kBT

0.04

probability

2

∆F/2L kBT

0.08

0.02 0.00

ρV

0.0

ρL 0.1

0.2

0.3 0.4 3 ρσ

10 −18 10 −16 10 −14 10 −12 10 −10 10 −8 10 −6 10 −4 10 −2 10 1

0.5

0.6

Fig. 13. Illustration of the grand-canonical simulation technique for temperature kB T / = 1.68 and µ = µcoex . A cuboidal system geometry 13.8σ × 13.8σ × 27.6σ is used with periodic boundary conditions in all three directions. The solid line corresponds to the negative logarithm of the probability distribution, P (ρ), in the grand canonical ensemble. The two minima correspond to the coexisting phases and the arrows on the ρ axis mark their densities. The height of the plateau yields an accurate estimate for the interfacial tension, γLV . The dashed line is a parabolic fit in the vicinity of the liquid phase employed to determine the compressibility. Representative system configurations are sketched schematically. From [62]

98

M. M¨ uller and J.J. de Pablo

the course of the simulation in order to equilibrate the weight between the two phases. Without multicanonical techniques, the large free energy barrier between the two phases would render the simultaneous sampling of both phases in a single simulation infeasible. If we assume that in a multicanonical simulation the system performs a random walk along the order √parameter then the statistical uncertainty of the peak weights will scale as 1/ #, where # is the number of transitions (or tunneling events) from one phase to the other. The concomitant statistical uncertainty in the √ free energy difference of the two coexisting phases is on the order O(kB T / #). The rule for phase coexistence can be rationalized as follows: Using the relation between the the probability distribution, P (n), and the grandcanonical partition function, Zgc , we obtain for the ratio of the partition functions of the two phases:  exp(βµn)  liq Dn [{r}] exp(−βE[{r}]) Zgc n∈liq n! (44) vap =  exp(βµn)  Zgc Dn [{r}] exp(−βE[{r}]) n∈vap n! where Dn [{r}] sums over all configurations of the system with n polymers, and E[{r}] denotes the energy of this microscopic configuration, {r}. The condition n ∈ liq, characterizes all particle numbers that correspond to the liquid phase; if n ∈ vap, the configuration belongs to the vapor phase. The detailed way in which the interval of particle numbers is divided into vapor and liquid phases affects the estimate of the ratio only by an very small amount. Furthermore, that amount decreases exponentially with the system size because the configurations between the peaks are strongly suppressed due to the free energy cost of the interface between the coexisting phases (cf. Sect. 3.5). The pressure, p, is related to the grand-canonical partition function via pV = kB T ln Zgc . Therefore one obtains: liq Zgc vap = 1 Zgc



pliq = pvap

(equal weight rule)

(45)

Thus the equal weight-rule rephrases the macroscopic definition of phase coexistence: Two phases coexists if they have equal pressure at equal chemical potential. Using histogram extrapolation [2] we determine the coexistence value of the chemical potential. The properties of the individual phases can be extracted by taking averages over the corresponding regions of the order parameter. The densities of the two coexisting phases – the binodal densities – are presented in Fig. 12(b). From the curvature of the free energy profile at the minima we can also extract the compressibility of the liquid and the vapor. Additional information about interfaces between the coexisting phases can also be obtained as discussed in Sect. 3.5.

Simulation Techniques for Calculating Free Energies

99

3.2 Demixing of Binary Blends Another example of phase coexistence that is described by a single scalar onecomponent order parameter is provided by incompressible binary mixtures. One considers a dense liquid of two components, A and B; the composition of A , distinguishes the two coexisting phases. The total the mixture, φ = nAn+n B number of particles, nA + nB , is assumed to be independent of composition. The more general case of compressible mixtures will be discussed in the following section. Sariban and Binder [64] employed simulations in the semi-grand canonical ensemble for investigating the phase behavior of an incompressible binary polymer blend at constant volume. In this ensemble, the total monomer density is fixed, the composition of the blend fluctuates, and the chemical potential difference, ∆µ, between the species is controlled. The Monte Carlo scheme comprises two types of moves. Canonical updates relax the conformation of the macromolecules, whereas semi-grand canonical moves convert A polymers into B polymers and vice-versa. This ensemble is particularly well suited for the study of strictly symmetric mixtures where the two components have the same chain architecture and intramolecular potentials, but different species repel each other. In this limit, semi-grand canonical moves consist of a mere identity exchange (a switch of labels). Note that the algorithm implies that both phases have identical densities but it does not automatically ensure that they have identical pressure. The algorithm can be extended to some degree of structural asymmetry (e.g., different chain lengths between the species [65]). Overall speaking, it is reasonably efficient for a modest degree of structural asymmetry between the different constituents, but the extension to pronounced structural asymmetries is a challenging task. Improvement might be achieved via gradually “mutating” one species into another [66]. Figure 14 exemplifies two computational methods to determine the probability distribution of composition for binary polymer blends described by the bond fluctuation model [67]. Phase coexistence can be extracted from these data via the equal-weight rule. For the specific example of a symmetric blend, the coexistence value of the exchange chemical potential, ∆µ, is dictated by the symmetry. One can simply simulate at ∆µcoex ≡ 0 and monitor the composition. Nevertheless, the probability distribution contains additional information, as discussed in Sect. 3.5. Panel (a) illustrates the application of the Wang-Landau algorithm [7]. The different probability distributions obtained at successive steps of the modification parameter, f are shown. As f decreases the distribution gradually converges towards the Boltzmann distribution. Note that the starting value of the modification factor, f = 1.02, is chosen much smaller than in the original application to a spin system in order to match the relaxation time of the system (chain conformations) with the time scale for exploring the entire composition range.

100

M. M¨ uller and J.J. de Pablo 10

f=1.02 f=1.00248 f=1.00031 f=1.00004 final

-10

10

0

P(φ)

P(φ)

10

0

10

10

-20

-30

10 0.0

-10

-20

0.2

0.4

φ

0.6

0.8

1.0

10 0.0

0.2

0.4

φ

0.6

0.8

1.0

Fig. 14. (a) Probability distribution of the composition, φ, of a symmetric binary polymer blend within the framework of the bond fluctuation model. In this coarse-grained lattice model monomeric units are represented by unit cubes on a three-dimensional cubic lattice. Each monomer blocks the 8 sites of a cube from double occupancy. This mimics excluded volume interactions. Monomers along a polymer via one of 108 bonding vectors that can adopt lengths, √ are connected √ √ chain b = 2, 5, 6, 3, and 10 in units of the lattice spacing. This represents the connectivity along the polymer backbone. Monomers of the same type attract each other via a square-well potential of depth − that extends over the nearest 54 lattice sites. “Unlike” monomers repel each other via a potential of opposite sign. The simulation data are obtained at the different stages of the Wang-Landau sampling for chain length N = 32 and /kB T = 0.02 in a simulation cell of geometry 64 × 64 × 128 in units of the lattice spacing (Re = 17). The convergence factors, f , are indicated in the key. A flatness of 50% was required for the histogram √ of visited to particle numbers to reduce the convergence factor from f → f  = f . (b) Piecewise probability distributions obtained by successive umbrella sampling. By patching the distributions together in regions of mutual overlap it is possible to construct the probability distribution over the complete composition range

Panel (b) illustrates the application of successive umbrella sampling [35], where each piece of the curve corresponds to several intervals used in the successive sampling. The intervals overlap just by one particle number, which is sufficient if one takes due account of detailed balance at the interval boundaries [36]. Matching the pieces at their boundaries one obtains the distribution across the entire composition range. Of course, both methods yield identical results for the final probability distribution and, provided that one starts with an appropriate modification factor, f , they require comparable amounts of CPU time. One advantage of these Monte Carlo simulations is that both the thermodynamic and structural properties of the binary polymer mixture are simultaneously accessible, and can quantitatively be compared to analytic approaches. The mean field theory of polymers makes detailed predictions for the bulk [68–70] and interface properties [71–77] as a function of the incompatibility, χN ˜ , the spatial extension of the molecules Re as measured by the root mean squared end-to-end distance of the Gaussian coils, and the

Simulation Techniques for Calculating Free Energies

%

101

&2

¯ ≡ ρR3 /N . The last parameter deinvariant degree of polymerization N scribes the strength of fluctuation effects that are neglected by mean field ¯ → ∞. theory; the analytic approach is thought to describe the limit N One question that these simulations can address is the relation between different estimates of the incompatibility between polymer species, i.e.: How can one identify the mutual repulsion between polymer species parameterized by the product of the Flory-Huggins parameter and chain length, χN ˜ , for a specific microscopic polymer model [65, 78]? In simulations, as well as in experiments, it is common practice to measure the Flory-Huggins parameter by comparing the results of simulations to the predictions of the mean field theory. Since the predictions are affected by fluctuation effects to different extents, not all quantities yield mutually compatible estimates of the Flory-Huggins parameter, χ. ˜ Within mean field theory, for a symmetric blend the excess free energy of mixing per volume is given by the Flory-Huggins expression: # ∆Fmix ¯ [φ ln φ + (1 − φ) ln(1 − φ) + χN ˜ φ(1 − φ)] = N 3 kB T (V /Re )

(46)

From this expressions one can calculate the binodal curves (composition of the two coexisting phases) ln

∆µcoex φ + χN ˜ (1 − 2φ) = =0, 1−φ kB T

(47)

the location of the critical point, χ ˜c N = 2 and φc = 1/2, which marks the onset of phase separation, and the composition fluctuations in the one phase region 1 1 N = + − 2χN ˜ for χN ˜