Percolation in fortran

Introduction

I thought I should add another project1 to my GitHub repositories and since I was mainly extending the Quantum Computing Simulator project I decided to implement something very simple, but still very rich, a model that despite being simple is still useful for many physical phenomena and also exhibits a phase transition… that is, something on Percolation theory. Because it is so simple, I spiced things a bit by changing the programming language, using Fortran instead of the usual C++. Why Fortran? Well, because Fortran is still a thing2.

By the way, I added some things to the Quantum Computing project, including a Matrix Product State Simulator and a stabilizer formalism simulator able to execute Clifford gates… maybe I’ll add sometime some blog entries about those, too.

Theory

I don’t intend to describe it here, the Wikipedia page is a good start and also in the GitHub project’s README1 I added a free book that contains much more than I could write here. Here is the book again: Percolation Theory Using Python3. It’s worth noting here that the code uses an algorithm called union-find for clusters identification.

Results

Here are some results for a 2×2 grid compared with the analytical results:

And here are the results for bigger and bigger grids:

Some code

The code on GitHub1 is simple enough, one can look over it there, I don’t think it require much explanation.
I’ve decided that instead I should add here code in javascript that instead of computing statistics, it does something more eye-candy: it displays the clusters, colored.

So, here it is:

It’s not that complex as it might appear, a lot of this code just takes care of displaying the colors in such a way that the clusters are distinguishable for the human eye (a not so trivial thing, that’s why HSV is used).

What the code does

Here is the above code running:

Canvas is not supported by your browser!
0

Note that the ‘probability’ field displays the post hoc computed value out of the actual values, instead of the value for the (pseudo)random number generator, those two values can differ.

Conclusion

Another project is added to the collection… there are over 20 projects on GitHub now, this one being among the simplest ones. I don’t know yet what the next project will be about… I’m open to suggestions, so leave a message if you think of something interesting, computational physics related.


  1. Percolation The project repository on GitHub 
  2. Fortran is still a thing 
  3. Percolation Theory Using Python An open access book from Springer 

Leave a Reply (for privacy concerns, please read the Privacy Policy Page accessible from the top menu)

This site uses Akismet to reduce spam. Learn how your comment data is processed.