Monte Carlo Simulations!

Traditional integration techniques are very efficient in solving simple integrals, however sometimes integrals can be impossible to evaluate analytically, leading to the use of Monte Carlo simulations. This method uses repeated random sampling to estimate the outcomes of an event. Using this technique, integrals that are virtually impossible to analytically calculate become much more manageable. However, due to the nature of repeated random sampling a large number of observations needs to be conducted to ensure an accurate estimate. Thus, a balance between speed and accuracy needs to be met, where the simulation is both fast (lower number of observations) and accurate (higher number of observations) to the true result.

Lennard Jones Potentials!

The Lennard Jones Potential is an approximation of the energy of nonbonded interactions (Equation 1). It is a pairwise potential and can be visualized as a graph with two main sections, a repulsive domain and an attractive domain. At a relatively great distance, the pair of atoms have negligible interactions and their potential is ~0. However as the particles are brought closer together, the interaction becomes attractive until the point $$r_m$$, where the potential energy is at a minimum of - $\varepsilon$ . At closer distances, the repulsive interactions overtake the attractive forces. The energy potential rising exponentially as the distance between them approaches 0. Conducting the approximation in reduced units is ideal because using SI units makes the values incredibility inconvenient to work with due to their very large or very small values and the inherent floating point error. The total pair potential energy of a system of particles can also be calculated by calculating the sum of the Lennard Jones energies over all pairwise interactions.

Figure 1: Graph of the Lennard Jones Potential, taken from https://en.wikipedia.org/wiki/Lennard-Jones_potential#/media/File:Graph_of_Lenanrd-Jones_potential.png

$$ U^\left(r_{ij} \right) = 4 \left[\left(\frac{1}{r^{ij}}\right)^{12} -\left(\frac{1}{r^*{ij}}\right)^{6} \right] $$ Equation 1: Reduced Lennard Jones potential equation

Python!

Writing code is a useful skill but documenting your code is an essential good coding practice. Writing docstrings within functions gives other programmers a rough idea of what your function does and what its parameters are. To write a docstring, start by writing three quotes and separating them with a line. Begin your docstring with a title of the function followed up with a short description (sometimes a title is descriptive enough). After the introduction you should write out the parameters used by the function as well as their data type and a short description. Then you should write what the function returns as well as its data type and a short description. Finally, you can conclude your docstring with some examples and the expected output.

Testing and debugging code is another useful skill and can be done painlessly using the assert function in python. To use it, write assert followed by a condition that you believe is true. If the condition evaluates to True, the program will continue to run. However if the condition returns False, the assert function will raise an assertion error at that point, at which you will need to troubleshoot the code.