-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Bradley Lucier wrote:
The purpose of the code may be obvious to you, but I can't tell what you want to do (even knowing roughly what the Ising model is, and after looking at the wikipedia page you pointed to).
Some advice:
- If you're going to use something again and again, don't recompute
it, compute it once and save it. It appears that helical-neighbors is computed over and over again. In accept-flip you compute (energy-jump/J grid site) twice if it turns out to be positive. You can use (time ...) to get information about how much stuff is consed, etc.
- If you can avoid arithmetic between exact (integer, rational)
numbers and inexact (floating-point) numbers, do so. And if you know that computations or comparisons are between fixnums, use the fixnum operations fx+, fx<, ...; if you know that certain operations apply only to flonums use fl+, ...
- If you've done the things above, then declaring
(standard-bindings)(extended-bindings)(block)(not safe) will help (but not before doing those things).
- If you've done all *those* things, then don't use -O2 (the options
that Gambit chooses at configuration time are almost always faster, especially for gcc) and if "-march=native" helps, then use it at configuration time.
Brad
Hi Brad,
thanks for looking my program over. I'll think about how to apply your advice.
Meanwhile, since I think you implied that you'd be interested in the following: The program simulates a bunch of tiny magnets that are restricted to point in one direction; either up or down. The energy function makes it favorable for them to all point in the same direction. This situation is called ferromagnetic and is an explanation of why a piece of iron can be permanently magnetized. If the spins have more kinetic energy, that is at higher temperatures, then due to the larger thermal energy fluctuations it is more likely that spins point in either direction rather than all in the same direction. That is, if you raise the temperature of a ferromagnet, the permanent magnetic field will disappear. There is a so-called critical temperature at which a transition between these two phases takes place. The program simulates the temperature-dependent energy fluctuations that cause spin flips in the array of spins and thus allows me to measure the average magnetisation at a certain temperature. However the simulation needs to be running long enough such that the sample can be assumed to be in equilibrium before any measurements can be done. There are situations where this can take a long time. For example if you start with a checker-board formation and simulate zero temperature, the sample will end up in either the all-down configuration or in the all-up configuration. Different parts of the sample might make different decisions on which it should be on the road to get to the final configuration. Only spins on the interfaces between differently magnetized areas are really available for spin flips due to the high energy increase for in-area spin flips and the low temperature. Anyway, I hope I haven't gone overboard on details, but that nonetheless it is now more clear what the program should do.
Marijn
- -- Sarcasm puts the iron in irony, cynicism the steel.
Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML http://www.gentoo.org/proj/en/lisp/, #gentoo-{lisp,ml} on FreeNode