Sei sulla pagina 1di 11

Monte Carlo Methods in Physics Ising model and Metropolis Algorithm

01-16-2010

Matthias Reggentin reggentin@physik.hu-berlin.de

Contents

Contents
1 Issue of this report 2 Ising model 3 Monte Carlo Method and Implementation 4 Results and Conclusions A Source code 2 2 3 4 8

2 Ising model

Issue of this report

A numerical solution of the two dimensional Ising model was carried out using the Metropolis algorithm as Monte Carlo method. This type of model was chosen since the analytical solution of the problem exists [1] as well as a number of dierent implementations, e.g. [2, 3, 4, 5] so that the produced code can be tested well. The code was written in Scilab, since the simulation for this assignment does not aim to be the fastest but proper graphical output is included within this tool. Besides, it is a piece of free Software. Moreover, the code should be also runnable under Matlab with modied syntax for the random number generator and the graphical output, even though it is not tested.

Ising model

The Ising model is a widely used model system in statistical physics, as well as other elds like neurology or social science. It is possible to use the model to describe properties of a system that evolves statistically. A physical system can be described by its energy, i.e. its Hamiltonian H . When the components of a system are arranged in a lattice and interact due to coupling, further referred as the intaction strength Jij between the elements Si and Sj of the system the Hamiltonian of the system for a specic conguration of all elements S = {Si , Sj } i, j is given by H (S ) =
ij

Jij Si Sj u
i

Si .

(1)

Further contributions to the energy can be achieved by an additionally potential u that eects the systems components. To ll eq. (1) with life, a typical example can be given where the Hamiltonian describes a ferromagnetic material. Here the properties of the elements can be identied as the spins of the particular lattice points that can have the values -1 and 1 for spin and spin , respectively. The potential is given by an outer magnetic eld B . For the following treatment of the problem some constraints are introduced. First of all, for reducing the necessary calculation steps the problem of the interaction is boiled down to nearest neighbour interaction and the interaction strength between the components of the system is set to a constant value Jij const =: J . Additionally, the potential is set u = 0. So one gets H (S ) = J
ij

Si Sj .

(2)

It possible to solve this problem exactly for an innite two dimensional lattice. The statistical system is described by its partition function Z (J, T ) =
S

eH (S ) , =

1 , kB T

what from, to follow the ferromagnetic material example up, the properties of the system e.g. the energy and the magnetization can be deduced. Referring to [6] one nds the following solution for the overall lattice magnetisation M = (nx ny ) (1 + z 2 ) 4 (1 6z + z 4 ) 8 (1 z 2 ) 2
1 1 1

(3)

3 Monte Carlo Method and Implementation

in the limit that the dimension of the lattice is nx,y and where z = e2J . The energy is given by E = (nx ny ) J coth(2J ) 1 + where = 2 tanh2 (2J ) 1 sinh(2J ) = 2 cosh2 (2J )
2

K () 2

(4)

(5) (6) (7)

K () =
0

1 1 2 sin2 ()

Moreover one nds that there exists a phase transition for = 1, i.e. that above a critical value no spontaneous formation of the elements without an outer potential can be obtained any longer. Due to eq. (6) and eq. (7) the critical value is given for = 1 by J = 0.4407 . So one can give a critical temperature Tc in units of J/kB where the phase transition should take place. Tc = 2.2692 J . kB

The existence of such a point is evident due to the fact that a low interaction strength between the elements or too high temperatures lead to disorder in the system so that ordering within in the system becomes really improbably or impossible from a certain point.

Monte Carlo Method and Implementation

To nd a solution for such kind of problem a quadratic lattice of the size N N was chosen. A calculation of all possible states is practically impossible. Therefore Monte Carlo methods can be used where just randomly chosen congurations are calculated for obtaining an approximation of the solution. For the problem the Metropolis algorithm can be used to get the solution. In that case the idea is to test the evolution of the system for a randomly chosen conguration, here the temperature T as property, for a randomly disordered lattice where the elements can have the properties 1 or -1. The probability p for the process of ipping an elements property 1 1 is given by the Boltzmann distribution, i.e. low energy states are preferred. One gets p = = eE1 Z p(1 1) = E = e E 1 p(1 1) Z e e E , for E > 0 1, for E 0

