Java applet for simulating spin systems
This is a simple Ising-type model written in Java. It simulates a system of spins located on the grid points of a lattice.
The spins are coupled to a heat bath with a temperature T = 1 / beta.
This applet then updates the spins on the lattice in order
to simulate the behavior of the spins for a given temperature.
-
You can adjust the size of the lattice by changing the values in the upper left
corner of the window. The default values define a two-dimensional lattice.
However, by changing
the number of points for the 3rd or 4th dimension from 1 to some other value you
can simulate a 3 or 4 dimensional system. The display of the spins on the right
always shows one plane within your lattice.
- The spins have a fixed length set to 1. You
can choose the number of spin directions between 2 (the standard Ising model)
and 8.
Beneath the number of spin orientations the value of the spin is shown, averaged over the lattice
and over the updates of the lattice. Also, its variation (errorbar) is shown.
When all spins are aligned the average spin is 1, whereas if all spin orientations
are completely random the spin average will approach 0 (one spin pointing upward
and one downward add up to zero).
- There are several options for the spin-spin interaction. The option
nearest neighbor means that a given spin interacts with its neighboring spins alone.
In the case of a 2-dimensional system this means a spin interacts with its left,
right, upper, and lower, i.e. 4, neighboring spins. In case of the choice
plus diagonal there are 4 more neighbors (upper-left, upper-right, ...).
The interaction strength is constant for these two cases. For the other two options
exp(-r)/r and exp(-r/2)/r
each spin interacts with every other spin on the lattice.
The strength of the interaction is given by the mathematical expressions just stated
(so-called Yukawa potentials),
where r is the distance between each pair of interacting spins.
Those options need a lot more computing, so the applet will slow down.
- You can change the temperature of the system by changing the value of beta which is
the inverse of the temperature as mentioned before. A large value of beta means that
the temperature is small and all spins tend to align with each other. Beta equal to
0 translates to infinite temperature which has the effect that all spins behave
completely randomly. You can also change the character of the spin system from
so-called ferromagnetic to anti-ferromagnetic by changing the sign of beta.
For positive beta the spins tend to align along the same direction, whereas in the case
of beta negative adjacent spins try to orient themselves in an anti-parallel way.
The specific structure
of the spins system will depend on your choice of interaction, however.
Playing around with
the various options will give you some idea of the different phases of your spin system.
- In addition you can switch on an external field which is always oriented along
the vertical axis. A positive value of the external field yields a tendency of the spins
to orient themselves pointing upward on the screen, whereas for a negative value the spins
tend to point downward. The strength of this
effect depends, of course, on the value you choose for the field.
- Before getting to the controls in the lower left part of the applet window,
let us discuss the display on the right side. As mentioned before in the upper right
the spins of the lattice are shown (or a single plane of the system in case of a
3 or 4 dimensional system). The arrows symbolize the direction of the spins. Each direction
is also connected to a specific color of the background. So you might
either look at the arrows or the colors to get an idea of what is happening with the
spin system.
- There are four segments in the lower right corner. The upper left panel shows a plot of
the value of the spin averaged over the lattice (blue)
and the same value averaged over all updates of the lattice (red) as they change with
successive updates of the spins on the lattice.
Here, first the average spin for a given lattice is determined, and then the absolute
value of this quantity is averaged over the updates - in contrast to the procedure
for the average value of the spin shown in the upper left part of the window.
The reason is that - without any additional external field - it is, e.g., equally probable to
have all spins pointing upward or downward. Thus, the average of this value tends to zero
over time even if all the spins are always aligned. This is not the case if one averages
over the absolute value as done here.
- The lower right panel shows the current spin averaged over the lattice. The orientation of
the arrow and its color represents the average spin direction whereas the absolute value
of the spin determines the size of the arrow.
- The upper right panel shows the correlation of the spin with another spin at some distance.
The horizontal axis represents the distance between the two spins, the vertical axis
is the value of the correlation (which is always one at distance 0, which is the leftmost
point in the plot). The red dots show the current values of the correlation averaged
over the lattice, the blue points (including black error bars)
are the corresponding values averaged over all updates of the lattice
(axis labels are still missing everywhere, I hope I'll get to fixing this, soon).
-
You can change either the value of the temperature or the external field continuously.
To do that you specify an amount of change in the lower left segment of the window,
and in addition the number of updates of the lattice after which the value of the
temperature or the field is altered. The applet will start with the continuous change
after you have entered the value for the amount of change. The value of
the average spin of the system with changing temperature/field is then plotted
in the lower left panel on the right part of the window. In case the increment is positive
green points mark the value and the evolution is plotted from left to right,
for a decrement the color is orange and the plotting is done from right to left.
The reason for this procedure is that sometimes when the spin orientations change drastically
with a change of parameters (phase transition) this change occurs differently if you
go from lower to higher values of the parameters or the other way round. Here, for instance,
you can choose a positive increment of the external field which will generate a green curve
and then you can change the sign of the increment and the average is spin is plotted from
right to left in orange. You can directly see whether both curves turn out to be on top of each
other or not (a so-called hysteresis or memory effect).
You can also go back and forth with the increments changing the
dimension of the system in-between and so on.
The curves don't get erased during the plotting. In order to clear the panel click
on the erase plot button. You can also interrupt the change of the parameters by
clicking on the stop button with the mouse. You can continue by clicking on it for a
second time.
- In case you need a break, click on the pause
button, which will freeze the applet until you
click on it again. There is also a help button which is, unfortunately, not yet
implemented.
This applet still needs improvement. I'll try to fix the deficiencies with time.
Now have fun playing around with the parameters!