Home

Participate (Download)

Help!

Education
  Teacher Page
  Distributed Computing
  Activities
  Amino Acids
  Proteins
  Genome
  Trivia Game
  Research
Articles
  Diseases
  Molecular Modeling
  Monte Carlo
  Validation of results
  Assessment
  Glossary

News

Stats

Science

Results

About

 

Education@Home | Teacher Page | Distributed Computing | Activities | Amino Acids | Proteins | Diseases | Molecular Modeling | Monte Carlo | Validation of Results | Assessment | Genome | Trivia Game | Research Articles | Glossary

The Basics of Monte Carlo Simulations

Introduction to Monte Carlo Methods

Related to molecular dynamics are Monte Carlo methods which randomly move to a new geometry/conformation. If this conformation has a lower energy or is very close in energy it is accepted, if not, an entirely new conformation is generated. This process is continued until a set of low energy conformers has been generated a certain number of times.

The expression "Monte Carlo method" is actually very general. Monte Carlo (MC) methods are stochastic techniques--meaning they are based on the use of random numbers and probability statistics to investigate problems. You can find MC methods used in everything from economics to nuclear physics to regulating the flow of traffic. Of course the way they are applied varies widely from field to field, and there are dozens of subsets of MC even within chemistry. But, strictly speaking, to call something a "Monte Carlo" experiment, all you need to do is use random numbers to examine some problem.

The use of MC methods to model physical problems allows us to examine more complex systems than we otherwise can. Solving equations which describe the interactions between two atoms is fairly simple; solving the same equations for hundreds or thousands of atoms is impossible. With MC methods, a large system can be sampled in a number of random configurations, and that data can be used to describe the system as a whole.

Monte Carlo Calculation of Pi

Can you get the value of 'pi' by throwing darts?

You can get very close to the value of 'pi' if you throw over a thousand darts.. or you can let the computer throw (simulate) the darts for you in a fraction of a second...how? just read on..


Figure 1

The figure 1 on the left, is simply a unit circle circumscribed by a square. We could examine this problem in terms of the full circle and square, but it's easier to examine just one quadrant of the circle, as in the figure 2, on the right.

If you are a very poor dart player, it is easy to imagine throwing darts randomly at Figure 2, and it should be apparent that of the total number of darts that hit within the square, the number of darts that hit the shaded part (circle quadrant) is proportional to the area of that part. In other words,


Figure 2

If you remember your geometry, it's easy to show that

If each dart thrown lands somewhere inside the square, the ratio of "hits" (in the shaded area) to "throws" will be one-fourth the value of pi. If you actually do this experiment, you'll soon realize that it takes a very large number of throws to get a decent value of pi...well over 1,000. To make things easy on ourselves, we can have computers generate random numbers.

If we say our circle's radius is 1.0, for each throw we can generate two random numbers, an x and a y coordinate, which we can then use to calculate the distance from the origin (0,0) using the Pythagorean theorem. If the distance from the origin is less than or equal to 1.0, it is within the shaded area and counts as a hit. Do this thousands (or millions) of times, and you will wind up with an estimate of the value of pi. How good it is depends on how many iterations (throws) are done, and to a lesser extent on the quality of the random number generator. Below is Flash version of this with Action Script (Flash scripting language) as follows:

Sample computer code. The one below is Flash 'Action Script' code, but it can be adapted to just about any programming language:

hits = 0;
darts = 0;
i = 0;
while (i<=user_input) {
x = Math.random();
y = Math.random();
t = Math.sqrt(2.0);
dist = Math.sqrt((x*x)+(y*y));
if (dist<=1.0) {
hits = hits+1;
}
if (dist<=t) {
darts = darts+1;
}
pi = 4*(hits/darts);
i = i+1;
}

Web author: Tug Sezen


 

 

 
(c) 2000-2002 Vijay Pande and Stanford University