1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Computational Physics - M. Jensen Episode 2 Part 2 doc

20 217 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 20
Dung lượng 269 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Table 11.1: Energy and magnetization for the one-dimensional Ising model withN = 2 spins with free ends FE and periodic boundary conditions PBC.. Table 11.2: Degeneracy, energy and magne

Trang 1

11.1 PHASE TRANSITIONS IN MAGNETIC SYSTEMS 189

where the vectorspin[℄contains the spin values

k

= 1 For the specific stateE

1, we have chosen all spins up The energy of this configuration becomes then

E

1

= E

""

= J:

The other configurations give

E

2

= E

"#

= +J;

E

3

= E

#"

= +J;

and

E

4

= E

##

= J:

2 We can also choose so-called periodic boundary conditions This means that ifi = N, we set the spin number toi = 1 In this case the energy for the one-dimensional lattice reads

E

i

N

X

j=1 s

j s

j+1

and we obtain the following expression for the two-spin case

E = J (s

1 s

2 + s

2 s

1

In this case the energy forE

1is different, we obtain namely

E

1

= E

""

= 2J:

The other cases do also differ and we have

E

2

= E

"#

= +2J;

E

3

= E

#"

= +2J;

and

E

4

= E

##

= 2J:

If we choose to use periodic boundary conditions we can code the above expression as jm=N ;

f o r ( j = 1 ; j <=N ; j ++) {

e n e r g y + = s p i n [ j ]s p i n [ jm ] ;

jm = j ; }

Trang 2

Table 11.1: Energy and magnetization for the one-dimensional Ising model withN = 2 spins with free ends (FE) and periodic boundary conditions (PBC)

Table 11.2: Degeneracy, energy and magnetization for the one-dimensional Ising model with

N = 2spins with free ends (FE) and periodic boundary conditions (PBC)

The magnetization is however the same, defined as

M

i

= N

X

j=1 s

where we sum over all spins for a given configurationi

Table 11.1 lists the energy and magnetization for both free ends and periodic boundary con-ditions

We can reorganize Table 11.1 according to the number of spins pointing up, as shown in Table 11.2 It is worth noting that for small dimensions of the lattice, the energy differs depending on whether we use periodic boundary conditions or fri ends This means also that the partition functions will be different, as discussed below In the thermodynamic limit however,N ! 1, the final results do not depend on the kind of boundary conditions we choose

For a one-dimensional lattice with periodic boundary conditions, each spin sees two neigh-bors For a two-dimensional lattice each spin sees four neighboring spins How many neighbors does a spin see in three dimensions?

In a similar way, we could enumerate the number of states for a two-dimensional system consisting of two spins, i.e., a 2  2 Ising model on a square lattice with periodic boundary conditions In this case we have a total of2

4

= 16states Some examples of configurations with their respective energies are listed here

E = 8J

" "

E = 0

" "

E = 0

# #

E = 8J

# #

Trang 3

11.1 PHASE TRANSITIONS IN MAGNETIC SYSTEMS 191

In the Table 11.3 we group these configurations according to their total energy and magneti-zation

Table 11.3: Energy and magnetization for the two-dimensional Ising model with N = 2  2

spins with periodic boundary conditions

Exercise 11.1

Convince yourself that the values listed in Table 11.3 are correct

For a system described by the canonical ensemble, the energy is an expectation value since

we allow energy to be exchanged with the surroundings (a heat bath with temperatureT) This expectation value, the mean energy, can be calculated using the probability distributionP

i as

hE i =

M

X

i=1 E

i P

i ( ) =

1

Z

M

X

i=1 E

i e Ei

with a corresponding variance defined as

 2

E

= hE 2

i hEi

2

= 1

Z

M

X

i=1 E 2

i e E

i 1

Z

M

X

i=1 E

i e E

i

!

2

If we divide the latter quantity withkT

2

we obtain the specific heat at constant volume

C

V

= 1

kT 2 hE 2

i hEi

2



Using the same prescription, we can also evaluate the mean magnetization through

hMi =

M

X

i M

i P

i ( ) =

1

Z

M

X

i M

i e E

i

and the corresponding variance



2

M

= hM 2

i hMi

2

= 1 M

X

M 2

i e Ei

1 M

X

M

i e Ei

!

2

Trang 4

This quantity defines also the susceptibility

 = 1

kT hM 2

i hMi

2



It is also possible to show that the partition function for the one-dimensional case forN spins with free ends is

Z

N

N 1

If we use periodic boundary conditions it becomes

Z

N

= 2 N



J)℄

N

+ [sinh( J)℄

N



In the limitN ! 1the two results agree

We can then calculate the mean energy with fri ends from the above formula or using

hEi =

lnZ



If we take our simple system with just two spins in one-dimension, we see immediately that the above expression for the partition function is correct Using the definition of the partition function we have

Z

2

= 2

X

i=1 e E

i

= 2e

+ 2e

If we take the limitT ! 0( ! 1) and setN = 2, we obtain

lim

!1 hEi =

e J

e J

e J

+ e J

which is the energy where all spins point in the same direction At low T, the system tends towards a state with the highest possible degree of order

The specific heat in one-dimension with free ends is

C

V

= 1

kT 2

 2

 2 lnZ

N

= (N 1)k



J

J )



2

Exercise 11.2

Calculate the exact partition function for a system of three spins with the

one-dimensional Ising model using both free ends and periodic boundary conditions

For our two-dimensional2  2lattice we obtain the following partition function

Z = 2e

8J

+ 2e 8J

and mean energy

hEi =

1

16e 8J

16e 8J



Trang 5

11.1 PHASE TRANSITIONS IN MAGNETIC SYSTEMS 193

The analytical expression for the Ising model in two dimensions was obtained in 1944 by the Norwegian chemist Lars Onsager (Nobel prize in chemistry) The exact partition function forN

spins is given by

Z

N

=



J)e I



