Homework 3#
Due on Friday Oct 13 by midnight.
In this homework, we will look at some applications of Monte Carlo methods.
1. Diffusion-limited aggregation [Solution]#
In this question we want to model the growth of a crystal starting with a small solid “seed” that grows as particles from the liquid randomly encounter the seed and stick to it. Once the particle sticks, it becomes part of the solid and can in turn cause liquid particles to stick to it. In this way, the liquid particles freeze onto the growing solid. Because the rate of growth is set by how quickly the liquid particles diffuse and encounter the growing crystal, this process is known as diffusion-limited aggregation.
(a) First model the liquid particles – consider a collection of
A simple way to do this is to assume that the particles can only occupy discrete locations (
Implement this and plot the trajectories of your particles. Investigate how the distance moved from the starting location depends on time. Is it what you expect for a random walk?
(b) Now create a separate
(c) Plot the number of solid particles against time. How does
(It may also help to plot the number density of liquid particles as a function of radial distance from the centre of the grid and look at how it evolves with time).
2. Ising model [Solution]#
The Ising model is a simple model of a ferromagnetic material in which a lattice of spins interact via nearest-neighbour interactions. In 2D, we have a square lattice with
where “nn” in the sum indicates that the sum is over nearest-neighbour pairs (with each pair counted once). Any given spin interacts only with the spins that are immediately up, down, left and right from its location. We can see that the energy will be minimized when neighbouring spins are aligned.
For any given configuration of spins, the total magnetization is
At a temperature
To calculate the magnetization at a given temperature, we need to sample the possible configurations from this probability distribution and then we can average over them to find the mean magnetization
(a) Use the Metropolis-Hastings algorithm to generate a sample of configurations
Some hints:
for the proposal step of the Metropolis algorithm, you can choose a spin at random and consider flipping it from up to down or vice versa.
when you assess whether or not to accept the proposed change, you can use the change in energy due to the spin flip, which is
(where the spins here are the current values before the spin flip).
you can use periodic boundary conditions for the lattice, and you might find it simpler to store the spins in a 1D array rather than a 2D array.
(b) Make plots of your chains of
(c) Plot the mean magnetization