Code & Tutorials

Rigid body simulator

[used for my tutorials on classical Lagrangian mechanics]

Description: This tool, developed in R with embedded C code, allows the user to simulate the tossing of any odd-shaped rigid body onto a flat surface of adjustable elasticity and friction.

Illustration: tossed cuboid with side lengths 6:3:2; centre of mass (black), angular velocity (grey, blue), angular momentum (thin grey).

Download: please contact me at

Developer: Danail Obreschkow, 2013

Gravitational N-body simulator

[used for my tutorials on the gravitational N-body problem]

Description: These are the source files required for my seven step tutorial to build a simple gravitational N-body simulator in R with the following features:
+ Arbitrary number or particles of varying mass
+ Simulation and visualisation in 3D
+ Leapfrog integration
+ Adaptive time step
+ Smoothed particles

Illustration: the Sun, Jupiter, Earth and a comet that swings by Jupiter while changing its orbit from parabolic to elliptic; a point is plotted every 30 days

Download R-files here

Developer: Danail Obreschkow, 2014

Simulation of jetting cavitation bubbles

Description: Simulation of an asymmetric cavitation bubble during its growth (grey), collapse (black) and jet-impact (blue). The fluid is assumed to be incompressible, inviscid and irrotational, and surface tension is neglected. The Navier-Stokes equations are solved using the boundary integral method developped by J. R. Blake and collaborators in this context. Users are kindly asked to cite the works by Supponnen et al. (in prep.) and Blake & Gibson (Ann. Rev. Fluid Mech, 19, 1987).

Illustration: Bubbles collapsing while forming a jet driven by an asymmetric situation, caused by gravity, a rigid surface and a free surface, respectively. The three cases represent identical asymmetry parameters zeta.

Download R-file here. (Please view this file in a text-editor to get a brief explanation of how to run the software.)

Developer: Danail Obreschkow, 2016

SPH simulator of a viscous fluid

[used for my tutorials on SPH methods]

Description: This is a basic smoothed particle hydrodynamics simulator of a compressible, viscous fluid in two dimensions. The core code is written in C and embedded into a Matlab script for visualisation.

Illustration: Viscous fluid forming a Karman vortex street behind a cylindrical obstacle.

Download: please contact me at

Developer: Danail Obreschkow, 2011



Advanced correlation functions in cosmological N-body simulations

Description: ProCorr is a Fortran code to efficiently compute several correlation functions of a cubic periodic density field, provided as regular 3D grid or array of particle positions. ProCorr can compute the power spectrum, the 2-point autocorrelation, the bispectrum, and the line correlation function l(r), introduced in Obreschkow et al. (ApJ 762, 2013). It can also convert particle lists into regular grids in a way that conserves the small-scale power; and it can generate Fourier transforms of density fields. For details please refer to the README file provided with the code.

Illustration: adopted from Obreschkow et al. (ApJ 2013).

Download ProCorr 1.12 here 

Developer: Danail Obreschkow, 2013-2017



Description: CorrPhase also allows the computation of the line correlation function. However, unlike ProCorr (above), CorrPhase evaluates the line correlation analytically using linear and second order perturbation theory combined with appropriate fitting formulae (see Wolstenhulme, Bonvin and Obreschkow, ApJ 2014).

Illustration: Three snapshots from the Wolstenhulme publication.

Download CorrPhase via Camille Bonvin’s page

Developers: Camille Bonvin & Richard Wolstenhulme, 2014