This source code simulates 2D diffusion (e.g. biological membrane components) under periodic boundary conditions in presence of a partially reflective meshgrid (e.g. actin membrane skeleton).
- N particles perform a random walk in 2D
- A meshgrid (repesenting a membrane skeleton) reflects particles, which can only pass with a probability pjump
- 9 Gaussian shaped detection spots are placed on the membrane and simulated fluorescence traces are aquired
- The fluorescence traces are autocorrelated using the multiple tau algorithm, resulting in realistic fluorescence correlation spectroscopy (FCS) curves
The code was used to generate simulations published in a Biophysical Journal publication.
Lateral membrane diffusion modulated by a minimal actin cortex, Heinemann F., Vogel SK, Schwille P., 2013 (https://www.cell.com/biophysj/fulltext/S0006-3495(13)00260-9)
The simulation was optimized for performance using a profiler. It is written in C++ (with a small inline assembly part for a much faster floor computation).
The code should be easy to read (three files with lots of comments). I recommend starting with main(), then looking at CSimulatedDiffusion::start() where the simulation takes place.
- Scientists working on, or interested in FCS and / or diffusion
- Developers looking for example implementations of spatial hashing in C++ (a method for very fast collision detection, see https://conkerjo.wordpress.com/2009/06/13/spatial-hashing-implementation-for-fast-2d-collisions/).
Image: Simulated actin mesh, diffusing particles and 9 confocal detection spots.
- boost (https://www.boost.org/) (tested with the somewhat old: boost 1_48_0)
- cpp-yaml (https://github.com/jbeder/yaml-cpp)
- Tested under Windows 7 and 10 (should in principle also run under Linux)
- Compile the project
- Create file(s) decribing meshgrid (see mesh/1-2 mean82 sd31.txt)
- Create / edit yaml file configuring the simulation
- Open cmd, browse to project folder and run
- Drink some coffee and wait...
- Analyze simulation results written to text files
The yaml file contains repeating blocks of 4 parameters. An example is in the repository. Example block:
voronoimesh: ./mesh/1-2 mean82 sd31.txt
resultfile: ./1-2 mean82 sd31_p001.txt
pjump: 0.01
Tmax: 100
Each block is one simulation and will output one result file. All blocks are computed until the end.
-voronoimesh: A text file with coordinates of the mesh. See example in repository. I used a custom program performing Voronoi tesselation (https://en.wikipedia.org/wiki/Voronoi_diagram), which I can distrubute on request.
-resultfile: Name of output file to write to. Output will be a simple textfile containing the 9 simulated FCS autocorrelation curves and their average.
-p_jump: Probability to cross a mesh fibre.
-Tmax: time in simulated seconds (I recommend 100-300s, with larger values for dense meshes and / or high pjump).
A simulated FCS curve (without mesh; with mesh the curve will move to right and a second component may appear, see paper https://www.cell.com/biophysj/fulltext/S0006-3495(13)00260-9).
CSimulatedDiffusion.cpp contains further physical and simulation parameters, which can be modified, e.g.:
- Diffusion coefficient: D (default: 10 µm²/s)
- Confocal spot size: r0 (default: 250 nm)
- Particle number: nParticles (default: 1000)
Try it out!