Weird fluctuations in Ising model

In summary, the programmer is having trouble understanding the chaotic behavior of their 2D Ising model. They are trying to find an error in their code, but they do not know where it is.
  • #1
mastrofoffi
51
12
Not 100% sure this thread belongs in this section, sorry if it's out of place.

I was trying to run a simulation of a 2D Ising model; i thought everything was going fine until I started to look at the numerical results and I noticed that I get some wild fluctuations in my results; as an example, here are the values i get for final energy and magnetization (per site) after 10 different 10000-step runs on a 128x128 lattice at temperature T = 0.1 K(critical temperature is at 2.27 K), where the initial spin configuration is chosen randomly(+1 or -1 is assigned to each node with equal probability):
$$ (E, |M|) = (-2, 1); (-1.95, 0.52); (-2, 1); (-1.95, 0.21); (-2, 1); (-1.95, 0.02); (-2, 1); (-1.95; 0.24); (-2, 1); (-2; 1) $$
With a temperature so low I would expect all [itex]|M|[/itex] to be exactly 1, or at least that fluctuations like these would be way less probable than 4/10, so I guess there must be some error in my code. Am I wrong in thinking this?
I would be very grateful if someone could take a look at my code and maybe point out where the error is, cause it seems like I can't find it.

Here is the function used to update the lattice(it's Metropolis algorithm):
Code:
void update(graph *pLattice, int *s, double *prob, int *pE, int *pM){
  /* pLattice is the pointer to the graph/lattice; s is the pointer
   * to the array containing the spin value for each site; prob is the pointer to
   * the lookup table used to map differences in energy to their probability according
   * to Boltzmann distribution; pE and pM point respectively to the energy and 
   * magnetization values of the lattice. */
  int k, site, *pNeigh, siteConn, sum;
  for(site = 0; site < pLattice->numNodes; site++){ // loop over all nodes
    pNeigh = pLattice->neigh[site]; // = neigh[site][0]
    siteConn = pLattice->conn[site]; // = 4
    sum = 0;
    for(k = 0; k < siteConn; k++, pNeigh++){
      sum += s[*pNeigh];  // = s[neigh[site][k]]
    }
    sum *= s[site]; // this is now the energy of site
    if(sum <= 0 || drand48() < prob[sum]){
      /* this is legit because sum = half the variation of energy due to the flip of s[site]
       * and 0 < prob[sum] = exp(-2.0 * sum / T) < 1; (T=temperature) */
      s[site] = -s[site];
      *pE += 2*sum;
      *pM += 2*s[site];
    }
  }
  return;
}
"graph" is basically an adjacency list, defined as
Code:
typedef struct {
  /* conn points to an array of size numNodes, whose items are the number of
   * connections of each node(i'm using periodic bc so conn[i] = 4 for every value of i).
   * neigh points to a 2d array of dimensions numNodes*numLinks,
   * where the neighbours of each node are stored. */
  int numNodes, numLinks, *conn, **neigh;
} graph;
The main function, besides declaration of variables and error checking, is basically just
Code:
  E = energy(pLattice, s);
  M = magnetization(pLattice, s);
  for(i=0;i<R;i++){
    update(pLattice, s, probLUT, &E, &M);    
  }
  fprintf(stderr, "E = %f; M = %f\n", (double)E/N, (double)M/N);
where N is the number of nodes.

The difference in energy value between "correct" and "weird" runs is small, so when I average over lot of runs for each T, and for many values of T, the plot EvsT
looks not too different from the expected curve; the plot of |M|vsT still shows the correct behaviour, but instead of getting constant |M|=1 for [itex]T<T_c[/itex] i get values oscillating around |M|=0.8. I tried running for different times, different lattice size, different initial conditions, with no different results.
I'll post full code, graphs or whatever if needed. Thanks.
 
Technology news on Phys.org
  • #2
Updating just in case anyone happens to come by and help me out. I created some animated plots for the 'weird' results and I found that they correspond to situations where two connected clusters(one for each spin) arise and reach some sort of equilibrium configuration where they are just translated (always) in the [itex]-x[/itex] direction through the periodic boundary. Here a few pics of a 64x64 lattice taken at times 850,851,852,856:
ising850.png
ising851.png

ising852.png
ising856.png

Basically it evolves for some time, then stabilizes on a configuration like this which is mantained for the rest of the simulation. This makes no sense at all to me: why would something like this happen? and how? I also tried rewriting the program all over, without looking at the original one, but I get the exact same thing. I guess this must be related to the periodic boundaries, so I'll try to implement free boundaries and see what happens.
 

Attachments

  • ising850.png
    ising850.png
    9.3 KB · Views: 338
  • ising851.png
    ising851.png
    8.8 KB · Views: 313
  • ising852.png
    ising852.png
    11.7 KB · Views: 329
  • ising856.png
    ising856.png
    9.9 KB · Views: 373

What is the Ising model?

The Ising model is a mathematical model used in statistical mechanics to study the behavior of systems consisting of interacting particles, such as atoms or spins. It was first proposed by physicist Ernst Ising in 1925. The model is often used to understand and predict phase transitions in materials, such as magnetism and ferroelectricity.

What are "weird fluctuations" in the Ising model?

"Weird fluctuations" in the Ising model refer to unexpected or unusual changes in the behavior of the system. This could include sudden changes in the magnetization or energy of the system, or the emergence of unusual patterns or structures. These fluctuations can provide insight into the behavior of the system and can be used to study the effects of different parameters on the system.

What causes these fluctuations in the Ising model?

Fluctuations in the Ising model are caused by the random interactions between particles in the system. The model assumes that each particle has a spin, which can be either up or down, and that these spins interact with each other according to a set of rules. As the system evolves over time, the interactions between particles can lead to fluctuations in the behavior of the system.

How are "weird fluctuations" studied in the Ising model?

In order to study "weird fluctuations" in the Ising model, scientists use computer simulations or mathematical calculations to model the behavior of the system. By varying different parameters, such as temperature or strength of interactions, scientists can observe and analyze the fluctuations that occur. These studies can provide valuable insights into the behavior of the system and can help improve our understanding of phase transitions in materials.

What are the potential applications of studying "weird fluctuations" in the Ising model?

Understanding "weird fluctuations" in the Ising model can have a wide range of applications. For example, it can help us better understand the behavior of materials, such as magnets and alloys, and how they undergo phase transitions. This knowledge can then be applied to develop new materials with specific properties. Additionally, the Ising model has also been used in other fields, such as biology and economics, to study complex systems and phenomena.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
Replies
1
Views
1K
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
1
Views
754
  • Programming and Computer Science
Replies
6
Views
5K
  • Advanced Physics Homework Help
Replies
0
Views
244
Replies
2
Views
632
  • Programming and Computer Science
Replies
2
Views
1K
  • Quantum Physics
Replies
10
Views
641
  • Programming and Computer Science
Replies
2
Views
2K
Back
Top