Control Variables

Metropolis Monte Carlo is controlled by a number of variables. These effect the efficiency of the sampling, and so the number of moves that are required to converge a thermodynamic average.

The key variables are set at the top of the metropolis_pl script;

# Set the number of atoms in the box
$n_atoms = 25;

# Set the number of Monte Carlo moves to perform
$num_moves = 5000;

# Set the size of the box (in Angstroms)
@box_size = ( 15.0, 15.0, 15.0 );

# The maximum amount that the atom can be translated by
$max_translate = 0.5;  # angstroms

# Simulation temperature
$temperature = 298.15;   # kelvin

The number of krypton atoms in the box is set by the variable $n_atoms. Currently there are only 25 atoms. Try increasing or decreasing the number and re-running the script. How does this change the way the program runs? How does this change the number of accepted and rejected moves?

The total number of Monte Carlo moves to perform is set by the $num_moves variable. Currently it is 5000. This is not a lot. Typical Monte Carlo simulations use millions or billions of moves. Perl is too slow to run this many moves. The C++ version of this program (metropolis.cpp) runs 100 times faster, and is set to up 500,000 moves. Use the C++ program if you want to run lots of moves.

The size of the periodic box is set in the @box_size array. Try making the box bigger and smaller, and re-running metropolis_pl. How does this change the energy? How does it change the movie? How does it change the number of accepted and rejected moves?

The maximum amount by which to translate an atom is set in the $max_translate variable. This is currently 0.5 Angstroms. Try increasing and decreasing this value and re-running metropolis_pl How does this affect the movie, and the number of accepted and rejected moves?

Finally, the simulation temperature is set in the $temperature variable. It is currently 298.15 Kelvin (room temperature). Try increasing and decreasing the temperature, and re-running metropolis_pl. How does this affect the energy, and the number of accepted and rejected moves?