Nearest Image for Particle Simulations and Molecular Dynamics in MATLAB

Nearest Image for Particle Simulations and Molecular Dynamics in MATLAB

Often when working on particle simulations and Molecular Dynamics you need to find the nearest image of a particle when working with Periodic Boundary Conditions. After working out several implementations in MATLAB, I have come to favor the approach I show here. I will a simple approach with a few assumptions that makes the implementation easier but it can easily be extended. This works great for diffusion or random walk simulations or for your molecular dynamics code and for on lattice or off lattice simulations.

Read More

Easy Periodic Boundary Conditions for Particle Simulations in MATLAB

Easy Periodic Boundary Conditions for Particle Simulations in MATLAB

Often when working on particle simulations you need to employ Periodic Boundary Conditions. After working out several implementations in MATLAB, I have come to favor the approach I show here. I will a simple approach with a few assumptions that makes the implementation easier but it can easily be extended.

Read More

Source Code Walkthrough for Simulating On-Lattice Diffusion in MATLAB with No Particle Overlap

Source Code Walkthrough for Simulating On-Lattice Diffusion in MATLAB with No Particle Overlap

Earlier this year I wrote up a simulation for on-lattice diffusion in MATLAB. Since then, several people have asked me about my implementation. It is very hard to pick up someone else's code, so in this post I will walk through the details of the code line-by-line with some examples of how each section works. I will focus on 2D, but the code could easily be extended to 3D.

Read More

Simulating Diffusion in MATLAB with no Particle Overlap

Simulating Diffusion in MATLAB with no Particle Overlap

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. 

Read More