I'm working on a Magnetization simulation and writing an algorithm using the metropolis method.

I am using a change in energy and a Boltzmann distribution, but, my question is about the trial step. Should the trial position of the magnetization be completely random or should it be a random differential added onto the position of the old magnetization?

My energy basically depends on an angle, so, my range is 0 to Pi, and to get anything near a 50% rejection I'm adding or subtracting approximately pi over 4 from each step - which is far too large. If I reduce it to something reasonably small, then the difference in energy between the old and new energy probability is about 0.999 to 1.001. (here I create a random, small angle and add or subtract it from the current angle of the magnetization vector.)

  • 1
    $\begingroup$ An important question to ask yourself is "Do you want to map the whole space, or to converge on a single answer?" And if you want one (or a small number of) answer(s) you have consider how scared you are of ending in sub-optimal local extrema and if you want any annealing. $\endgroup$ Feb 2, 2016 at 0:58
  • $\begingroup$ My intent is to scale up to a thousand particles and look at average magnetization in different fields. So, since I am primarily interested in the average, I think I want to map the whole space. But I still want something that has meaning, jumping around at these large angles is scary just because I'm not sure I'm getting any good information out of an average. $\endgroup$
    – Joseph
    Feb 2, 2016 at 1:01
  • $\begingroup$ So parameterize the step size and anneal: start large and slowly squeeze it down. Gives you a chance to learn if you've missed a golden spot but still end with a well defined answer. You can also average over multiple walkers to improve the odds of a good overall map. There are lots of variations. $\endgroup$ Feb 2, 2016 at 1:04
  • $\begingroup$ Ok, I guess I've kind of done that - but my understanding is that if the method is to have meaning you should operate in a 30-70% rejection range, and I am working around 10% rejection. $\endgroup$
    – Joseph
    Feb 2, 2016 at 1:07
  • $\begingroup$ i guess my questions are really more about the computational side then the physics side so if you want to migrate it - that would be fine $\endgroup$
    – Joseph
    Feb 2, 2016 at 1:51

1 Answer 1


Well I guess that this question could take place in both computational science and physics, depending on the kind of physicist or computational scientist stubbling upon it.

Yet for your answer, as I saw some solid MC algorithm, I advise you to put your rejection goal (or acceptation) as a constant inside your code and vary your trial size proportionnaly to the actual trial size.

What I mean is that you calculate the rate of rejection $\frac{n_{rejected}}{n_{total}}$, compare it with the goal and update your trial size to, let's say, something like $\pm10\%$ of it $$\delta\theta_{new}=\delta\theta\pm0.1\delta\theta$$

Notice that if the trial size is larger you'll end up with larger $e^{\Delta U}$ meaning more rejection so check the $\pm$ sign wisely depending on the rate of rejection. Also verify that $n_{total}$ is only considered with entries recorded since the last update of $\delta\theta$. This stuff should converge to a solution exploring a useful portion of the phase space and avoiding very low probable region at lower temperatures.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.