Continuing on Monte Carlo Simulation

Our primary topic today focuses on the application of the Monte Carlo simulation to generate sample configurations of particles in order understand and characterize the statistical mechanics of a system. However as powerful as Monte Carlo simulation is, simply considering all coordinates for our configuration is very inefficient. This is because although a randomly generated configuration may be possible, configurations with high energy are simply not likely to occur. Therefore it is useful to sample positions from a desired equilibrium probability distribution, where configurations that have a low probability are generated less frequently to more realistic and relevent configurations. This is the concept of importance sampling.

Implementing the Metropolis Criteron

To accomplish this, we are going to implement acceptance criteria, specifically the Metropolis-Hasting algorithm, to determine if we will accept a change in the position of a particle in a system considering the changes in the system energy that the positional shift imparts. The Metropolis-Hasting criterion we built into our model is as follows:

$$ P_acc Pacc(m → n) = min[1,e-$\Delta$U/T] $$

As we have established our system, if a configuration is energetically more favorable, it is always accepted. If a configuration is more energetically "uphill", a number is generated randomly on (0,1) and compared to the expression e-$\Delta$U/T. If the generated number is less than the result of the expression, the criterion is not met, and the change is rejected. By this model, all configurations with lower energy are always accepted, configuration with increases in energy are accepted a fraction of the time, and configurations that have great increases in energy are possible, but very unlikely.

We continued to investigate on the relation between the expression e-$\Delta$U/T and the probability density. Upon plotting the probability density against $\Delta$U from (-2,2) for different values of T the following graph was generated.

Figure 1: Probability density visualized against various $\Delta$U for three different temperatures

Upon discussing our models, we noted that for the domain $\Delta$U > 0, if the temperature of the system is higher, the probability density is also higher. This means that at higher temperatures, systems are more likely to enter states of higher energy. We also noted that for all $\Delta$U < 0, the generated Pacc was above 1.0 for all temperatures. However, because this value was only compared to a generated number from (0,1), the shift is effectively accepted 100% of the time. This lines up with our assumption that all configurations of lower energy are accepted.

Monte Carlo Looping

Using a function we built to calculate the sum of all pairwise interactions experienced by a particle, accounting for cutoff and periodic boundaries, we built a Monte Carlo simulation loop to simulate the step taken by our input configuration. If a step produces a state that is accepted by our Metropolis Criterion, then the step is accepted, the energy is recorded in a list, and the simulation continues. Otherwise, the step is reverted back to the original configuration before the generated changes, and the Monte Carlo randomly introduces another configuration. The Monte Carlo loop we built is shown below:

Random Seed, I mean random.seed()

A useful tool to build sanity checks for functions with random number generators is to call a seed. This means that the same sequence of random numbers are call by that seed anytime it is called. Very handy for teaching and debugging purposes.