Growing crystals in Python

Diffusion-Limited AggregationAs part of my preparation for my PhD, I’ve decided to have a look at other programming languages, partially just out of curiosity, but also partly due to the frustrating length of time it seems to take to get code up and running in Java/C++. Python is often mentioned as suitable scientific programming language so I decided to dive straight in. I’ve only been using it for about a week and already I’ve been very impressed with the speed with which I can get prototypes up and running. Coding in python seems more eloquent, concise, almost like writing pseudo-code at times. The community encourages writing “pythonic” code where the finding simplest, cleanest (and often fastest) method is highly valued.

So to test out the new language I decided to have a go at implementing a basic lattice-based Diffusion-Limited Aggregation model. The basic idea is set off a series of random walkers around a central “seed” – if they come into contact with the seed they stick to it and a new walker is released. The colors in the above diagram show how new that part of the crystal is (hotter – new, colder – old). The code is available over at github; the curious should also have a look at the faster version rewritten in the NumPy numerical library.

Leave a Reply

Your email address will not be published. Required fields are marked *