Jump to content

Rep:JJ1516Ising

From ChemWiki

Introduction to the Ising Model

The Model

Minimum Energy State

Minimum Interaction Energy

The interaction energy of an Ising lattice is given by:

E=12JiNjneighbours(i)sisj

In an Ising lattice with D dimensions and periodic boundary conditions, a given spin si has 2D neighbours.

The minimum interaction energy is achieved when all spins in the lattice are aligned (all ↑ or all ↓). As such, any spin si must be aligned with all 2D of its neighbours. That is, sisj=1 for all j.

Therefore, for any si, the sum of its interactions is jneighbours(i)sisj=2D

As this is true for all N spins in the lattice, it follows that iN2D=2DN.

Thus the minimum interaction energy is given by:

Emin=12J2DN=DNJ

Entropy of the Minimum Energy State

The entropy of a state is given by:

S=klnΩ

Where Ω is the multiplicity of the state, the number of degenerate configurations of said state. The minimum energy state is achievable with all spins ↑ or with all spins ↓. In the absence of an external magnetic field, these configurations are degenerate and indistinguishable giving Ω=2 for this state. Therefore,

SEmin=kBln2=0.693kB=9.57×1024JK1

Phase Transitions

Changes to Minimum Energy Configuration

Energy Change

The energy change ΔE associated with a single spin 'flip' from the lowest energy onfiguration may be calculated by considering the change in the interaction energy with the spin's neighbours.

Let D=3,N=1000

ΔE=E1E0

E1 Interaction energy after one spin has been 'flipped'

E0 Lowest energy configuration

interactions=2D+2D(2D2)+2D[N(2D+1)]


=2DN8D


E1=12Jinteractions=4DJDNJ


ΔE=E1E0=4DJDNJ+DNJ=+4DJ=+12J

This energy change is independent of N and depends only on the dimension size and the coupling constant J.

In this calculation, the following assumption has been made.

  • The lattice dimensions are infinite relative to the size of each cell

This allows any cell to be treated as the centre of the lattice. As every cell interacts with 2D neighbours, flipping any cell in the minimum energy configuration results in the same energy change. Alternatively, the periodic boundary conditions of the Ising model remove the necessity for such an assumption. As a consequence, the absence of N from the resulting energy change is justified.

Entropy Change

S=kBlnΩ

Ω=N!N!N!

Where Nx! denotes the factorial of the number of spins in spin state x.


ΔS=kBln(Ω2Ω1)

Ω2=1000!999!1!=1000

Ω1=1000!1000!=1

ΔS=kBln1000=9.54×1023JK1

ΔSmol=NAkBln1000=57.4JK1mol1

Magnetisation Values of 1D and 2D Lattices

M=isi

1D Lattice Magnetisation

M1D=+1

2D Lattice Magnetisation

M2D=+1

Magnetisation at 0K

At 0K, no thermal energy is available to overcome the energetic barriers to spin flipping. Considering the Hemholtz free energy:

A=ETS

A temperature of 0K nullifies the entropic contribution to the free energy. Thus the energetic driving force (which maximises parallel spin interactions) dominates the entropic driving force (which maximises multiplicity of lattice states). For an Ising Lattice with D = 3, N = 1000 at 0K, the alignment of all spins results in the minimum energy configuration and an overall magnetisation of M=±1000.

Calculating the Energy and Magnetisation

Modifying the Files

Energy and Magnetisation Functions

=Energy

The above energy method segments a given lattice into lattice cells on the edges, corners or in the bulk of the lattice and calculates the energy interactions with its neighbours as appropriate.

Magnetisation

The magnetisation method loops over all elements in the array representing the Ising lattice and adds the value of the spin to the magnetisation variable.

Testing the Files

ILCheck.py


Above, the results of the ILcheck.py script are presented.


Introduction to the Monte Carlo Simulation

Average Energy and Magnetisation

Configurations of a 100 Spin System

For a system of two spins, 4 configurations are possible (↑↑, ↓↓, ↑↓, ↓↑) i.e. 22. For a system of 100 spins, there are 2100 configurations. In the first example, the ↑↑ and ↓↓ are degenerate, as are the ↑↓ and ↓↑ configurations. Therefore, dividing the number of possible configurations by the multiplicity of each configuration (2) gives the number of non-degenerate configurations. As previously stated, degenerate configurations are indistinguishable in the absence of an external magnetic field.

For 100 spins, this gives 21002=6.338×1029 distinguishable configurations.

