| New Reply |
Heath bad method for Ising model |
Share Thread | Thread Tools |
| Jul9-12, 09:14 AM | #1 |
|
|
Heath bad method for Ising model
I'm trying to simulate a 100x100 Ising model in matlab. So far I've tried the metropolis method (which seems to work), but I'm having problems with the heat bath method. I'm not sure how it's supposed to work (I can't get the spins to all take the same +1 or -1 value even at really low temperatures, while I can easily get them to do that with the metropolis method): am I supposed to change spins based only on the state of its neighbors in the original configuration and am I supposed to choose the spins at random or can I go through them systematically, if it's the latter, am I supposed to repeat the whole process (which would kinda make it just as much work for a computer as the metropolis method)?
Anyway, can somebody tell me how it's supposed to work, roughly? |
| Jul16-12, 09:44 AM | #2 |
|
|
Isn't the "metropolis method" (that I personally refer to as "Metropolis choice" for the fact that it merely means fixing a free parameter to its optimum value) just a special (optimized) case of a "heat bath method"? In that case, your "heat bath method" would just be the same as before; only the probabilities to accept a proposed spin flip would change. I would not go through the spins systematically unless you can formally proof that it gives the correct results. Adding correlations between your Monte Carlo steps is usually not a desirable property of a simulation scheme.
|
| Jul16-12, 12:53 PM | #3 |
|
|
My book "Introduction to Statistical Physics" (Kerson Huang) says 'It can be shown that one step in the heat bath method is equivalent to an infinite number of Metropolis steps.' It and other sources say the heat bath method is supposed to be much faster and only works for systems with a small number of possible spin values (the Ising model only has two: -1 and +1), unlike the Metropolis method. Also, what would be the physical justification that allows for the Metropolis method to be carried out with different sets of probabilities (as with a dice, you'd expect only one set of probabilities to be correct)? So I don't think the two methods are the same except for their probability sets. My book advices me to go through the spins systematically for the Metropolis method (I think that is because the probability of selecting spins 1, 2 and 3 in sequence is the same as that of selecting spins 23, 48 and 71, so why bother with random selection that eats up computing resources?), it doesn't say how I should select spins for the heath bath method, some of my other sources say I should select at random. |
| Jul16-12, 02:45 PM | #4 |
|
|
Heath bad method for Ising model
Hi Gulli. I am not familiar with the "heat bath method". Here's a page I found that mentions and briefly describes is: http://cours-physique.lps.ens.fr/ind...ing_model_2011. I will assume that is what you books also talks about in the following.
According to this, you pick a random (random! see below) spin, and chose its new value according to a probability that depends on its neighbouring spins. Apart from some possible free parameters that is the same as flipping it with a probability that depends on its neighbouring spins and its current value. From what you wrote I have some doubts about the book you are using. The Amazon reviews and the fact that the author is over 80 years of age also support my feeling that the book is not a proper read for an introduction to Monte Carlo computer simulations. If you want to seriously go into Monte Carlo methods then a specialized book (i.e. one assuming you already know thermodynamics and statistical mechanics and only want to read about Monte Carlo methods as they are actually used in research in these fields) I can recommend Newman, Barkema: "Monte Carlo Methods in Statistical Physics" (disclaimer: as I am a 2nd generation "academic sibling" of one of the authors, this opinion is strongly biased by the "the book describes MC exactly the way I use it"-effect). (*) Explaining these points in detail would be beyond the current scope. But I can gladly go into more detail if your are interested (for which it would help to know a bit about your background, though). |
| Jul16-12, 05:10 PM | #5 |
|
|
I just started graduate school (I have a bsc in physics and know thermodynamics, etc...), taking introductory Monte Carlo courses, but no one ever explained the heat bath method to me and I guess my book really threw me of course because the language it uses to (very briefly) describe the heat bath method is very different from online sources. Anyway, I'll try implementing it now and report back what I find. |
| Jul17-12, 01:31 PM | #6 |
|
|
I think I got the heat bath method working now, your replies has been very helpful and I found another mistake in the book (the author switched mixed things up again) that kept me from implementing the heat bath method succesfully. I'll never use that book again: it's the second edition but it still has two deadly mistakes on the four pages that deal with the Ising model.
|
| Aug4-12, 09:45 PM | #7 |
|
|
How about sweeping the lattice for more times?
|
| Aug19-12, 09:16 AM | #8 |
|
|
Well, I've now successfully implemented bith methods (Metropolis seems to be faster, I think because its steps don't always require computing an exponential).
Rather than randomly choosing spins both methods systematically go though all spins in my implementation because drawing random numbers doesn't work with the Metropolis method (because you can't eliminate double counting unless you keep a record of all the spins you've visited previously, which is tedious and time consuming) and for the heat bath method it's just very slow (computer takes too much time drawing random numbers). Both methods are dramatically faster when I use an algorithm (based on the number of spins that are neighboring at least one spin with opposite spin, which is a measure for how big islands of +1 or -1 have become) that occassionally goes through the lattice systematically but only looks at spins that have at least one opposite neighbor (these spins tend to be located on the edge between two islands). When the islands become big enough "occassionally" changes into "always" and the program will only look at the edges between islands because that's where all the action would happen anyway (flipping a spin in the middle of an island would just result in noise since it's very likely to be forced to flip back by its neighbors the next round, so looking at these spins is a waste of time). This is an algorithm by my own design and I think it doesn't change the outcome in any measurable way (since the odds against, a spin in the middle of a big island suddenly flipping and converting the entire island and then changing the outcome for the entire model, are astronomical), but of course there's always a chance I'm wrong. |
| Aug20-12, 10:11 AM | #9 |
|
|
http://www.netlib.org/utk/lsi/pcwLSI/text/node292.html |
| Aug20-12, 10:47 AM | #10 |
|
|
|
| Aug20-12, 04:30 PM | #11 |
|
|
See pages 48-51 here. |
| Aug21-12, 01:42 AM | #12 |
|
|
A few random comments:
1) If you are calculating exponentials in a step of either method then your implementation is inefficient. There are only five possibilities for the total magnetization of the neighbors. Calculate your flip probabilities in advance and store them in a lookup table. 2) The Metropolis algorithm should still be more efficient, since it is, by definition, the most dynamic single spin flip algorithm with randomly chosen spins. Again, that statement may be impacted by the fact that I don't know the Heat Bath method, but from your description it shouldn't beat what you call the Metropolis Method. 3) Ignoring spins inside a large cluster may be faster. But it is wrong. And unless you can control how wrong you go (and verify that the error you introduce does not matter for your purpose) you shouldn't intentionally program something like that (unless you are an experimentalist and merely want "simulation results" to "validate" your experiments - then you can program anything because your referee won't know proper MC simulations, either ). If you want the T=0 state you do not need to program anything - just set all spins up or down and call it a result.4) Consider it theorist nit-picking, but I cannot resist: You won't see a phase transition in a finite system in any case. |
| Aug21-12, 08:51 AM | #13 |
|
|
|
| Aug21-12, 09:22 AM | #14 |
|
|
However, for finite systems you will instead get a "blurry" transition as you call them. E.g. instead of a singular peak of the heat capacity at the critical temperature, you would get only a nonsingular peak for a finite system, but still a clearly visible peak for a 100x100 system. |
| Aug28-12, 05:31 PM | #15 |
|
|
P.S. I passed the course. |
| Aug29-12, 02:12 AM | #16 |
|
|
That's an interesting finding. Perhaps even more interestingly, I found exactly the opposite: a single exp() taking ten times as long as drawing a random number in a simple test (although I am sceptical of my results, too - a factor of ten seems a bit too much).
Here's the code I used: Code:
#include <iostream>
#include <cmath>
#include "MTRand.h"
using namespace std;
const int N=100000000;
mccore::MTRand RND(31);
double randoms() {
double result(0.);
for (int i=0; i<N; ++i)
result += RND();
return result;
}
double expos() {
double result(0.);
double d(-1.e-5);
for (int i=0; i<N; ++i, d*=1.1) {
result += exp(d);
if (d < -10.) d=-1.e-5; // keep d in sensible range, CPU time may explode, otherwise.
}
return result;
}
int main() {
cout<<randoms()<<endl;
// cout<<expos()<<endl;
}
Anyways, nice to hear you passed your course. Most of my comments here were actually targetted at a more advanced audience, say a PhD student starting to work in computer simulations. So don't worry if you found them too picky for your case. |
| New Reply |
| Tags |
| heat bath method, ising model |
| Thread Tools | |
Similar Threads for: Heath bad method for Ising model
|
||||
| Thread | Forum | Replies | ||
| Ising model | Atomic, Solid State, Comp. Physics | 0 | ||
| Ising model on GPU | Science Textbook Discussion | 0 | ||
| about ising model | Atomic, Solid State, Comp. Physics | 12 | ||
| Ising Model | Atomic, Solid State, Comp. Physics | 6 | ||
| 2d ising model, mft | Advanced Physics Homework | 1 | ||