Simulating Diffusion in MATLAB with no Particle Overlap

See the Walkthrough of Source Code for implementation details

If you are a student and don't have MATLAB at home, grab the software off Amazon for $99.

Often for my research I find the need to model systems of diffusing particles. The application can be aggregating nanoparticles, electrodeposition, or even simulations of molecular motors. These simulations are striking to me for their simplicity and ability produce qualitatively accurate results. All of this is done with a few simple (algorithmic) rules leading to a "logical geometric description" of the world. 

Often allowing particles to occupy the same space makes implementation significantly easier. This is bothersome in problems where diffusion is important, especially systems like electrodeposition. So one night when I was on duty in Rodin, I gave coding these steric effects a shot for my favorite on lattice style system. 


Here we allow particles to diffuse on a square lattice starting from a Packed Square. No two particles can occupy the same location at the same time. This video is a simulation of 2D diffusion and the code was implemented in MATLAB. The source code is also available.

You can also have some fun by starting with an arbitrary shape. In this case I start with PENN and let it dissolve. You can easily modify the code to import and arbitrary image.

Want to more about how the code works? Let me know and I will maker a post going through the code in detail. 


Nicholas M Schneider

Nicholas M Schneider is a 2010 graduate from the Kate Gleason College of Engineering who is now a Doctoral Candidate at the University of Pennsylvania. Originally from an obscure town south of Buffalo, New York, he attended the Rochester Institute of Technology where he received concurrent Bachelor of Science and Master of Science degrees. While there he had a number of Co-ops including a six month stay as a Design Engineer at Lockheed Martin and Research positions with Dr. Satish Kandlikar. Nicholas currently works with Dr. Haim H Bau in the field dubbed “in situ electron microscopy of liquid systems” where he studies applications in energy and biological systems. Outside of the lab, Nicholas Schneider is a Graduate Associate in Rodin College House and enjoys running (he ran his second Philly Marathon this past November), cooking, baking, reading, and justifying his coffee addiction by making it a hobby.