If processing speed permits 1×109 calculations each second, the evaluation of a single value of MT would last 6.338×1020 seconds or 1458 times the age of the Universe!

Modifying IsingLattice.py

Monte Carlo and Statistics Methods

The Metropolis Monte Carlo (MMC) algorithm provides a computationally inexpensive path from random initial states to the minimum free energy states of the Ising lattices generated. First, a random 2D Ising lattice is generated. A single random spin within this lattice is "flipped" and the resulting (internal) energy change between these states is measured. Recalling the relationship between the Hemholtz free energy, internal energy and entropy, it follows that a decrease in internal energy also lowers the free energy of the system: thus the configuration change is accepted.

In the case that the spin "flip" does not lower the internal energy, the MMC algorithm tests this configuration change against the Boltzman factor. In the canonical (NVT) ensemble, the free energy of the system is given by:

A=kBTlnZNVT

where Z is the canonical partition function which depends upon eΔEkBT, the Boltzman factor. By choosing a random value in the interval [0,1)from a continuous uniformm probability distribution and rejecting any value of the Boltzman factor less than this value, the MMC algorithm allows for configuration changes with small, positive internal energy changes if they conform to the Boltzman probability distribution. Alternatively, the MMC allows small perturbations to the internal energy which prevents the system from settling in a metastable internal energy minimum and instead, ensures that the system equilibrates around the true free energy minimum.

Spontaneous Magnetisation

Below the Curie Temperature, TC, the energetic driving force dominates the entropic driving force, resulting in a highly ordered system and an overall magnetisation. The spins of the system align in order to maximise favourable coupling interactions rather than adopting a less ordered configuration of higher multiplicity. Therefore, when T<TC, the most probable configurations have an overall magnetisation resulting in M0.

The plots of magnetisation per spin and energy per spin obtained from ILanim.py support this prediction. Below, the plots show that upon equilibration, the system adopts the minimum energy per spin: Eminspin=NDJN=DJ=2 and exhibits the maximum magnitude of magnetisation per spin: |Mspin|=1


An unknown system error prevented the statistics() function from printing the average values.

Accelerating the Code

Initial Method Speeds

Taking 10 repeat measurements for the time taken to perform 2000 Monte Carlo steps resulted in

  • An average time of 11.7s
  • A standard error of 0.020s

Updating Measurement

NOTE: ILtimetrial.py has been modified to:

  • Perform a requested number of '2000 Monte Carlo Step' measurements
  • Record these measurements in a CSV file
  • Return the mean measuremd time and the Standard Error i.e. σn

Updating Energy and Magnetisation Methods


Updated Method Speeds

Taking 30 measurements of the time taken to perform 2000 Monte Carlo Steps resulted in:

  • An average time of 0.87s
  • A standard error of 2.5×103s

This represents a 93% decrease in the average computation time from the initial methods.


The Effect of Temperature

Correcting the Averaging Code

Finding a Delay Value

To quickly find a value for Nd, the minimum number of cycles typically needed for the equilibration of a system of within the lattice and temperature ranges of interest, it was assumed that:

  • Larger lattices would require more Monte Carlo steps to reach equilibrium from their initial, random configurations
  • Lattices at lower temperatures would require more Monte Carlo steps to reach equilibrium from their initial, random configurations.

Therefore, an initial value for Nd was found for a 128×128 lattice at a temperature of 0.5 reduced temperature units.

  • Nd=185000

By this number of steps, all smaller lattices at all higher temperatures were found to have equilibrated also. Thus, this value ofNd was accepted as an appropriate delay.



For the 128x128 lattices at T=0.5, equilibration was ensured from 185000 steps onwards.


Smaller lattices at the same temperature did indeed equilibrate more slowly, but all equilibrated within Nd MC steps.



The figure below shows the modifications made to IsingLattice.py to incorporate the Nd step delay.

Running over a Range of Temperatures

To examine the effect of temperature on the average energy E and average magnetisation M of Ising lattices at equilibrium, the following parameters were used:

  • Temperature Range: 0.55 reduced units
  • Temperature Interval: 0.01 reduced units (450 temperature values)
  • Number of MMC Steps per Temperature value: 2×105 with the aforementioned value of Nd=1.85×105 Monte Carlo steps
  • Lattice Sizes: 2×2, 4×4 , 8×8 , 16×16 , 32×32 , 64×64

Plots of E and M per spin as versus temperature are presented below for each lattice size. Errorbars have been implemented to demonstrate how well-behaved lattice systems of each size are at each temperature, that is, how temperature and lattice size affect the size of the variations in the expected values. For the error calculations, the standard errors, σX¯, in E and M per spin have been used:


