SpatialPy is a Python 3 package for simulation of spatial deterministic/stochastic reaction-diffusion-advection problems embedded in Lagrangian reference frame particle based fluid dynamics domain
This package is intended to replace the PyURDME software https://github.com/pyurdme/pyurdme and will feature both a NSM solver for RDME simulation on static domains and a sSSA-SDPD particle based fluid dynamics solver as described in the publication "A hybrid smoothed dissipative particle dynamics (SDPD) spatial stochastic simulation algorithm (sSSA) for advection–diffusion–reaction problems" by Drawert, Jacob, Li, Yi, Petzold https://www.sciencedirect.com/science/article/pii/S0021999118307101
![]() |
- Table of contents
- Installation
- Usage
- Getting help
- Contributing
- License
- Authors and history
- Acknowledgments
SpatialPy can be installed on your computer using different methods, as described below.
On Linux, macOS, and Windows operating systems, you should be able to install SpatialPy with pip
. Please review the official pip documentation for installation instructions and additional information.
Then, to install SpatialPy from the Python package repository, run the following command:
python3 -m pip install spatialpy --user --upgrade
As an alternative to getting it from PyPI, you can instruct pip
to install SpatialPy directly from the GitHub repository:
python3 -m pip install https://github.com/StochSS/SpatialPy/archive/main.zip --user --upgrade
As a final alternative, you can first use git
to clone a copy of the SpatialPy source tree from the GitHub repository to your local computer disk, and then install SpatialPy using that copy:
git clone https://github.com/StochSS/SpatialPy.git
cd SpatialPy
python3 -m pip install . --user --upgrade
SpatialPy provides simple object-oriented abstractions for defining a model of a biochemical system and simulating that model using efficient stochastic simulation algorithms. The basic steps to use SpatialPy are:
- Create a
SpatialPy.Model
containing molecular species, parameters, and reactions. - Invoke the model's
.run()
method.
The run()
method can be customized using keyword arguments to select different solvers, random seed, data return type and more. For more detailed examples on how to use SpatialPy, please see the Jupyter notebooks contained in the examples subdirectory.
You can use Docker to create a repeatable environment for developing and debugging SpatialPy. The supplied Dockerfile starts a jupyter server with SpatialPy dependencies installed.
If you have Docker Compose: docker-compose build && docker-compose up
Otherwise:
docker build -t spatialpy:latest .
docker run -v ./:/home/jovyan/spatialpy -v ./tmp:/tmp -p 8888:8888 -p 5000:5000
The SpatialPy repo is mounted into /home/jovyan so you can import it in the usual way for development (see examples).
Any changes you make to your local codebase are reflected in the docker container. Note that you DO NOT need to restart the docker container or even re-import spatialpy to see source changes take effect in jupyter notebooks.
The /tmp
directory is also mounted for easy access to build and result directories.
In order to compile the solver binary for use by the debugger, run solver.compile()
with debug=True
. This will inject the -g
flag into the gcc
command that compiles the solver, enabling gdb debug information.
You can invoke solver.run_debugger()
anytime after you instantiate a solver in Python to start up a new session of gdbgui. The debugger will be available at http://127.0.0.1:5000.
To enable profiling, both solver.compile()
and solver.run()
need to be invoked with profile=True
. If you don't run solver.compile()
explicitly, invoking solver.run()
with profile=True
will run compile()
correctly for you.
SpatialPy's online documentation provides more details about using the software. If you find any problem with SpatialPy or the documentation, please report it using the GitHub issue tracker for this repository. You can also contact Dr. Brian Drawert directly with questions and suggestions.
We would be happy to receive your help and participation with enhancing SpatialPy! Please follow the guidelines described in CONTRIBUTING.md.
New developments happen primarily in the develop
branch. New releases are put in the main
branch.
Main Branch | Develop Branch |
---|---|
SpatialPy is licensed under the GNU General Public License version 3. Please see the file LICENSE for more information.
- Dr. Brian Drawert
- Dr. Kevin Sanft
- Sean Matthew
- Evie Hilton
- Bryan Rumsey
- Bruno Jacob
- Mason Kidwell
- Matthew Geiger
This work has been funded by National Institutes of Health (NIH) NIBIB Award No. 2R01EB014877-04A1.
SpatialPy uses numerous open-source packages, without which it would have been effectively impossible to develop this software with the resources we had. We want to acknowledge this debt. In alphabetical order, the packages are:
- Jupyter – web application for creating documents containing code, visualizations and narrative text
- MatplotLib – Python plotting library
- Plotly – Graphing library for making interactive, publication-quality graphs
- Numpy – the fundamental package for scientific computing with Python
- Scipy – Python-based ecosystem of open-source software for mathematics, science, and engineering
Finally, we are grateful for institutional resources made available by the University of North Carolina at Asheville, the University of California at Santa Barbara, Uppsala University, and the California Institute of Technology.