Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Ising model: Anti-ferromagnet

  1. Nov 5, 2011 #1
    Hi

    I'm working on a matlab simulation of the 2D Ising model, and would like to verify my code and its results. One thing I'd like to try and observe is the transition from anti-ferromagnet to ferromagnet, but I'm not sure how to create the initial lattice in Matlab. I've already made a (pseudo)random lattice of spins and one that starts as a ferromagnet.

    In other words, how can I create a lattice with alternating elements (1s and -1s)?

    Also, is there a way to plot or graph my matrix as a colour/greyscale grid, so that -1s are black and +1s are black say? Currently I've used a surface plot but have to rotate the 3D image to a plan view.
     
  2. jcsd
  3. Nov 6, 2011 #2
    As an additional point. I'd also like to calculate the thermal average of magnetisation and Energy [itex]<M>,<E>[/itex] as a function of temperature. I'm not quite sure how to do this with a Monte Carlo algorithm, without a partition function. Is the best way to run the alogrithm for different temperatures then average the results for each temperature?
     
  4. Nov 6, 2011 #3

    Pythagorean

    User Avatar
    Gold Member

    If I understand what you're asking for (a checkerboard pattern?)
    Code (Text):

    Y = zeros(m,n) %make a mxn matrix of zeros

    %now make checkerboard 1,-1
    Y(1:2:end,1:2:end) = 1
    Y(2:2:end,1:2:end) = -1
    Y(1:2:end,2:2:end) = -1
    Y(2:2:end,2:2:end) = 1
    try "doc imagesc"
    you can call options to customize the colors, read up on it.
     
  5. Nov 7, 2011 #4
    Thanks for the tip. That did the trick nicely. The simulation is showing the wrong behaviour but the graphs look good:biggrin:

    Does anyone have any tips for debugging a code in matlab, I'm really not seeing my error at the moment.
     
  6. Nov 8, 2011 #5

    Pythagorean

    User Avatar
    Gold Member

    Just follow the input/output chain backwards (pause ad display function can help with this).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Matlab Ising model: Anti-ferromagnet
  1. Modeling and Matlab (Replies: 3)

  2. 3D modelling in MATLAB (Replies: 2)

Loading...