8x8


A Python script has been written to generate a plot of E or M against temperature based upon user input. A screenshot of this code has been inserted below.


The Effect of System Size

Scaling the System Size

More Lattice Sizes

2x2

4x4

16x16

32x32

64x64


Scrutiny of the plots of average energy per spin for each lattice size reveals an increase in the errorbar width with increasing lattice size. This is most notable in the low temperature region of the plots. Between the 8×8 and 16×16 lattices, the long range fluctuations become suddenly prominent. The 16×16 lattice is the first (in the range of sizes tested)to clearly capture these fluctuations.

Determining the Heat Capacity

Calculating the Heat Capacity

Heat Capacity Derivation

Working in the canonical ensemble (constant volume), the heat capacity CV is given by:

CV=ETV

where E is the average total energy or expected value of the internal energy of the system.

E=lnQβ=1QQβ

where Q is the partition function for the system of N interacting spins.

By evaluating the second form of the partial derivative with respect to β:

E=1QQβ=ΣϵieβϵiΣeβϵi


Applying the product rule enables the differentiation of this expression for E with respect to temperature, giving:

ET=ΣϵiϵikBT2eβϵiΣeβϵiΣϵieβϵiϵikBT2eβϵi(Σeβϵi)2


ET=1kBT2[Σϵi2eβϵiΣeβϵi(ΣϵieβϵiΣeβϵi)2]

ET=1kBT2[E2E2]

Thus,

ET=Var[E]kBT2

Heat Capacity versus Temperature

Below, a screenshot of the Python script written to produce plots of CV against T, together with the output images of this script.


2x2


4x4

8x8


16x16


32x32

Locating the Curie Temperature

C++ Data Comparison

Below a comparison of the CV against T plot generated for the 2/times2 to the corresponding C++ data is offered.

The data generated by the ILtemperaturerange.py script is a faithful match to the C++ data. However, this is an exceptional case; the plots for all other lattice sizes were found to be very dissimilar, necessitating polynomial fitting.

Polyfitting of C++ Data

Fitting a Polynomial to the Entire Range

The following Python script was written to perform a polynomial fit to the entire range of the graph of CV against T.


Below, the result of the polyfit to the 2/times2 lattice data is offered (for comparison to the previous, non-fitted example).

Polynomials with 5 terms and above were found to match the data in the vicinity of the critical region considerably well. Below 7 terms, the tails of the plot were matched poorly. In the above example, a polynomial of 15 terms was fit to the data.


Fitting a Polynomial to the Critical Region

The following Python script was written to perform a polynomial fit to the region of interest (the critical region) of the plots of CV against T to facilitate the discovery of TC.

An example of the result returned by the script is offered below for the C++ data for the 16×16 lattice.


Finding the Peak C Values for Each Lattice Size

Below, a screenshot of the code used to obtain the temperatures at which the maximum values of C occured is presented for each lattice size. The temperatures themselves are also featured on the image.

The range of lattice sizes and their associated TC values were exported to a text file, enabling a plot to be created.

Subsequently, the scipy.optimize.curve_fit function was used to fit TC,L=AL+TC, function to the data obtained. This enabled the estimation the constant A and the value of TC at AL=0, otherwise TC,.

A value of TC,=2.2799 was obtained. A comparison to the literature[1] value of 2.269 reveals a percentage error value of only 0.47%. Surprisingly, the investigation of lattices in the given size range was enough to capture the theoretical behaviour of an infinite lattice. As explained by Frenkel and Smit, the implementation of periodic boundary conditions enables the simulation of an infinite bulk (or infinite adjacent lattices) surrounding the single lattice under scrutiny. The agreement of the experimental and theoretical values for TC, prove the effectiveness of this idea.


A likely source of error arises from the polynomial fitting of the data. The peaks in CV against T were far more sharp than the broad peaks of the polynomial functions used to fit them. In several cases, the polynomial peak was a slight, yet discernible overestimate of the true peak. This has resulted in an overestimation of the final TC, value. Fitting a function with a sharper peak (e.g. a Kronecker delta function) to the critical region could overcome this overestimation and provide a more faithful final value.

References

  • Frenkel, Daan, et al. Understanding Molecular Simulation : From Algorithms to Applications, Elsevier Science & Technology, 2001
  • Krieger, M. Constitutions of matter : Mathematically modeling the most everyday of physical phenomena. Chicago ; London: University of Chicago Press, 1996