Monte Carlo Simulation, Ising model in 2D

Click For Summary
SUMMARY

The discussion focuses on retrieving specific heat capacity (C_v) from a Monte Carlo simulation using the Metropolis algorithm in the context of the Ising model in 2D. The participant attempted to calculate C_v with the formula C_v = ((-^2)/T^2) but encountered issues with the resulting graph resembling vs T instead of the expected C_v vs T. The code provided for calculating energy (E2) was also shared, highlighting the need for adjustments to achieve the desired output.

PREREQUISITES
  • Understanding of Monte Carlo simulations
  • Familiarity with the Metropolis algorithm
  • Knowledge of the Ising model in statistical mechanics
  • Proficiency in MATLAB for numerical simulations
NEXT STEPS
  • Review the implementation of the Metropolis algorithm in Monte Carlo simulations
  • Learn how to correctly calculate specific heat capacity in statistical mechanics
  • Explore MATLAB functions for plotting and data visualization
  • Investigate common pitfalls in Monte Carlo simulations and how to troubleshoot them
USEFUL FOR

Researchers and students in physics, particularly those focusing on statistical mechanics and computational simulations, as well as developers implementing Monte Carlo methods in programming environments like MATLAB.

Firben
Messages
141
Reaction score
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: 464
  • CvVsT.jpg
    CvVsT.jpg
    8.9 KB · Views: 508
Physics news on Phys.org
No, I am still stuck atm. Cant get any reasonable graph. Is there someone that have done this type of simulation before ?
 
Someone that knows what iam missing ?
 
Firben said:
Someone that knows what iam missing ?
where is your code?
 
MohammadJCM said:
where is your code?
I solved it
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
11
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
2K
Replies
1
Views
652