Mar 15

Raspberry Pi Cluster

One thing I miss about previous employments is the ability to write parallel code on HPC systems.  Whether itpiCluster involved diagonalizing large matrices to find atomic or molecular ground state energies or modeling the country of Thailand in order to understand disease transmission, I found that writing parallel code reinforced a way of thinking that you just don’t get with serial applications.  While my current job is interesting in the vast amount of projects and applications I am involved with, the entirety of the work is done on conventional workstations and laptops.  This is fine, as most of the results can be calculated in minutes (and don’t require parallelization), but I still miss working with the technology.

In order to accommodate this desire, and attempt to stay at least semi-sharp in the field of parallel computing, I decided to build a cluster at home using Raspberry Pi.  For anyone who has been living under a rock the last few years, a Raspberry Pi is a credit card sized computer.  With a CPU comparable to a cellphone’s, a gigabyte of RAM, onboard graphics, ethernet, USB, and HDMI, these computers have a vast array of potential applications.  Since they debuted in early 2012, several iterations have been released with varying specs (the newest being the Raspberry Pi 2).

The cluster I built uses four Raspberry Pi B+.  They are connected via an ethernet switch.  Power is provided by a powered USB hub.  The MPI implementation used is MPICH.

A set of instructions for building the cluster can be found here, where a professor at The University of Southampton built a cluster using 64 Raspberry Pi computers.  As mentioned above, I only used four.  The reason I decided to stop there was primarily cost as well as the fact that writing parallel code with four nodes is fundamentally the same as writing code for 64 or more.piClusterHookedUp

Since “Supercomputer” seems to be a buzzword these days (hasn’t it always?), I think it need to be mentioned that this is not going to get you any sort of computing power surpassing that available to you even in a modern conventional desktop workstation.  Furthermore, there are bottlenecks in Raspberry Pi cluster that don’t exist (or are greatly mitigated) in real (and expensive) supercomputers.  As mentioned above, I built this thing in order to test out parallel codes — not because I think I’m going to be solving any particular problem faster than on any other hardware currently available to me.

Going forward, the first step will be to benchmark the cluster.  Then I will develop some test codes.  if I can think up any interesting problems to solve after that, I will certainly make an update to Evil Quark.  Perhaps generate Pi to many digits or generate prime numbers… or calculate the ground state energy of the helium atom using different basis sets.  Who knows?  Stay tuned.

Feb 13

Going to School

As an occasional scuba diver, it has been a privilege to see on more than one occasion the majesty that is a school of fish up close. I’ve often wondered what (if anything) is going through any particular fish’s mind as it effortlessly maintains its position in the school. It’s easy to see why some have begun to study entire herds, flocks, swarms, or schools as a singular complex organism.


About a year ago, using a few basic rules…

  1. Separation – avoid crowding neighbors (short range repulsion)
  2. Alignment – steer towards average heading of neighbors.
  3. Cohesion – steer towards average position of neighbors (long range attraction)

… I developed a simple schooling algorithm using Processing 2.1.1 in order to model this phenomenon.  In the model, there are predatory sharks (blue circles) and a food source (red dot).

I was surprised at how sensitive the schooling behavior was to the strength of the forces associated with the three rules above.  Certain combinations of varying reliance on separation, alignment, and cohesion meant that the behavior ranged from fish that wouldn’t school at all, to scenarios where several small schools would form from the initial.  In fact, getting the parameters just right (from my perspective anyways) to model realistic schooling behavior was non-trivial.  Perhaps this supports the notion that real life schools of fish are actually very complex systems that have been optimized by evolution over the course of millions of years.


Flocking Behavior Rules: Wikipedia

Modeling Knowledge: Nature of Code

Feb 09

Introduction and Synthesized Sound

After several iterations, Evil Quark is back!  This website exists only to collect my thoughts and reflect on my various interests.  If by some miracle of internet search you find yourself roaming these pages, I sincerely apologize for the random and hectic presentation of what you might find.  If you need clarification, have any questions, or just want to say ‘hi’, feel free to contact me!

The first project I’d like to memorialize is the building of a rudimentary synthesizer.  The tutorial that I followed can be found here: 

Overall, this project was pretty awesome.  Years ago I used to make electronic music (mostly detroit and swedish style techno) so being able to create a synthesizer from scratch was both an interesting and personal project for me.   The end product was a square-wave oscillator (made from a Schmitt trigger) with an LFO.  Here’s a picture of the final circuit:

Square wave osc with LFO

Square wave oscillator with LFO

I want to have a better understanding of how the MOSFET transistor as well as the Schmitt trigger actually work (from a physics standpoint), and perhaps I’ll research this and make some informative posts in the future.

If you are wondering what the synthesizer sounds like, check out this video I made which showcases the audio.  Watch out Daft Punk!

Quick note:  The parts list on the hackaday website needs to be updated.  In particular, the Jameco link for the 47k ohm resistor links to a 47 ohm resistor.  I found this out the hard way and now have a bunch of 47 ohm resistors laying around.  If you attempt the project, make sure you get the 47k ohm resistors.  Or, you could just skip ahead and use the potentiometer instead.