Presentation is loading. Please wait.

Presentation is loading. Please wait.

Monte Carlo method: Basic ideas. deterministic vs. stochastic In deterministic models, the output of the model is fully determined by the parameter values.

Similar presentations


Presentation on theme: "Monte Carlo method: Basic ideas. deterministic vs. stochastic In deterministic models, the output of the model is fully determined by the parameter values."— Presentation transcript:

1 Monte Carlo method: Basic ideas

2 deterministic vs. stochastic In deterministic models, the output of the model is fully determined by the parameter values and the initial conditions Stochastic models possess some inherent randomness. The same set of parameter values and initial conditions will lead to an ensemble of different outputs 2

3 Molecular Dynamics and Monte Carlo Molecular dynamics (MD) is a deterministic method that solves the equations of motion to predict positions and velocities of all particles of a system. The statistical treatment of the information gained in this way allows predictions of thermodynamic and transport properties Monte Carlo is a stochastic method in which the configurations of a system are sampled, in non- chronological order. The statistical treatment of the information gained in this way allows predictions of thermodynamic properties but not of transport properties 3

4 A crude approach to Monte Carlo Suppose we begin with an empty simulation box of fixed volume and then randomly choose a position for each molecule in the box until achieving the desired density. We then “measure” the instantaneous values of the properties of interest. The experiment is repeated many times. If the temperature is constant, the probability of each state is: 4

5 A crude approach to Monte Carlo In high-density systems, it is very likely this simple way of placing molecules will cause overlaps. In the hard core (e.g., hard spheres) intermolecular potential, overlaps lead to infinite configuration energy. Therefore, the probability of observing a microscopic state with overlap is zero. 5

6 A crude approach to Monte Carlo In high-density systems, it is very likely this simple way of placing molecules will cause overlaps. In soft core intermolecular potentials (e.g., Lennard- Jones), overlaps lead to very high configuration energy. Therefore, the probability of observing a microscopic state with overlap is nearly zero. 6

7 A crude approach to Monte Carlo In summary: Many of the generated configurations have extremely low (or zero) probability of occurrence and, therefore, contribute little to computing the average. Such sampling approach is inefficient for computing average thermodynamic properties. Another problem: how to compute the denominator, as it requires adding the Boltzmann factor of all configurations? 7

8 Importance sampling Alternative: Devise procedures that sample more frequently the states that matter most to the average properties. This is called importance sampling. 8

9 Importance sampling Importance sampling in the canonical ensemble: In a box of fixed volume, place the desired number of molecules in an arrangement without overlaps, for example, according to a lattice (crystal) structure. Develop other configurations with a bias towards lower energy states to try avoid highly unlikely configurations. Note: configurations with higher energy will be possible – but there will be a bias towards lower energy. This introduces a bias in the sampling procedure. When computing averages, it is necessary to account for this bias. 9

10 Importance sampling Importance sampling in the canonical ensemble: There are several ways to devise schemes to introduce biases and accounting for them when computing average thermodynamic properties. The most widely used is the Metropolis scheme originally published in 1953 – in the early stage of the development of electronic computers. N. Metropolis, A.W. Rosenbluth, M.N. Rosenbluth, A.H. Teller, E. Teller, J. Chem. Phys. 21, 1087 (1953) 10

11 Markov chains The Metropolis procedure uses a Markov chain of states. In a Markov chain: There is a finite (or countable) set of states of the system; The probability of transition from one state to another depends on the properties of these two states and not on those of other states. 11

12 Markov chains To illustrate the features of a Markov chain, consider a system with four possible states, with the probability of transition between any two of them given by the values above the arrows: 12

13 Markov chains Let us organize these probabilities in a matrix, called transition matrix (columns and rows switched with respect to the book, but the discussion is equivalent): 13

14 Markov chains Let us organize these probabilities in a matrix, called transition matrix (columns and rows switched with respect to the book, but the discussion is equivalent): 14

15 Markov chains Why is the summation of the elements of each column equal to 1? 15

16 Markov chains Note: until now, we have probabilities for the transitions but we do not have probabilities for the states. Let us make an initial guess that all four states are equally likely: 16

