PySPH: a Python-based SPH framework

PySPH is an open source framework for Smoothed Particle Hydrodynamics (SPH) simulations. It is implemented in Python and the performance critical parts are implemented in Cython.

PySPH is implemented in a way that allows a user to specify the entire SPH simulation in pure Python. High-performance code is generated from this high-level Python code, compiled on the fly and executed. PySPH can use OpenMP to utilize multi-core CPUs effectively. PySPH also features optional automatic parallelization (multi-CPU) using mpi4py_ and Zoltan. If you wish to use the parallel capabilities you will need to have these installed.

Here are videos of simulations made with PySPH.

PySPH is hosted on bitbucket. Please see the bitbucket site for development details.


  • User scripts and equations are written in pure Python.
  • Flexibility to define arbitrary SPH equations operating on particles.
  • Ability to define your own multi-step integrators in pure Python.
  • High-performance: our performance is comparable to hand-written solvers implemented in FORTRAN.
  • Seamless multi-core support with OpenMP.
  • Seamless parallel integration using Zoltan.
  • BSD license.

SPH formulations

Currently, PySPH has numerous examples to solve the viscous, incompressible Navier-Stokes equations using the weakly compressible (WCSPH) approach. The following formulations are currently implemented:


3D dam-break past an obstacle SPHERIC benchmark Test 2


Streamlines for a driven cavity


Collision of two elastic rings.


PySPH is primarily developed at the Department of Aerospace Engineering, IIT Bombay. We are grateful to IIT Bombay for the support. Our primary goal is to build a powerful SPH-based tool for both application and research. We hope that this makes it easy to perform reproducible computational research.

Lead developers:

Earlier developers:

  • Pankaj Pandey (stress solver and improved load balancing, 2011)
  • Chandrashekhar Kaushik (original parallel and serial implementation in 2009)

The following have contributed bug-fixes, features, documentation etc.

  • Arkopal Dutt, Arpit Agarwal, Sarang Minhas, S Saravanan, Vishnu Sivadasan

Citing PySPH

We are in the process of writing up an article on the new PySPH framework as it stands today. In the meanwhile, if you use PySPH and wish to cite it you may use this:

  • Prabhu Ramachandran and Kunal Puri, PySPH: A framework for parallel particle simulations, In proceedings of the 3rd International Conference on Particle-Based Methods (Particles 2013), Stuttgart, Germany, 18th September 2013.


  • 2009: PySPH started with a simple Cython based 1D implementation written by Prabhu.
  • 2009-2010: Chandrashekhar Kaushik worked on a full 3D SPH implementation with a more general purpose design. The implementation was in a mix of Cython and Python.
  • 2010-2012: The previous implementation was a little too complex and was largely overhauled by Kunal and Pankaj. This became the PySPH 0.9beta release. The difficulty with this version was that it was almost entirely written in Cython, making it hard to extend or add new formulations without writing more Cython code. Doing this was difficult and not too pleasant. In addition it was not as fast as we would have liked it. It ended up feeling like we might as well have implemented it all in C++ and exposed a Python interface to that.
  • 2011-2012: Kunal also implemented SPH2D and another internal version called ZSPH in Cython which included Zoltan based parallelization using PyZoltan. This was specific to his PhD research and again required writing Cython making it difficult for the average user to extend.
  • 2013-present In early 2013, Prabhu reimplemented the core of PySPH to be almost entirely auto-generated from pure Python. The resulting code was faster than previous implementations and very easy to extend entirely from pure Python. Kunal and Prabhu integrated PyZoltan into PySPH and the current version of PySPH was born. Subsequently, OpenMP support was also added in 2015.


If you have any questions or are running into any difficulties with PySPH, please email or post your questions on the pysph-users mailing list here:

