The goals of Physics 366x build on those of physics 365x. We aim to teach you to use computational methods to solve real-world physics problems. At the same time, we aim to help improve and solidify the material you are learning in the paradigms. At the same time, you should learn:
The Ising model is a simplified model that is often used to for
ferromagnets. An Ising model consists of spins in a regular
arrangement, each of which has a few neighboring spins. The system is
defined by a set of values
which can have a value of
. Of course, real electrons have a spin of
, but the model is traditionally simplified by rescaling
the spin, since this doesn’t affect the resulting predictions. The
final knob that is present in the system is the magnetic field
, which is taken as a scalar. The Ising model is not an
accurate description of a ferromagnet, since spins are
quantum-mechanical objects, and can be oriented in any direction, but
it is a simple model has shows many of the same properties held by a
ferromagnet.
The total energy for an Ising model is:

Here you can see that the magnetic field
is given in
energy units and is allowed to be inhomogeneous—which is to say that
it may be different at different sites. You can think of this as
rescaling it by the magnetic moment of the electron. The second sum
is over pairs of lattice sites that are nearest neighbors, and has a
set of parameters
, with energy units, which describes the
interaction between neighboring spins.
Your first task will be to write a function that given matrices
describing
,
and the spins, will compute the
energy. For this task, we will restrict ourselves to two-dimensional
models, so a matrix is a reasonable choice to describe the spins and
magnetic field. A second task is to write a function that given a
matrix describing a set of spins will create a picture of that set of
spins.
Many of the interesting things that happen in ferromagnets happen when you change the temperature. Changing temperature computationally is possible, but requires considerable understanding of statistical mechanics—or the use of methods that you don’t understand. Instead, we are going to control the energy, which you should understand, and then find out the the temperature later.
If we let a system change while holding the energy fixed, the set of microstates it might change to is called the microcanonical ensemble. We will begin by exploring the microcanonical ensemble. In contrast, if we held the temperature fixed and allow the energy to change, then we would be using the canonical ensemble. The microcanonical ensemble is simpler, because within the microcanonical ensemble every microstate has the same energy, and is equally probable.
A microstate is a single possible state that the system could be in, which defines all possible things that could change in the system. In an Ising model, a microstate corresponds to the matrix that holds all the spins in the system. In contrast, a macrostate is by a set of measurements that you might have done to a system, and could correspond to many possible microstates. In the Ising model, a macrostate could be defined by the total energy, the total spin, or by both of them. You can distinguish macrostates from microstates by asking if you could possibly define two different systems that would have the same state.
A key postulate of statistical mechanics is that within a microcanonical ensemble—that is, if you take a system and isolate it so it is unable to exchange energy with its environment—all microstates are equally probable. This postulate allows us to make physical predictions, provided we are able to appropriately sample this ensemble.
In real systems, random transitions happen, and we can model this computationally using random numbers. Numerical methods that involve random numbers are called Monte Carlo methods, named after an area in Monaco famous for its casino. Monte Carlo methods can allow us to compute results that would be too challenging to compute using a precise, deterministic approach.
In our Ising problem, we know that within the microcanonical ensemble every microstate is equally probable, so if we were able to enumerate all the microstates corresponding to a given energy, we could compute any averaged quantity we should desire. But this is completely infeasible because even for moderately sized systems there are way too many possible microstates. So instead we look for an approach that will allow us to sample microstates with equal probability. Of course, this is what the real world does: the system evolves from one microstate to another in a quasirandom manner, but doesn’t actually explore every possible microstate.
The challenge in a microcanonical Monte Carlo approach is in constraining the energy to be fixed, since most possible transitions will end up changing the energy somewhat. We handle this by allowing small changes in energy, thus keeping the energy approximately constant.
The Monte Carlo approach for a microcanonical ensemble consists of the following code beyond what you have already written:
To compute thermodynamic quantities (e.g. the magnetization), you will average over all the acceptable microstates that you have explored.
Your first task is to implement these functions, generating a sequence of microstates.
We will begin by studying a system with
, which is to say,
with no interactions between neighboring spins. This is a
particularly simple system, and we will use it to improve our
understanding of how the Ising system behaves in an inhomogeneous
magnetic field. For this problem, you can use a simple linear
gradient in the magnetic field.
Once you can compute a sequence of possible states, you will want to compute averages and probabilities over all those states. You can begin by computing the average magnetization of each spin, and plotting this as a function of the magnetic field. Observe what happens to this plot when you change the value of the energy.
Try plotting the relative probability of the spin being up or down (i.e. the number of times a given spin is up divided by the number of times it is down), as a function of magnetic field. This should be a simpler plot than the magnetization plot. Try taking a suitable logarithm to see if you can simplify this plot even further. This plot will allow us to find the temperature of a given system (as we will discuss in class).
Once you have observed the Boltzmann factor, have your program fit the curve to find the temperature. The details for this process will be given in class. Try adjusting the total energy, and for each total energy solve for the temperature, so you can create a plot of internal energy (i.e. total energy) versus temperature for your system.
See what happens when you add a negative value for
. In
order to use our previous results as a “thermometer”, keep
for part of your system, and use the same range of
values
for that region as you did last time. For the
portion of
the system, pick some moderately small value for
. That way
you can compute the energy distribution in that region in order to
determine the temperature. Both portions should be reasonably large.
Try a few different energies, and visually observe what happens. Now work out the temperature for each simulation based on the thermometer section, and plot the mean polarization versus temperature.
Please pick an interesting physics problem to solve, and solve it. You should pick a problem that you cannot solve without using a computer.