(8)

So the evolution of the system can be simulated by randomly picking out an element of the lattice, assume all other elements as static, calculate the probability for a ip and execute the ip if necessary. For the case E > 0 the condition for a ip is set to r < p where r is a random number from a at distribution between 0 and 1.

4 Results and Conclusions

Just a 20 20 big lattice was chosen for the simulation due to the fact that the evolution steps of the system had to be set to 100000 for achieving condent nal states, so that the calculation time could be limited to manageable intervals for my hardware by the small sized lattice. To come closer to an innite lattice periodic boundary conditions where used. I.e. the lattice is extended to an innite one with the periodicity of the base cell which is given by a N N lattice. So that the property of the element at position l, m is identical to the one at position l + n1 N, m + n2 N element, where n1 , n2 Z.

Results and Conclusions

At rst the value for the critical temperature was tested using the script tctest.sce which is given in the appendix. One achieves good conrmation with the expected value although the number of calculated points was not that much. The behaviour of the magnetisation

Magnetisation vs. Temperature 1.0

0.8

0.6

0.4 Magnetisation m

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0 0.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

4.5

5.0

Temperature T [J/kB]

Figure 1: Simulation of the critical temperature Tc . The result ts well with theoretically value of 2.2692 J/kB . The red line displays the analytical solution.
Energy vs Temperature -0.5

-1.0

-1.5

Energy [J]

-2.0

-2.5

-3.0

-3.5

-4.0 0.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

4.5

5.0

Temperature T [J/kB]

Figure 2: Simulation of the energy behaviour when the temperature of the system is changed around critical temperature.

4 Results and Conclusions

is plotted in g. 1. The associated energy plot is shown in g. 2. Also these values are in good qualitative agreement with the analytical solution. For T 0 the system evolves into well ordered states so that nearly all spins are aligned. For the shown energy per element the energy goes to the lowest possible value 4 J . For temperatures T /Tc 1 the system stayed disordered so that the average value of the energy goes to 0. Taking the singularity in eq. (6) into account the rst derivative of the energy in eq. (4) should diverge for T Tc . Just that can be seen in g. 2 at Tc . The simulation ts well with the analytical solution as well as in comparison with the former mentioned simulations when kB Tc is set 1. To illustrate possible nal states for dierent congurations some examples are given. For the rst one in g. 3 the interaction strength is chosen relatively high, the temperature is set to the critical temperature. As one can see that yields relatively high ordering.
initial spin state

final spin state

Figure 3: J = 0.7, T /Tc = 1

4 Results and Conclusions

As a second example the temperature was enhanced to T /Tc = 8 which is shown in g. 4. Therefore the possibility for spontaneous ip processes in the system are that high that no ordering can be seen after a longtime evolution of the system. In a third example, with the result plotted in g. 5 the interaction strength was reduced what leads to the same results as an increased temperature.
initial spin state

final spin state

Figure 4: J = 0.7, T /Tc = 8 Within this assignment a two dimensional Ising model was simulated and its solutions compared with the analytical results of the model. It was possible to verify the results. On the basis of these simulations other simulations can be done where no analytical solution exists. E.g. it would be possible to investigate the inuence of an outer potential which is already provided in the source code. Moreover, it would be easy to extend the model to a three dimensional lattice, nevertheless it would be nearly impossible to achieve results in an appropriate time using my hardware. But for the case that the dimensions of the lattice can be changed independently in every direction it would be interesting to analyse the behaviour of the systems properties near to the dimension changes 3D2D1D what would lead to nice nano-science-like results when one continue to analyse quantum systems.

References

initial spin state

final spin state

Figure 5: J = 0.1, T /Tc = 1

