Problem in a simulation with Python

  • Python
  • Thread starter Berti
  • Start date
  • #1
2
3

Summary:

I wanted to simulate the Ising model and it was okay until I wanted to get the fluctuations <M^2>.
In fact, first, I wanted to obtain the magnetization M :
$$ M = \sum_i \sigma ^ z_i $$
and it worked, I got indeed the magnetization M. However I don't succeed unfortunately to obtain the fluctuations <M^2>.

Main Question or Discussion Point

I wanted to simulate the Ising model and it was okay until I wanted to get the fluctuations <M^2>.
In fact, first, I wanted to obtain the magnetization M :

$$ M = \sum_i \sigma ^ z_i $$​

and it worked, I got indeed the magnetization M by writing these lines :

sigmaxop = []
sites = []
for i in range (L):
# \ sum_i sigma ^ z (i)
sigmaxop.append ((sigmaz) .ToList ())
sites.append ()

with L being the length of the lattice (ie the number of spins).

However I would like now to obtain the average fluctuations :


$$ \langle M^2\rangle = \sum_ {i, j} \langle\sigma_i \sigma_j\rangle $$​


To obtain this average fluctuation, I try to modify the part of the code above (that allowed me to obtain M) to get the fluctuations <M^2> but I didn't succeed : I don't obtain <M^2>.

A priori for every lattice
$$m_j=\sum_k \sigma_k$$
and the average of magnetization is
$$<M>=\sum_j m_j$$
So
$$<M^2>=\sum_j m^2_j$$

Unfortunately after trying again I am still stuck with my code. It doesn't work.

Could someone help me to modify/rewrite this part of code to obtain the fluctuations <M^2>, please?
 

Answers and Replies

  • #2
phyzguy
Science Advisor
4,572
1,518
You need to post your actual code so we can see it. Enclose it with Code tags (the </> icon above, then choose python as the language - like below).

Python:
import numpy as np
 
  • #3
2
3
You need to post your actual code so we can see it. Enclose it with Code tags (the </> icon above, then choose python as the language - like below).

Python:
import numpy as np
Sorry. The part of the code for the magnetization M is :

Code:
sigmaxop = []
sites = []
for i in range (L):
     # \ sum_i sigma ^ z (i)
     sigmaxop.append ((sigmaz) .ToList ())
     sites.append ()
And now I'd like to get the fluctuations <M^2> . So I tried to modify this part of the code to get <M^2> but I am unsuccessful ...
 
  • #4
phyzguy
Science Advisor
4,572
1,518
Sorry. The part of the code for the magnetization M is :

Code:
sigmaxop = []
sites = []
for i in range (L):
     # \ sum_i sigma ^ z (i)
     sigmaxop.append ((sigmaz) .ToList ())
     sites.append ()
And now I'd like to get the fluctuations <M^2> . So I tried to modify this part of the code to get <M^2> but I am unsuccessful ...
How can we possibly comment without seeing the part of the code that isn't working?
 

Related Threads on Problem in a simulation with Python

  • Last Post
Replies
4
Views
9K
Replies
5
Views
5K
Replies
4
Views
3K
Replies
2
Views
8K
  • Last Post
Replies
11
Views
748
Replies
6
Views
482
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
10
Views
9K
Replies
6
Views
851
  • Last Post
Replies
8
Views
6K
Top