A framework for Smoothed Particle Hydrodynamics in Python
Switch branches/tags
Clone or download
Latest commit bf7e020 Nov 8, 2018
Failed to load latest commit information.
docker DOC: Document rebuilding docker image. Sep 14, 2016
docs Add documentation for the feature. Nov 2, 2018
examples/cpy Local memory support to CUDA Oct 24, 2018
old_examples Add an IISPH scheme. Feb 20, 2018
pysph Add simple remeshing option for taylor green example. Nov 8, 2018
pyzoltan Try and fix test errors. Sep 21, 2018
starcluster Fixing format issues Aug 24, 2017
.coveragerc Added .coveragerc and modified setup.py so that linetracing is enable… Jun 14, 2017
.gitignore Adding tox setup to test on py26, py27 and py34. Jun 10, 2015
.travis.yml Use defaults channel in travis instead of anaconda Oct 24, 2018
CHANGES.rst Updating documentation with OpenCL information. Sep 26, 2017
LICENSE.txt Adding license file [skip ci]. May 13, 2015
MANIFEST.in Add *.h to MANIFEST May 14, 2016
Makefile updated tox.ini so that pysph test runs fast tests only May 12, 2017
README.rst Updating documentation with OpenCL information. Sep 26, 2017
appveyor.yml Separate test requirements Mar 5, 2018
bitbucket-pipelines.yml Update shippable to use pysph/base docker image. Aug 15, 2016
build_zoltan.sh Update zoltan version to 3.83. Aug 15, 2016
requirements-test.txt Memoize kernel generation methods Sep 24, 2018
requirements.txt Memoize kernel generation methods Sep 24, 2018
setup.cfg Modified files for pytest automation and CI May 7, 2017
setup.py Setup changes and documentation for STL Converter Jan 24, 2018
shippable.yml Fix some test errors. Sep 29, 2017
tox.ini Update tox.ini Aug 26, 2018


PySPH: a Python-based SPH framework

Travis Status Shippable Status Appveyor Status Codeship Status

PySPH has moved here: https://github.com/pypr/pysph

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 and PyOpenCL.

PySPH allows users to write their high-level code in pure Python. This Python code is automatically converted to high-performance Cython or OpenCL which is compiled and executed. PySPH can also be configured to work seamlessly with OpenMP, OpenCL, and MPI.

The latest documentation for PySPH is available at pysph.readthedocs.org.

Here are videos of some example problems solved using PySPH.


  • Flexibility to define arbitrary SPH equations operating on particles in pure Python.
  • 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 GPU support with PyOpenCL.
  • Seamless parallel support using Zoltan.

SPH formulations

PySPH ships with a variety of standard SPH formulations along with basic examples. Some of the formulations available are:


Up-to-date details on how to install PySPH on Linux/OS X and Windows are available from here.

If you wish to see a working build/test script please see our shippable.yml. For Windows platforms see the appveyor.yml.

Running the examples

You can verify the installation by exploring some examples. A fairly quick running example (taking about 20 seconds) would be the following:

$ pysph run elliptical_drop

This requires that Mayavi be installed. The saved output data can be viewed by running:

$ pysph view elliptical_drop_output/

A more interesting example would be a 2D dam-break example (this takes about 30 minutes in total to run):

$ pysph run dam_break_2d

The solution can be viewed live by running (on another shell):

$ pysph view

The generated output can also be viewed and the newly generated output files can be refreshed on the viewer UI.

A 3D version of the dam-break problem is also available, and may be run as:

$ pysph run dam_break_3d

This runs the 3D dam-break problem which is also a SPHERIC benchmark Test 2

Three-dimensional dam-break example

PySPH is more than a tool for wave-body interactions::

$ pysph run cavity

This runs the driven cavity problem using the transport velocity formulation of Adami et al. The output directory cavity_output will also contain streamlines and other post-processed results after the simulation completes. For example the streamlines look like the following image:

Lid-driven-cavity example

If you want to use PySPH for elastic dynamics, you can try some of the examples from the pysph.examples.solid_mech package:

$ pysph run solid_mech.rings

Which runs the problem of the collision of two elastic rings:

Collision of two steel rings

The auto-generated code for the example resides in the directory ~/.pysph/source. A note of caution however, it's not for the faint hearted.

There are many more examples, they can be listed by simply running:

$ pysph run


PySPH is primarily developed at the Department of Aerospace Engineering, IIT Bombay. We are grateful to IIT Bombay for their 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.

To see the list of contributors the see github contributors page

Some earlier developers not listed on the above are:

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


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: https://groups.google.com/d/forum/pysph-users

Please also take a look at the PySPH issue tracker.