Course MP3 Lecture 5 14/11/2006 Monte Carlo method II How to put some real physcs nto the Monte Carlo method Dr James Ellott 5.1 Monte Carlo method revsted In lecture 4, we ntroduced the Monte Carlo (MC) method, whch s a probablstc smulaton technque for evolvng systems to thermodynamc equlbrum. We dscussed Metropols algorthm, n whch new states are accepted automatcally f ther energy s lower than prevous state, or wth Boltzmann probablty f ther energy s hgher. Metropols MC samples states accordng to ther thermal mportance naturally produces confguratons from the canoncal (NVT) thermodynamc ensemble. However, does not allow us to study stuatons n whch there are fluctuatons n partcle number or changes n total system volume. 1
5.2 MC n dfferent thermodynamc ensembles In ths lecture, we wll dscuss ways of usng MC to sample from dfferent thermodynamc ensembles, whch are dentfed by ther conserved quanttes. Isobarc-sothermal (NpT) Fxed number of partcles, pressure and temperature. E.g., a perfectly elastc balloon flled wth gas. Grand canoncal or Gbbs (µvt) Varable number of partcles, fxed volume and temperature. E.g., onc solutons n osmotc contact across a permeable membrane. 5.3 Free energy calculatons usng MC We wll see how MC can be used to calculate free energes usng thermodynamc ntegraton or smulatons n the grand canoncal ensemble. Free energes are dffcult to calculate by computer smulaton (and also n real experments!) because they nvolve entropy, and cannot smply be obtaned by averagng over functons of the phase space co-ordnates of the system (as can energy, temperature, etc.). Instead, they depend on the avalable volume of accessble phase space, and are called thermal quanttes (as opposed to mechancal quanttes). The calculaton of thermal quanttes s very mportant, as t allows us to study the phase behavour of a substance as a functon of temperature and pressure. 2
5.4 Confguratonal bas MC Fnally, we wll look at how to study stuatons n whch the acceptance rato of tral moves s very low. For example, a polymerc system where most moves are forbdden by the constrants of chan topology and excluded volume. These problems can be tackled by basng the generaton of tral conformatons so that the acceptance rate s greatly enhanced (even to such an extent that each move s guaranteed to be accepted). Ths s allowed (.e we wll stll produce a well-defned thermodynamc equlbrum state) provded the acceptance rule s modfed n such a way that the bas s removed. 5.5 Revson of Metropols MC Let s start by revsng the Metropols MC method. We recall that we start wth an ntal random confguraton, and apply perturbatons whch take us on a random walk through regons of phase space whch have an mportant contrbuton to the ensemble averages (recall the analogy of the Nle from lecture 4). The acceptance rules governng the transtons to new states are chosen such that these confguratons occur wth a frequency whch s proportonal to ther Boltzmann probablty. 1 p = Z ( ) exp βe 3
5.6 General approach for MC smulaton The procedure used for Metropols MC can be generalsed to sample confguratons from any thermodynamc ensemble by followng a general recpe: 1. Lst the conserved quanttes of the requred ensemble 2. Impose the condton of detaled balance: p σ P(σ ν) = p ν P(ν σ) where the lower case p are occupaton probabltes and the captal P are transton probabltes [Remember that each transton probablty can be decomposed nto the product of a selecton probablty and an acceptance probablty] 4. Determne probabltes of generatng a partcular confguraton 5. Derve condton whch needs to be fulflled by acceptance rules 5.7.1 Isobarc-sothermal MC Let s now do an example and sample confguratons from the NpT ensemble. Not only are these the most common expermental condtons, but also constant NpT MC can be used to calculate the equaton of state for systems n whch the partcles nteract va arbtrary potental energy functons. They can also be used to smulate systems n the vcnty of a frst order phase transton. Ths s not possble wth standard NVT MC because the densty s constraned by the fnte sze of the smulaton box. Usng NpT MC, the system relaxes to the state of lowest Gbbs free energy. 4
5.7.2 Isobarc-sothermal MC A rgorous dervaton of the scheme for NpT MC can be found n Frenkel 5.4, but dea s to take the volume of the smulaton box V as an addtonal degree of freedom. So, as well as makng tral moves n the system confguraton, we also make tral moves n V that consst of addng or subtractng some small amount of volume. Note the shft n the c.o.m. of the partcle postons. V V ' = V + δ V δ = U[ 1,1] max 5.7.3 Isobarc-sothermal MC The trck s to ntroduce the volume changng moves n such a way that the symmetry of the underlyng Markov chan s not dsturbed. We can do ths by choosng the acceptance probablty of a random volume changng move V V to be: H [ { β H} ] mn 1,exp = E N N V ' ( s, V ') E( s, V ) + p( V ' V ) Nk T ln V You can thnk of ths procedure as formng an equlbrum wth a macroscopc reservor at pressure p. B 5
5.7.4 Isobarc-sothermal MC The frequency wth whch tral moves n the volume should be attempted s much less than that of the sngle partcle moves, because they requre us to recompute all the ntermolecular nteractons. The general rule s to try one volume move every N partcle moves. However, to guarantee the symmetry of the underlyng Markov chan, ths move should be attempted wth probablty 1/N after every partcle move. Ths ensures that the system s mcroscopcally reversble, and generates a Boltzmann dstrbuton of states n the NpT ensemble. Some methods make moves n lnv rather than V. 5.8 Calculatng free energes Although NVT and NpT MC enable us to smulate realstc expermental condtons, they do not permt drect calculaton of thermal quanttes such as entropy or Gbbs free energy. Ths s precsely because the smulatons are so good at samplng only thermally mportant regons of phase space (as the thermal quanttes depend on the volume of phase space whch s accessble to the system). We can get around ths ether drectly, by calculatng absolute free energes n the full grand canoncal ensemble, or ndrectly, by calculatng free energy changes between dfferent equlbrum states. 6
5.9 Thermodynamc ntegraton An ndrect method whch s very smlar to the way n whch free energes are calculated n real experments. Lke our smulatons, these measure dervatves of the free energy such as pressure or energy: F p = V NT ( F ) β E = Frenkel 7.2 β Bnder 5.6 So, F between two states can be calculated by ntegratng the nternal energy along a reversble path n V and T. An example s calculatng free energy of a lqud usng an equaton of state and the deal gas as a reference state. VN 5.10.1 Grand canoncal MC However, f we want to obtan absolute free energes drectly or we don t have a sutable reference state, then we can do MC n the grand canoncal or Gbbs ensemble. You mght thnk that ths would be µpt ensemble, but ths s not a vald thermodynamc ensemble because we must have at least one extensve conserved quantty or the model may evaporate or dverge wthout lmt. Actually, t s the µvt ensemble whch corresponds to the Gbbs dstrbuton (whch you derved n examples sheet 1). In µvt MC, there are three types of move: Partcle dsplacement Partcle creaton Partcle annhlaton 7
5.10.2 Grand canoncal MC Can thnk of the µvt MC as allowng the system to come to dffusve equlbrum wth a reservor of deal gas n whch the partcles do not nteract. Frenkel 5.6 Blue partcles n smulaton box nteract as normal, but transparent ones n the reservor can overlap. Both types carry the same chemcal potental µ. When a partcle moves from the reservor to the smulaton box, the only change n energy s that due to the nteracton potental. In practce, the partcle s nserted randomly nto the smulaton box. 5.10.3 Grand canoncal MC Partcle creatons are accepted wth probablty: V a( N N + 1) = mn 1, exp ) 3 λt ( N + 1) { β( µ E( N + 1) + E( N )} Partcle annhlatons are accepted wth probablty: 3 NλT a( N N 1) = mn 1, exp ) V { β( µ E( N 1) + E( N )} where λ T s the thermal wavelength (see lecture 2). The rato of creatons or annhlatons to dsplacement moves s roughly the same, as both nvolve a smlar amount of computatonal effort. Ensure reversblty! 8
5.10.4 Grand canoncal MC The free energy can then be calculated drectly from: F / N = µ p V / N The quanttes <p> and <N> are average values of pressure and number of partcles whch are measured from the smulaton over many dfferent confguratons. However, there are some techncal dffcultes wth carryng out µvt MC whch centre around the problem n creatng or annhlatng partcles n dense systems. There are varous methods to crcumvent ths problem whch nvolve the concept of confguratonal bas MC. 5.11.1 Confguratonal bas MC Frenkel 13.2.1 Bnder 6.7 There are many stuatons n whch the acceptance probabltes of tral moves n MC smulatons drop to almost zero, resultng n a very neffcent smulaton. In these crcumstances, we would lke to bas the generaton of tral moves such that they stand a greater probablty of beng accepted. It turns out we can do ths wthout affectng the equlbrum dstrbuton provded we change our acceptance probabltes Remember that we are only concerned about the rato of our transton probabltes, so we are free to ntroduce an arbtrary basng factor wthout volatng detaled balance. 9
5.11.2 Confguratonal bas MC To llustrate how the procedure works, consder a selfavodng polymer chan on a lattce wth coordnaton k (e.g. k = 4 for a smple cubc lattce n 2D). 1. Insert frst atom at random on the lattce and compute ts energy 2. The next segment has k possble drectons, so select a partcular drecton (label t n) wth probablty p (n) = exp{ βe (n)}/ w ( ) w ( n) = exp{ βe (j)} p ( n) n 3. Repeat step 2 untl the entre chan of length l s generated, and compute the Rosenbluth factor W of the new confguraton: W ( n) = l = 1 w ( n) k j= 1 5.11.4 Confguratonal bas MC To restore the symmetry of the Markov chan, we need to adjust our standard MC algorthm as follows: 1. Generate ntal confguraton usng the based scheme and compute ts Rosenbluth factor W 0 2. Generate a new confguraton usng the based scheme and compute ts Rosenbluth factor W(n) 3. Accept the tral move wth probablty: mn [ 1, W ( n) / W (0)] 4. Go back to step 2 and terate to equlbrum So, confguratons are selected accordng to ther Rosenbluth factor rather than ther energy. It s qute straghtforward to generalse ths method to off-lattce smulatons. 10
5.11.5 Confguratonal bas MC The confguratonal bas approach can be used to smulate entre macromolecules f an approprate force feld s used to compute the Rosenbluth factors. The pont s that we bas the generaton of tral conformatons towards states whch are favourable n energy (.e. are reasonably lkely to satsfy our force feld constrants) so that we don t spend all our tme generatng rdculously unphyscal chans. We then get rd of the effects of basng by adjustng our acceptance probabltes. Note that t s possble to make ths algorthm much more effcent, but the detals are beyond the scope of ths course. 5.12 Summary We started off by revewng Metropols MC. We then dscussed how to carry out MC smulatons n varous dfferent thermodynamcs ensembles other than the NVT. Of these, only the grand canoncal or µvt ensemble can be used to calculate free energes drectly. An alternatve s to calculate free energy dfferences usng thermodynamc ntegraton. Fnally, we outlned the Rosenbluth scheme for carryng out confguraton bas MC, whch enables us to deal wth smulatons where our states are hghly constraned. 11