Monte Carlo Simulation, Ising model in 2D

In summary: Metropolis algorithm and calculating the energy and magnetization at each step. Then, I plotted the average energy squared and average energy against temperature. This resulted in a graph similar to the desired one, but without the magnetization included.In summary, the conversation discusses the process of retrieving specific heat capacity from an MC simulation using the Metropolis algorithm. The desired output is a graph similar to the given example, but without magnetization. The individual sharing their experience mentions their code and the steps they took, but is still struggling to get a reasonable graph. They seek advice from someone who has experience with this type of simulation.
  • #1
Firben
145
0

Homework Statement


Lo,Im stuck on how to retrieve the specific heat capacity from an MC simulation, with the metropolis algorithm. I want my graph to look something like this:
https://i.stack.imgur.com/NXeXs.png

Homework Equations


C_v = ((<E^2>-<E>^2)/T^2

The Attempt at a Solution



My code is similar to this guy:

but without magnetization

To retrieve C_v i wrote the following code to 4:19 from the video above.

Cv = (E2/16384 - E.*E/16384^2)./(T(i).^2);

plot(T,Cv);Where E2 is given by the code:

function [E2] = ising_energy(u,J)

[L1,L2] = size(u);
E2=0;
for i=1:L1
for j=1:L2
f1i=mod(i,L1)+1;
f2j=mod(j,L2)+1;
forward_neighbors=u(f1i,j)+u(i,f2j);
E2=E2-(J*u(i,j)*forward_neighbors)*(J*u(i,j)*forward_neighbors);


end;clear j
end;clear i

However my graph looks more like the plot of <E> vs T.
 

Attachments

  • EVsT.jpg
    EVsT.jpg
    10.5 KB · Views: 404
  • CvVsT.jpg
    CvVsT.jpg
    8.9 KB · Views: 425
Physics news on Phys.org
  • #2
No, I am still stuck atm. Cant get any reasonable graph. Is there someone that have done this type of simulation before ?
 
  • #3
Someone that knows what iam missing ?
 
  • #4
Firben said:
Someone that knows what iam missing ?
where is your code?
 
  • #5
MohammadJCM said:
where is your code?
I solved it
 

1. What is Monte Carlo simulation?

Monte Carlo simulation is a computational technique that uses random sampling to model and analyze complex systems or processes. It is commonly used in various scientific fields, including physics, chemistry, and finance.

2. What is the Ising model in 2D?

The Ising model in 2D is a mathematical model used to study the behavior of interacting particles, such as atoms or spins, on a two-dimensional lattice. It is widely used in statistical mechanics to understand phase transitions and critical phenomena.

3. How does Monte Carlo simulation help in understanding the Ising model in 2D?

Monte Carlo simulation allows researchers to numerically simulate the behavior of the Ising model in 2D by randomly sampling the states of the particles on the lattice. This helps in understanding the statistical properties and phase transitions of the model.

4. What are the applications of Monte Carlo simulation in the Ising model in 2D?

Monte Carlo simulation has various applications in the Ising model in 2D, such as studying the behavior of magnetic materials, analyzing complex systems in statistical physics, and predicting critical properties of phase transitions.

5. What are the limitations of Monte Carlo simulation in the Ising model in 2D?

One limitation of Monte Carlo simulation in the Ising model in 2D is that it can be computationally intensive and time-consuming, especially for large lattices. Additionally, the accuracy of the results depends on the number of Monte Carlo steps and the chosen sampling method.

Similar threads

  • Programming and Computer Science
Replies
4
Views
1K
Replies
0
Views
2K
  • Advanced Physics Homework Help
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
11
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
9
Views
2K
Replies
6
Views
2K
  • Advanced Physics Homework Help
Replies
2
Views
2K
  • Atomic and Condensed Matter
Replies
3
Views
844
  • Advanced Physics Homework Help
Replies
3
Views
2K
Back
Top