N

with

I = 1

2

Z



0 dln



1

2

1 + (1 

2

sin 2

) 1=2





and

 = 2sinh(2 J

2

Exercise 11.3

Calculate the heat capacity and the mean magnetization per spin for the2  2ising

model

11.1.2 The Metropolis algorithm

The algorithm of choice for solving the Ising model is the approach proposed by Metropolis et

al in 1953 As discussed in chapter ??, new configurations are generated from a previous one

using a transition probability which depends on the energy difference between the initial and final states

In our case we have as the Monte Carlo sampling function the probability for finding the system in a statesgiven by

P

s

= e ( Es

Z

;

with energyE

s, = 1=kT andZis a normalization constant which defines the partition function

in the canonical ensemble As discussed above

Z ( ) =

X

s e ( E

s

is difficult to compute since we need all states In a calculation of the Ising model in two di-mensions, the number of configurations is given by2

N

with N = L  L the number of spins for a lattice of length L Fortunately, the Metropolis algorithm considers only ratios between probabilities and we do not need to compute the partition function at all The algorithm goes as follows

1 Establish an initial state with energyE

bby positioning yourself at a random position in the lattice

2 Change the initial configuration by flipping e.g., one spin only Compute the energy of this trial stateE

t

3 CalculateE = E

t E

b The number of valuesEis limited to five for the Ising model

in two dimensions, see the discussion below

Trang 6

4 IfE  0we accept the new configuration, meaning that the energy is lowered and we are hopefully moving towards the energy minimum at a given temperature Go to step 7

5 IfE > 0, calculatew = e

( E)

6 Comparewwith a random numberr If

r  w;

then accept the new configuration, else we keep the old configuration

7 The next step is to update various expectations values

8 The steps (2)-(7) are then repeated in order to obtain a sufficently good representation of states

9 Each time you sweep through the lattice, i.e., when you have summed over all spins, con-stitutes what is called a Monte Carlo cyclus You could think of one such cyclus as a measurement At the end, you should divide the various expectation values with the total number of cycles You can choose whether you wish to divide by the number of spins or not If you divide with the number of spins as well, your result for e.g., the energy is now the energy per spin

The implementation of this algorithm is given in the next section In the calculation of the energy difference from one spin configuration to the other, we will limit the change to the flipping

of one spin only For the Ising model in two dimensions it means that there will only be a limited set of values for E Actually, there are only five possible values To see this, select first a random spin position x; y and assume that this spin and its nearest neighbors are all pointing

up The energy for this configuration isE = 4J Now we flip this spin as shown below The energy of the new configuration isE = 4J, yieldingE = 8J

E = 4J

"

" " "

"

= ) E = 4J

"

" # "

"

The four other possibilities are as follows

E = 2J

"

# " "

"

= ) E = 2J

"

# # "

"

withE = 4J,

E = 0

"

# " " = ) E = 0

"

# # "

Trang 7

11.2 PROGRAM EXAMPLE 195

withE = 0,

E = 2J

#

# " "

#

#

# # "

#

E = 4J

#

# " #

#

#

# # #

#

withE = 8J This means in turn that we could construct an array which contains all values

ofe

E

before doing the Metropolis sampling Else, we would have to evaluate the exponential

at each Monte Carlo sampling

11.2 Program example

We list here an example of a C/C++-program which computes various thermodynamical prop-erties of the Ising model in two dimensions You should especially pay attention to the function Metropolis which implements the algorithm described in the previous subsection and the func-tionDeltaE which calculates the energy difference between the previous state and the trial state

by flipping one spin

The program is set up with dynamic memory allocation for the matrix which contains the spin values at a position(x; y) One could alternatively have used a fixed size for the matrices to

be used But then one would need to recompile the program when larger systems are considered

11.2.1 Program for the two-dimensional Ising Model

programs/chap11/program1.cpp

/

Program t o s o l v e t h e two d i m e n s i o n a l I s i n g m odel

The c o u p l i n g c o n s t a n t J = 1

B o l t z m a n n ’ s c o n s t a n t = 1 , t e m p e r a t u r e h a s t h u s d i m e n s i o n e n e r g y

M e t r o p o l i s s a m p l i n g i s u s e d P e r i o d i c b o u n d a r y c o n d i t i o n s

/

# i n c l u d e < i o s t r e a m >

# i n c l u d e < f s t r e a m >

# i n c l u d e < i o m a n i p >

# i n c l u d e " l i h "

u s i n g namespace s t d ;

Trang 8

o f s t r e a m o f i l e ;

/ / i n l i n e f u n c t i o n f o r p e r i o d i c b o u n d a r y c o n d i t i o n s

i n l i n e i n t p e r i o d i c (i n t i , i n t l i m i t , i n t add ) {

r e t u r n ( i + l i m i t + add ) % ( l i m i t ) ;

}

/ / F u n c t i o n t o r e a d i n d a t a f r o m s c r e e n

v o i d r e a d _ i n p u t (i n t& , i n t& , d o u b l e& , d o u b l e& , d o u b l e&) ;

/ / F u n c t i o n t o i n i t i a l i s e e n e r g y and m a g n e t i z a t i o n

v o i d i n i t i a l i z e (i n t , d ou b le , i n t   , d o u b l e& , d o u b l e&) ;

/ / The m e t r o p o l i s a l g o r i t h m

v o i d M e t r o p o l i s (i n t , l o n g& , i n t   , d o u b l e& , d o u b l e& , d o u b l e ) ;

/ / p r i n t s t o f i l e t h e r e s u l t s o f t h e c a l c u l a t i o n s

v o i d o u t p u t (i n t , i n t , d ou b le , d o u b l e ) ;

i n t main (i n t a r g c , ch ar a r g v [ ] )

{

ch ar o u t f i l e n a m e ;

l o n g idum ;

i n t  s p i n _ m a t r i x , n _ s p i n s , mcs ;

d o u b l e w [ 1 7 ] , a v e r a g e [ 5 ] , i n i t i a l _ t e m p , f i n a l _ t e m p , E , M, t e m p _ s t e p ;

/ / Read i n o u t p u t f i l e , a b o r t i f t h e r e a r e t o o f e w command l i n e

a r g u m e n t s

i f ( a r g c < = 1 ) {

c o u t < < " B d U s g : " < < a r g v [ 0 ] < <

" r a a s o t u t f l o n s a e l i e " < < e n d l ;

e x i t ( 1 ) ;

}

e l s e{

o u t f i l e n a m e = a r g v [ 1 ] ;

}

o f i l e open ( o u t f i l e n a m e ) ;

/ / Read i n i n i t i a l v a l u e s s u c h a s s i z e o f l a t t i c e , tem p and

c y c l e s

r e a d _ i n p u t ( n _ s p i n s , mcs , i n i t i a l _ t e m p , f i n a l _ t e m p , t e m p _ s t e p ) ;

s p i n _ m a t r i x = (i n t ) m a t r i x ( n _ s p i n s , n _ s p i n s , s i z e o f(i n t) ) ;

idum = 1 ; / / random s t a r t i n g p o i n t

f o r ( d o u b l e temp = i n i t i a l _ t e m p ; temp < = f i n a l _ t e m p ; temp +=

t e m p _ s t e p ) {

/ / i n i t i a l i s e e n e r g y and m a g n e t i z a t i o n

E = M = 0 ;

/ / s e t u p a r r a y f o r p o s s i b l e e n e r g y c h a n g e s

f o r ( i n t de = 8 ; de < = 8 ; de ++) w[ de ] = 0 ;

f o r ( i n t de = 8 ; de < = 8 ; de +=4) w[ de + 8 ] = exp ( de / temp ) ;

Trang 9

11.2 PROGRAM EXAMPLE 197

/ / i n i t i a l i s e a r r a y f o r e x p e c t a t i o n v a l u e s

f o r ( i n t i = 0 ; i < 5 ; i ++) a v e r a g e [ i ] = 0 ;

i n i t i a l i z e ( n _ s p i n s , temp , s p i n _ m a t r i x , E , M) ;

/ / s t a r t Monte C a r l o c o m p u t a t i o n

f o r ( i n t c y c l e s = 1 ; c y c l e s < = mcs ; c y c l e s ++) {

M e t r o p o l i s ( n _ s p i n s , idum , s p i n _ m a t r i x , E , M, w) ;

/ / u p d a t e e x p e c t a t i o n v a l u e s

a v e r a g e [ 0 ] + = E ; a v e r a g e [ 1 ] + = EE ;

a v e r a g e [ 2 ] + = M; a v e r a g e [ 3 ] + = MM; a v e r a g e [ 4 ] + = f a b s (M) ; }

/ / p r i n t r e s u l t s

o u t p u t ( n _ s p i n s , mcs , temp , a v e r a g e ) ;

}

f r e e _ m a t r i x ( (v o i d  ) s p i n _ m a t r i x ) ; / / f r e e memory

o f i l e c l o s e ( ) ; / / c l o s e o u t p u t f i l e

r e t u r n 0 ;

}

/ / r e a d i n i n p u t d a t a

v o i d r e a d _ i n p u t (i n t& n _ s p i n s , i n t& mcs , d o u b l e& i n i t i a l _ t e m p ,

d o u b l e& f i n a l _ t e m p , d o u b l e& t e m p _ s t e p ) {

c o u t < < " N u b r o M o t e C a l t r a s = ";

c i n > > mcs ;

c o u t < < " L a t i e s z o n u b r o s p i s ( x a d y e u l ) = ";

c i n > > n _ s p i n s ;

c o u t < < " I n i i a l t m p e a t r e w i t d m e s i o e e g y = ";

c i n > > i n i t i a l _ t e m p ;

c o u t < < " F i a t e m e r t u r w t d i e n s o n e n r y = ;

c i n > > f i n a l _ t e m p ;

c o u t < < " T e m e r a u r s t p w t h d i m n s i n e n r g = ";

c i n > > t e m p _ s t e p ;

} / / end o f f u n c t i o n r e a d _ i n p u t

/ / f u n c t i o n t o i n i t i a l i s e e n e r g y , s p i n m a t r i x and m a g n e t i z a t i o n

v o i d i n i t i a l i z e (i n t n _ s p i n s , d o u b l e temp , i n t  s p i n _ m a t r i x ,

d o u b l e& E , d o u b l e& M) {

/ / s e t u p s p i n m a t r i x and i n t i a l m a g n e t i z a t i o n

f o r(i n t y = 0 ; y < n _ s p i n s ; y ++) {

f o r ( i n t x = 0 ; x < n _ s p i n s ; x ++) {

s p i n _ m a t r i x [ y ] [ x ] = 1 ; / / s p i n o r i e n t a t i o n f o r t h e g r o u n d s t a t e

M + = (d o u b l e) s p i n _ m a t r i x [ y ] [ x ] ;

}

}

Trang 10

/ / s e t u p i n i t i a l e n e r g y

f o r(i n t y = 0 ; y < n _ s p i n s ; y ++) {

f o r ( i n t x = 0 ; x < n _ s p i n s ; x ++) {

E = (d o u b l e) s p i n _ m a t r i x [ y ] [ x ]

( s p i n _ m a t r i x [ p e r i o d i c ( y , n _ s p i n s , 1) ] [ x ] +

s p i n _ m a t r i x [ y ] [ p e r i o d i c ( x , n _ s p i n s , 1) ] ) ;

}

}

}/ / end f u n c t i o n i n i t i a l i s e

v o i d M e t r o p o l i s ( i n t n _ s p i n s , l o n g& idum , i n t  s p i n _ m a t r i x , d o u b l e& E , d o u b l e&M, d o u b l e w)

{

/ / l o o p o v e r a l l s p i n s

f o r(i n t y = 0 ; y < n _ s p i n s ; y ++) {

f o r ( i n t x = 0 ; x < n _ s p i n s ; x ++) {

i n t i x = ( i n t) ( r a n 1 (& idum )(d o u b l e) n _ s p i n s ) ;

i n t i y = ( i n t) ( r a n 1 (& idum )(d o u b l e) n _ s p i n s ) ;

i n t d e l t a E = 2s p i n _ m a t r i x [ i y ] [ i x ]

( s p i n _ m a t r i x [ i y ] [ p e r i o d i c ( i x , n _ s p i n s , 1) ] +

s p i n _ m a t r i x [ p e r i o d i c ( i y , n _ s p i n s , 1) ] [ i x ] +

s p i n _ m a t r i x [ i y ] [ p e r i o d i c ( i x , n _ s p i n s , 1 ) ] +

s p i n _ m a t r i x [ p e r i o d i c ( i y , n _ s p i n s , 1 ) ] [ i x ] ) ;

i f ( r a n 1 (& idum ) < = w[ d e l t a E + 8 ] ) {

s p i n _ m a t r i x [ i y ] [ i x ] = 1 ; / / f l i p one s p i n and a c c e p t new

s p i n c o n f i g

M + = (d o u b l e) 2s p i n _ m a t r i x [ i y ] [ i x ] ;

E + = (d o u b l e) d e l t a E ;

}

}

}

} / / end o f M e t r o p o l i s s a m p l i n g o v e r s p i n s

v o i d o u t p u t (i n t n _ s p i n s , i n t mcs , d o u b l e temp , d o u b l e a v e r a g e )

{

d o u b l e norm = 1 / ( (d o u b l e) ( mcs ) ) ; / / d i v i d e d by t o t a l number o f

c y c l e s

d o u b l e E a v e r a g e = a v e r a g e [ 0 ]norm ;

d o u b l e E 2 a v e r a g e = a v e r a g e [ 1 ]norm ;

d o u b l e Maverage = a v e r a g e [ 2 ]norm ;

d o u b l e M2average = a v e r a g e [ 3 ]norm ;

d o u b l e M a b s a v e r a g e = a v e r a g e [ 4 ]norm ;

/ / a l l e x p e c t a t i o n v a l u e s a r e p e r s p i n , d i v i d e by 1 / n _ s p i n s / n _ s p i n s

d o u b l e E v a r i a n c e = ( E 2 a v e r a g e E a v e r a g eE a v e r a g e ) / n _ s p i n s / n _ s p i n s ;

d o u b l e M v a r i a n c e = ( M2average M a b s a v e r a g e M a b s a v e r a g e ) / n _ s p i n s /

...

For our two-dimensional2  2< /small>lattice we obtain the following partition function

Z = 2e

8J

+ 2e 8J

and...

2< /small>

sin 2< /small>

) 1 =2< /small>





and

 = 2sinh (2 J

2< /small>... one-dimension, we see immediately that the above expression for the partition function is correct Using the definition of the partition function we have

Z

2< /small>

Ngày đăng: 07/08/2014, 12:22

TỪ KHÓA LIÊN QUAN