17 Markov chains Let us assume an event takes place in the Markov chain. The new probability for the states is obtained by multiplying the transition matrix by the probability vector: 17

18 Markov chains The probability vector after each subsequent event takes place is calculated in similar fashion: It is possible to show (Perron-Frobenius theorem) that there is a single limiting distribution, independent of the initial value, for any Markovian matrix that represents an ergodic system. 18

19 Markov chains In our problem, successive transitions leads to the following vector for the state probabilities: 19

20 Markov chains In our problem, successive transitions leads to the following vector for the state probabilities: At the beginning, we only knew transition probabilities. Using the Markov chain, we found the state probabilities. 20

21 Metropolis method We note that: 21

22 Metropolis method In an ergodic* system in equilibrium, the average number of transitions that take to a state is equal to the number of transitions that leave this state. (If the number of transitions into the state were, for example, bigger, then the system would get stuck in such a state after some time). A way to satisfy this condition is to impose what is called “microscopic reversibility”: the number of transitions that take the system from one state to another is equal to the number of transitions in the opposite direction: 22 *ergodic: average over time is equal to average over states (phase space)

23 Metropolis method Let us add over index m: To sample in the canonical ensemble: 23

24 Metropolis method There is more than one way of setting transition matrices that satisfy the conditions outlined in the previous slides. Metropolis solution is: For microscopic reversibility: Note: 24

25 Monte Carlo method in the canonical ensemble We need the ratio of the probabilities in states n and m. In the canonical ensemble: 25

26 Monte Carlo method in the canonical ensemble All these details can be put to work in an algorithm for Monte Carlo simulations whose basic structure is relatively simple. With the N particles of a system initially placed in a box of fixed volume kept at constant temperature: 1) Make small perturbation to the system, e.g., by trying to move one of its particles; 2) Accept or reject the move according to the transition probability of the Markovian matrix. 26

27 Monte Carlo method in the canonical ensemble 1) Make small perturbation to the system, e.g., by trying to move one of its molecules; In the Metropolis formulation, this is governed by matrix Probability of moving the system from state m to state n. A solution: Randomly pick a molecule; Randomly pick a new position for it. 27

28 Monte Carlo method in the canonical ensemble 1) Make small perturbation to the system, e.g., by trying to move one of its molecules; A solution: Randomly pick a molecule – let us say, molecule i; Randomly pick a new position for it. Uniformly distributed random number between 0 & 1 Maximum allowed displacement 28

29 Monte Carlo method in the canonical ensemble The new position of molecule i is within a small box centered in its position in configuration m with sides equal to 29

30 Monte Carlo method in the canonical ensemble 2) Accept or reject the move according to the transition probability of the Markovian matrix. 30

31 Monte Carlo method in the canonical ensemble 2) Accept or reject the move according to the transition probability of the Markovian matrix. 31

32 Monte Carlo method in the canonical ensemble What is the practical meaning of these conditions? 32

33 Monte Carlo method in the canonical ensemble What is the practical meaning of these conditions? is the probability of selecting a particle and randomly displacing it to a new position. Once this is done, if the energy of the system remains equal or decreases, the move is accepted. What if the energy increases? 33

34 Monte Carlo method in the canonical ensemble What if the energy increases? The probability of accepting the move depends on the ratio: Draw a random number uniformly distributed between 0 and 1. If its equal to or smaller than this ratio, accept the move. Otherwise, reject it. 34

35 Monte Carlo method in the canonical ensemble Summary: 35

36 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Maximum allowed displacement: A large value means molecules can make big moves, but these are unlikely to succeed in a dense system. Most will result in overlaps and be rejected. The consequence is that the sampling is inadequate. 36

37 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Maximum allowed displacement: A small value means molecules can make small moves, likely to be accepted. But with small moves, a good sampling takes a lot of time. The consequence is that the sampling is inadequate. 37

38 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Maximum allowed displacement: Solution: Periodically, during the equilibration part of the simulation, the maximum allowed displacement is adjusted in such a way that about 50% of the attempted moves are accepted. During the production part, it should be kept fixed. 38

