


























Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!



























now compare the calculated properties of a model system with those of an experimental system: if the two disagree, our model is inadequate, i.e. we have to improve on our es- timate of the intermolecular interactions. On the other hand, we can compare the result of a simulation of a given model system with the predictions of an approximate analytical theory applied to the same model. If we now find that theory and simulation disagree, we know that the theory is flawed. So, in this case, the computer simulation plays the role of the ‘experiment’ that is designed to test the theory. This method to ‘screen’ theories before we apply them to the real world, is called a ‘computer experiment’. Computer experiments have become standard practice, to the extent that they now provide the first (and often the last) test of a new theoretical result. In fact, the early history of computer simulation (see e.g. ref.^2 ) illustrates this role of computer simulation. In some areas of physics there appeared to be little need for simula- tion because very good analytical theories were available ( e.g. to predict the properties of dilute gases or of nearly harmonic crystalline solids). However, in other areas, few if any ‘exact’ theoretical results were known, and progress was much hindered by the fact that there were no unambiguous tests to assess the quality of approximate theories. A case in point was the theory of dense liquids. Before the advent of computer simulations, the only way to model liquids was by mechanical simulation3–5^ of large assemblies of macroscopic spheres ( e.g. ball bearings). But such mechanical models are rather crude, as they ignore the effect of thermal motion. Moreover, the analysis of the structures generated by me- chanical simulation was very laborious and, in the end, had to be performed by computer anyway. This may explain why, when in 1953 electronic computers were, for the first time, made available for unclassified research, numerical simulation of dense liquids was one of the first problems that was tackled. In fact, the first simulation of a ‘liquid’ was carried out by Metropolis et al.^6 at Los Alamos, using (or, more properly, introducing) the Monte Carlo method. Almost simultaneously, Fermi, Pasta and Ulam^7 performed a very famous numer- ical study of the dynamics of an anharmonic, one-dimensional crystal. However, the first proper Molecular Dynamics simulations were reported in 1956 by Alder and Wainwright^8 at Livermore, who studied the dynamics of an assembly of hard spheres. The first MD sim- ulation of a model for a ‘real’ material was reported in 1959 (and published in 1960) by the group of Vineyard at Brookhaven^9 , who simulated radiation damage in crystalline Cu (for a historical account, see^10 ). The first MD simulation of a real liquid (argon) was reported in 1964 by Rahman at Argonne^11. After that, computers were increasingly becoming avail- able to scientists outside the US government labs, and the practice of simulation started spreading to other continents12–14. Much of the methodology of MD simulations has been developed since then, although it is fair to say that the basic algorithms for MC and MD have hardly changed since the fifties.
1.1 Statistical mechanics
In the present lecture, we describe the basic principles of the Monte Carlo method and molecular dynamics. In particular, we focus on simulations of systems of a fixed number of particles (N ) in a given volume (V ) at a temperature (T ). Our aim is to indicate where the Monte Carlo method comes in. We start from the
classical expression for the partition function Q:
Q = c
dpN^ drN^ exp[−H(rN^ pN^ )/kB T ], (1)
where rN^ stands for the coordinates of all N particles, and pN^ for the corresponding momenta. The function H(qN^ , pN^ ) is the Hamiltonian of the system. It expresses the total energy of an isolated system as a function of the coordinates and momenta of the constituent particles: H = K + U, where K is the kinetic energy of the system and U is the potential energy. Finally, c is a constant of proportionality, chosen such that the sum over quantum states approaches the classical partition function in the limit ℏ → 0. For instance, for a system of N identical atoms, c = 1/(h^3 N^ N !). The classical equation is
dpN^ drN^ A(pN^ , rN^ ) exp[−βH(pN^ , rN^ )] ∫ dpN^ drN^ exp[−βH(pN^ , rN^ )]
where β = 1/kB T. In this equation, the observable A has been expressed as a function of coordinates and momenta. As K is a quadratic function of the momenta the integration over momenta can be carried out analytically. Hence, averages of functions that depend on momenta only are usually easy to evaluate. The difficult problem is the computation of averages of functions A(rN^ ). Only in a few exceptional cases can the multidimensional integral over particle coordinates be computed analytically, in all other cases numerical techniques must be used. Having thus defined the nature of the numerical problem that we must solve, let us next look at possible solutions. It might appear that the most straightforward approach would be to evaluate 〈A〉 in equation 2 by numerical quadrature, for instance using Simpson’s rule. It is easy to see, however, that such a method is completely useless even if the number of independent coordinates DN (D is the dimensionality of the system) is still very small O(100). Suppose that we plan to carry out the quadrature by evaluating the integrand on a mesh of points in the DN -dimensional configuration space. Let us assume that we take m equidistant points along each coordinate axis. The total number of points at which the integrand must be evaluated is then equal to mDN^. For all but the smallest systems this number becomes astronomically large, even for small values of m. For instance, if we take 100 particles in three dimensions, and m = 5, then we would have to evaluate the integrand at 10210 points! Computations of such magnitude cannot be performed in the known universe. And this is fortunate, because the answer that would be obtained would have been subject to a large statistical error. After all, numerical quadratures work best on functions that are smooth over distances corresponding to the mesh size. But for most intermolecular potentials, the Boltzmann factor in equation 2 is a rapidly varying function of the particle coordinates. Hence an accurate quadrature requires a small mesh spacing ( i.e. a large value of m). Moreover, when evaluating the integrand for a dense liquid (say), we would find that for the overwhelming majority of points this Boltzmann factor is vanishingly small. For instance, for a fluid of 100 hard spheres at the freezing point, the Boltzmann factor would be nonzero for 1 out of every 10260 configurations! The closing lines of the previous section suggest that it is in general not possible to eval- uate an integral, such as
drN^ exp[−βU(rN^ )], by direct Monte Carlo sampling. How- ever, in many cases, we are not interested in the configurational part of the partition func-
Nile
Nile
Figure 1. Measuring the depth of the Nile: a comparison of conventional quadrature (left), with the Metropolis scheme (right).
system in a configuration rN^ , which we denote by o (old), that has a nonvanishing Boltz- mann factor exp[−βU(o)]. This configuration, for example, may correspond to a regular crystalline lattice with no hard-core overlaps. Next, we generate a new trial configuration r′N^ , which we denote by n (new), by adding a small random displacement ∆ to o. The Boltzmann factor of this trial configuration is exp[−βU(n)]. We must now decide whether we will accept or reject the trial configuration. Many rules for making this decision satisfy the constraint that on average the probability of finding the system in a configuration n is proportional to N (n). Here we discuss only the Metropolis scheme, because it is simple and generally applicable. Let us now “derive” the Metropolis scheme to determine the transition probability π(o → n) to go from configuration o to n. It is convenient to start with a thought exper- iment (actually a thought simulation). We carry out a very large number (say M ) Monte Carlo simulations in parallel, where M is much larger than the total number of accessible configurations. We denote the number of points in any configuration o by m(o). We wish that, on average, m(o) is proportional to N (o). The matrix elements π(o → n) must sat- isfy one obvious condition: they do not destroy such an equilibrium distribution once it is reached. This means that, in equilibrium, the average number of accepted trial moves that result in the system leaving state o must be exactly equal to the number of accepted trial moves from all other states n to state o. It is convenient to impose a much stronger condition; namely, that in equilibrium the average number of accepted moves from o to any other state n is exactly canceled by the number of reverse moves. This detailed balance condition implies the following:
N (o)π(o → n) = N (n)π(n → o). (6)
Many possible forms of the transition matrix π(o → n) satisfy equation (6). Let us look how π(o → n) is constructed in practice. We recall that a Monte Carlo move consists of
two stages. First, we perform a trial move from state o to state n. We denote the transition matrix that determines the probability to perform a trial move from o to n by α(o → n); where α is usually referred to as the underlying matrix of Markov chain^16. The next stage is the decision to either accept or reject this trial move. Let us denote the probability of accepting a trial move from o to n by acc(o → n). Clearly,
π(o → n) = α(o → n) × acc(o → n). (7)
In the original Metropolis scheme, α is chosen to be a symmetric matrix (acc(o → n) = acc(n → o)). However, in later sections we shall see several examples where α is not symmetric. If α is symmetric, we can rewrite equation 6 in terms of the acc(o → n):
N (o) × acc(o → n) = N (n) × acc(n → o). (8)
From Eqn. 8 follows
acc(o → n) acc(n → o)
N (n) N (o)
= exp{−β[U(n) − U(o)]}. (9)
Again, many choices for acc(o → n) satisfy this condition (and the obvious condition that the probability acc(o → n) cannot exceed 1 ). The choice of Metropolis et al. is
acc(o → n) = N (n)/N (o) if N (n) < N (o) = 1 if N (n) ≥ N (o).
Other choices for acc(o → n) are possible (for a discussion, see for instance^17 ), but the original choice of Metropolis et al. appears to result in a more efficient sampling of con- figuration space than most other strategies that have been proposed.
1.2 A Basic Monte Carlo Algorithm
It is difficult to talk about Monte Carlo or Molecular Dynamics programs in abstract terms. The best way to explain how such programs work is to write them down. This will be done in the present section. Most Monte Carlo or Molecular Dynamics programs are only a few hundred to several thousand lines long. This is very short compared to, for instance, a typical quantum- chemistry code. For this reason, it is not uncommon that a simulator will write many different programs that are tailor-made for specific applications. The result is that there is no such thing as a standard Monte Carlo or Molecular Dynamics program. However, the cores of most MD/MC programs are, if not identical, at least very similar. Next, we shall construct such a core. It will be very rudimentary, and efficiency has been traded for clarity. But it will serve to demonstrate how the Monte Carlo method work.
1.3 The Algorithm
The prime purpose of the kind of Monte Carlo or Molecular Dynamics program that we shall be discussing is to compute equilibrium properties of classical many-body systems. From now on, we shall refer to such programs simply as MC or MD programs, although it should be remembered that there exist many other applications of the Monte Carlo method
Algorithm 2 [Attempt to Displace a Particle]
SUBROUTINE mcmove attempts to displace a particle
o=int(ranf()npart)+1 select a particle at random call ener(x(o),eno) energy old configuration xn=x(o)+(ranf()-0.5)delx give particle random displacement call ener(xn,enn) energy new configuration if (ranf().lt.exp(-beta acceptance rule (11)
Comments:
chain; that is, the matrix α. In more down-to-earth terms: we must decide how we are going to generate trial moves. We should distinguish between trial moves that involve only the molecular centers of mass, and those that change the orientation or possibly even the conformation of a molecule. We start our discussion with trial moves of the molecular centers of mass. A perfectly acceptable method to create a trial displacement is to add random numbers between −∆/ 2 and +∆/ 2 to the x, y, and z coordinates of the molecular center of mass:
x′ i → xi + ∆ (Ranf − 0 .5) y′ i → yi + ∆ (Ranf − 0 .5) z′ i → zi + ∆ (Ranf − 0 .5), (12)
where Ranf are random numbers uniformly distributed between 0 and 1. Clearly, the reverse trial move is equally probable (hence, α is symmetric). We are now faced with two questions: how large should we choose ∆?, and should we attempt to move all particles simultaneously or one at a time? In the latter case we should pick the molecule that is to be moved at random to ensure that the underlying Markov chain remains symmetric. All other things being equal, we should choose the most efficient sampling procedure. But, to this end, we must first define what we mean by efficient sampling. Broadly speaking, sampling is efficient if it gives you good value for money. Good value in a simulation corresponds to high statistical accuracy, and “money” is simply money : the money that buys your computer time and even your own time. For the sake of the argument, we assume the average scientific programmer is poorly paid. In
that case we have to worry only about your computer budget.b^ Then we could use the following definition of an optimal sampling scheme: a Monte Carlo sampling scheme can be considered optimal if it yields the lowest statistical error in the quantity to be computed for a given expenditure of computing budget. Usually, computing budget is equivalent to CPU time. From this definition it is clear that, in principle, a sampling scheme may be optimal for one quantity but not for another. Actually, the preceding definition is all but useless in practice (as are most definitions). For instance, it is just not worth the effort to measure the error estimate in the pressure for a number of different Monte Carlo sampling schemes in a series of runs of fixed length. However, it is reasonable to assume that the mean- square error in the observables is inversely proportional to the number of uncorrelated configurations visited in a given amount of CPU time. And the number of independent configurations visited is a measure for the distance covered in configuration space. This suggests a more manageable, albeit rather ad hoc, criterion to estimate the efficiency of a Monte Carlo sampling scheme: the sum of the squares of all accepted trial displacements divided by computing time. This quantity should be distinguished from the mean-square displacement per unit of computing time, because the latter quantity goes to zero in the absence of diffusion ( e.g. in a solid or a glass), whereas the former does not. Next, consider the choice of the parameter ∆ which determines the size of the trial move. How large should ∆ be? If it is very large, it is likely that the resulting configura- tion will have a high energy and the trial move will probably be rejected. If it is very small, the change in potential energy is probably small and most moves will be accepted. In the literature, one often finds the mysterious statement that an acceptance of approximately 50% should be optimal. This statement is not necessarily true. The optimum acceptance ratio is the one that leads to the most efficient sampling of configuration space. If we express efficiency as mean-square displacement per CPU time, it is easy to see that differ- ent Monte Carlo codes will have different optimal acceptance ratios. The reason is that it makes a crucial difference if the amount of computing required to test whether a trial move is accepted depends on the magnitude of the move (see Figure 2). In the conventional Metropolis scheme, all continuous interactions have to be com- puted before a move can be accepted or rejected. Hence, for continuous potentials, the amount of computation does not depend on the size of a trial move. In contrast, for simu- lations of molecules with hard repulsive cores, a move can be rejected as soon as overlap with any neighbor is detected. In that case, a rejected move is cheaper than an accepted one, and hence the average computing time per trial move goes down as the step size is increased. As a result, the optimal acceptance ratio for hard-core systems is appreciably lower than for systems with continuous interactions. Exactly how much depends on the nature of the program, in particular on whether it is a scalar or a vector code (in the latter case, hard-core systems are treated much like continuous systems), how the information about neighbor lists is stored, and even on the computational “cost” of random numbers and exponentiation. The consensus seems to be that for hard-core systems the optimum acceptance ratio is closer to 20 than to 50%, but this is just another rule of thumb that should be checked.
bStill, we should stress that it is not worthwhile spending a lot of time developing a fancy computational scheme that will be only marginally better than existing, simpler schemes, unless your program will run very often and speed is crucial.
N, V, T
Figure 3. Canonical ensemble. The number of particles, volume, and temperature are constant. Shown is a Monte Carlo move in which a particle is displaced).
K(o → n) = K(n → o), (13)
where K(o → n) is the flow of configuration o to n. This flow is given by the product of the probability of being in configuration o, the probability of generating configuration n, and the probability of accepting this move,
K(o → n) = N (o) × α(o → n) × acc(o → n). (14)
It is instructive to apply the preceding recipe to the ordinary Metropolis scheme. In the canonical ensemble, the number of particles, temperature, and volume are constant (see Figure 3). The partition function is
drN^ exp[−βU(rN^ )], (15)
where Λ =
h^2 /(2πmkB T ) is the thermal de Broglie wavelength. From the partition function it follows that the probability of finding configuration rN^ is given by distribution is
N (rN^ ) ∝ exp[−βU(rN^ )]. (16)
equations 15 and 16 are the basic equations for a simulation in the canonical ensemble.
2.2 Monte Carlo Simulations
In the canonical ensemble, we have to sample distribution (16). This can be done using the following scheme:
where ∆/ 2 is the maximum displacement. The value of ∆ should be chosen such that the sampling scheme is optimal (see section 1.4). The new configuration is denoted n and its energy U(n).
An implementation of this basic Metropolis scheme is shown in Section 1.2 (Algorithms 1 and 2).
2.3 Justification of the Algorithm
The probability of generating a particular configuration is constant and independent of the conformation of the system
α(o → n) = α(n → o) = α.
Substitution of this equation in the condition of detailed balance (13) and substitution of the desired distribution (16) gives as condition for the acceptance rules
acc(o → n) acc(n → o)
= exp{−β[U(n) − U(o)]}. (18)
It is straightforward to demonstrate that acceptance rule (17) obeys this condition.
3 Grand-Canonical Ensemble
The ensembles we have discussed so far have the total number of particles imposed. For some systems, however, one would like to obtain information on the average number of particles in a system as a function of the external conditions. For example, in adsorption studies one would like to know the amount of material adsorbed as a function of the pres- sure and temperature of the reservoir with which the material is in contact. A naive but theoretically valid approach would be to use the Molecular Dynamics technique (micro- canonical ensemble) and simulate the experimental situation; an adsorbent in contact with a gas (see Figure 4). Such a simulation is possible only for very simple systems. In real experiments, equi- libration may take minutes or even several hours depending on the type of gas molecules.
μ T