Please also take a look at the PySPH issue tracker.



  • Release date: 14th July, 2016.
  • Improve many examples to make it easier to make comparisons.
  • Many equation parameters no longer have defaults to prevent accidental errors from not specifying important parameters.
  • Added support for Scheme classes that manage the generation of equations and solvers. A user simply needs to create the particles and setup a scheme with the appropriate parameters to simulate a problem.
  • Add support to easily handle multiple rigid bodies.
  • Add support to dump HDF5 files if h5py is installed.
  • Add support to directly dump VTK files using either Mayavi or PyVisfile, see pysph dump_vtk
  • Improved the nearest neighbor code, which gives about 30% increase in performance in 3D.
  • Remove the need for the windows_env.bat script on Windows. This is automatically setup internally.
  • Add test that checks if all examples run.
  • Remove unused command line options and add a --max-steps option to allow a user to run a specified number of iterations.
  • Added Ghia et al.’s results for lid-driven-cavity flow for easy comparison.
  • Added some experimental results for the dam break problem.
  • Use argparse instead of optparse as it is deprecated in Python 3.x.
  • Add to facilitate easier automation and reproducibility of PySPH simulations.
  • Add spatial hash and extended spatial hash NNPS algorithms for comparison.
  • Refactor and cleanup the NNPS related code.
  • Add several gas-dynamics examples and the ADEKEScheme.
  • Work with mpi4py_ version 2.0.0 and older versions.
  • Fixed major bug with TVF implementation and add support for 3D simulations with the TVF.
  • Fix bug with uploaded tarballs that breaks pip install pysph on Windows.
  • Fix the viewer UI to continue playing files when refresh is pushed.
  • Fix bugs with the timestep values dumped in the outputs.
  • Fix floating point issues with timesteps, where examples would run a final extremely tiny timestep in order to exactly hit the final time.


  • Release date: 18th August, 2015.
  • Fix bug with output_at_times specification for solver.
  • Put generated sources and extensions into a platform specific directory in ~/.pysph/sources/<platform-specific-dir> to avoid problems with multiple Python versions, operating systems etc.
  • Use locking while creating extension modules to prevent problems when multiple processes generate the same extesion.
  • Improve the Application class so users can subclass it to create examples. The users can also add their own command line arguments and add pre/post step/stage callbacks by creating appropriate methods.
  • Moved examples into the pysph.examples. This makes the examples reusable and easier to run as installation of pysph will also make the examples available. The examples also perform the post-processing to make them completely self-contained.
  • Add support to write compressed output.
  • Add support to set the kernel from the command line.
  • Add a new pysph script that supports view, run, and test sub-commands. The pysph_viewer is now removed, use pysph view instead.
  • Add a simple remeshing tool in
  • Cleanup the symmetric eigenvalue computing routines used for solid mechanics problems and allow them to be used with OpenMP.
  • The viewer can now view the velocity magnitude (vmag) even if it is not present in the data.
  • Port all examples to use new Application API.
  • Do not display unnecessary compiler warnings when there are no errors but display verbose details when there is an error.


  • Release date: 12th June, 2015
  • Support for tox, this makes it trivial to test PySPH on py26, py27 and py34 (and potentially more if needed).
  • Fix bug in code generator where it is unable to import pysph before it is installed.
  • Support installation via pip by allowing egg_info to be run without cython or numpy.
  • Added Codeship CI build using tox for py27 and py34.
  • CI builds for Python 2.7.x and 3.4.x.
  • Support for Python-3.4.x.
  • Support for Python-2.6.x.


  • Release date: 3rd June, 2015.
  • First public release of the new PySPH code which uses code-generation and is hosted on bitbucket.
  • OpenMP support.
  • MPI support using Zoltan.
  • Automatic code generation from high-level Python code.
  • Support for various multi-step integrators.
  • Added an interpolator utility module that interpolates the particle data onto a desired set of points (or grids).
  • Support for inlets and outlets.
  • Support for basic Gmsh input/output.
  • Plenty of examples for various SPH formulations.
  • Improved documentation.
  • Continuous integration builds on Shippable,, and AppVeyor.