References
[1] L. Onsager, Phys. Rev. 65, 1944, 117 [2] J. Gudmundsson, http://www3.tsl.uu.se/~ingelman/graduate school/courses/ montecarlo/hand-in/jon emil gudmundsson.pdf [3] F. Hebenstreit, http://www3.tsl.uu.se/~ingelman/graduate school/courses/ montecarlo/hand-in/felix hebenstreit.pdf [4] S. Sellner, http://www3.tsl.uu.se/~ingelman/graduate school/courses/ montecarlo/hand-in/stefan sellner.pdf [5] E. Ak c oltekin, http://sysmod.icb.uni-due.de/fileadmin/sysmod template/ main/resources/lehre/StudArbeiten/ising/ising.pdf [6] K. Huang, 1963, Statistical Mechanics

A Source code

A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

Source code
// // file ising2D_v3.sci // // 2D impementation of the Ising model for a ferromagnet // // input // N: scalar, grid dimension // J: scalar, interaction strength // H: scalar, outer magnetic field // T: scalar, temperature of the system // Iter: scalar, number of iterations for the evolution loop // f: if f==1 create fig. of the inital and final state // if f<>1 suppress fig. creation // // output // S: NxN matrix, spins at the grid points // M: scalar, overall magnetisation of the grid // E: scalar, overall energy of the grid // function [S,M,E]=ising2D_v3(N,J,H,T,Iter,f) // initialisation of the spins S within the quadratic // crystal grid - spin up/down corresponds to 1/-1 S = 2.*round(grand(N,N,def))-ones(N,N); if f==1 then clf(42); // plot initial spin condition scf(42); subplot(211); Matplot(S.*21,"040"); xtitle(initial spin state); end // system evolution Tc = 1; // set for the simulation of the crit. temp. //Tc = 2.2692; // [Tc] = J/kB -> [T]=1/Tc for i=1:Iter, k = ceil(grand(1,1,unf,0,N)); // randomly selected grid point l = ceil(grand(1,1,unf,0,N)); // energy change due to nn interaction when spin is flipped Ekl = -2.*J.*S(k,l).*(S(modulo(k-2+N,N)+1,l) + ... S(modulo(k,N)+1,l) + S(k,modulo(l-2+N,N)+1) + ... S(k,modulo(l,N)+1)) - S(k,l).*H; if Ekl>=0 | grand(1,1,def)<exp(Tc*Ekl./T) then S(k,l)=-S(k,l);

A Source code

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

end end if f==1 then subplot(212); // plot final spin condition Matplot(S.*21,"040"); xtitle(final spin state); end Eij = []; for i=1:N for j=1:N // overall energy calculation

Eij = [Eij,-J.*S(i,j).*(S(modulo(i-2+N,N)+1,j) + ... S(modulo(i,N)+1,j) + S(i,modulo(j-2+N,N)+1) + ... S(i,modulo(j,N)+1)) - S(i,j).*H]; end end E = sum(Eij); M = sum(S); // overall magnetisation

// // file tctest.sce // // numerical calculations for a value of the critical // temperature // clear; exec ising2D_v3.sci; Mtest = []; // // Etest = []; // // Ttest = []; // collection vector for the magnetization per grid point collection vector for the energy per grid point coolection vector for the choosen T

Ntest = 100; // number of tests N = 20; J = 1; H = 0; Iter = 100000; for i=1:Ntest T = grand(1,1,unf,0,5); // randomly choosen 0<=T<5 [S,M,E] = ising2D_v3(N,J,H,T,Iter,0);

A Source code

10

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

Mtest = [Mtest,M./N./N]; Etest = [Etest,E./N./N]; Ttest = [Ttest,T]; end // plotting clf(1); scf(1); plot(Ttest,Mtest,*k); xtitle(Magnetisation,Temperature T,... Magnetic moment per grid point m); clf(2); scf(2); plot(Ttest,Etest,*k); xtitle(Energy,Temperature T,... Energy per grid point E);

Potrebbero piacerti anche