Monte Carlo Simulation, Ising model in 2D

AI Thread 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 user is attempting to plot C_v against temperature (T) but is currently only achieving a graph resembling the average energy (<E>) versus T. They provide their code for calculating C_v and the energy function but express frustration over not obtaining the expected results. Ultimately, the user indicates they have resolved their issue, although the specifics of the solution are not detailed. The conversation highlights common challenges in computational physics simulations.
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: 456
  • CvVsT.jpg
    CvVsT.jpg
    8.9 KB · Views: 497
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
 
Thread 'Help with Time-Independent Perturbation Theory "Good" States Proof'
(Disclaimer: this is not a HW question. I am self-studying, and this felt like the type of question I've seen in this forum. If there is somewhere better for me to share this doubt, please let me know and I'll transfer it right away.) I am currently reviewing Chapter 7 of Introduction to QM by Griffiths. I have been stuck for an hour or so trying to understand the last paragraph of this proof (pls check the attached file). It claims that we can express Ψ_{γ}(0) as a linear combination of...
Back
Top