39 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Random numbers play a crucial role in the method – no wonder it is called Monte Carlo method. Computers do not really generate random numbers. They have deterministic functions that result in numbers that appear to be random (even though, they are not). 39

40 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Unlike molecular dynamics, there is no need to compute forces. Only energies matter to sample the states. Implementation tends to be simpler. 40

41 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Computing the total energy of the system is very time consuming because many pairs of particles need to be considered. In the canonical ensemble, this does not need to be done in every attempted move. When a move is attempted, all molecules remain in their positions, except for one (molecule i). The energy change is the energy change of molecule i. 41

42 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Cut-off distance Intermolecular interactions fade away very quickly with distance unless there are electrostatic interactions. Therefore, after a few molecular radii, the interaction is very small. To save time, it is usual to define a cut-off distance beyond which interactions are neglected. 42

43 Monte Carlo method: details As in molecular dynamics, efficient implementation is very important. There are many “tricks”. Neighbor list Also, it is useful to keep a list of neighbors, i.e., the particles that are inside the cut-off distance or nearby. 43

44 Periodic boundary conditions What to do if a particle leaves the box as it moves? 44

45 Periodic boundary conditions To avoid the effect of borders on simulation results, surround the system by replicas of itself. 45

46 Periodic boundary conditions If a molecule leaves the system, another enters from the opposite side. 46

47 Periodic boundary conditions Each particle interacts with the nearest replica of its neighbors. 47

48 Radial distribution function Molecular simulations provide a lot of information that we will uncover as we discuss more of the fundamentals of statistical thermodynamics. One type of information – the radial distribution function – has to do with the structure of the substance being simulated. Formal definitions apart, the radial distribution function gives information about the average population of neighboring molecules as function of the intermolecular distance to a central molecule. 48

49 Radial distribution function To evaluate it via molecular simulation, one splits the space around each central molecule in spherical concentric shells and counts how many neighboring particles have their center there. Image source: http://rheneas.eng.buffalo.edu/w/images/e/e0/LJ_Rdf_shell_t.GIF 49

50 Radial distribution function The radial distribution function is the probability of finding the center of a neighboring molecule at a certain distance from the central molecule divided by the same probability for an ideal gas of same density. 50

51 Radial distribution function Lennard-Jones fluid. Image source: Wikipedia 51

52 Dimensionless quantities Dimensionless quantities are defined as follows: 52

53 Average properties from canonical MC simulations MC simulations provide the average radial distribution function in numerical form. From it, thermodynamic properties can be evaluated using formulas from Chapter 11. For spherically symmetrical molecules: 53

54 Instantaneous properties in canonical molecular simulations The instantaneous values of the configuration energy are calculated as part of the procedure – they are readily available. Let us examine how to compute the instantaneous pressure. The force that acts on a particle i in the x-direction and the acceleration in that direction are related as follows: 54

55 Instantaneous properties in canonical molecular simulations 55

56 Instantaneous properties in canonical molecular simulations Now, integrate both sides of the equation over a certain period of time and divide by this time interval to obtain time averages: 56

57 Instantaneous properties in canonical molecular simulations Summing all molecules: The left-hand side has time derivatives of the total kinetic energy direction in the x-direction, which are zero for a system in equilibrium. Then: 57

58 Instantaneous properties in canonical molecular simulations Considering all three directions x, y, z: Using the relationship between average kinetic energy and temperature: 58

59 Instantaneous properties in canonical molecular simulations Then: In an ideal gas, there are no intermolecular forces. The only forces acting on the system are interactions of molecules with the wall that confines the fluid in a reservoir. In this case: 59

60 Instantaneous properties in canonical molecular simulations In a real fluid: 60

61 Instantaneous properties in canonical molecular simulations In a real fluid: 61

62 Instantaneous properties in canonical molecular simulations Using that: it can be shown that: 62

63 Instantaneous properties in canonical molecular simulations The last term appears as an average, but can be applied to a single configuration to obtain an instantaneous pressure: 63 valid for MC or MD


Download ppt "Monte Carlo method: Basic ideas. deterministic vs. stochastic In deterministic models, the output of the model is fully determined by the parameter values."

Similar presentations


Ads by Google