Skip to main content

Spatial Modeling Algorithms for Reactions and Transport (SMART) is a high-performance finite-element-based simulation package for model specification and numerical simulation of spatially-varying reaction-transport processes in biological cells.

Project description

Test fenics_smart PyPI Deploy static content to Pages pre-commit DOI DOI

Spatial Modeling Algorithms for Reaction-Transport [systems|models|equations]

Statement of Need

Spatial Modeling Algorithms for Reactions and Transport (SMART) is a finite-element-based simulation package for model specification and numerical simulation of spatially-varying reaction-transport processes, especially tailored to modeling such systems within biological cells. SMART is based on the FEniCS finite element library, provides a symbolic representation framework for specifying reaction pathways, and supports large and irregular cell geometries in 2D and 3D.

Installation

SMART has been installed and tested on Linux for AMD, ARM, and x86_64 systems, primarily via Ubuntu 20.04 or 22.04. On Windows devices, we recommend using Windows Subsystem for Linux to run the provided docker image (see below). SMART has also been tested on Mac OS using docker. Installation using docker should take less than 30 minutes on a normal desktop computer.

Using docker (recommended)

The simplest way to use fenics-smart is to use the provided docker image. You can get this image by pulling it from the github registry

docker pull ghcr.io/rangamanilabucsd/smart:latest

It is also possible to pull a specific version by changing the tag, e.g.

docker pull ghcr.io/rangamanilabucsd/smart:v2.0.1

will use version 2.0.1.

In order to start a container you can use the docker run command. For example the command

docker run --rm -v $(pwd):/home/shared -w /home/shared -ti ghcr.io/rangamanilabucsd/smart:latest

will run the latest version and share your current working directory with the container. The source code of smart is located at /repo in the docker container.

Running the example notebooks

To run the example notebooks, one can use ghcr.io/rangamanilabucsd/smart-lab

docker run -ti -p 8888:8888 --rm ghcr.io/rangamanilabucsd/smart-lab

to run interactively with Jupyter lab in browser

Converting notebooks to Python files

In the smart and smart-lab images, these files exist under /repo/examples/**/example*.py.

If you clone the git repository or make changes to the notebooks that should be reflected in the python files, you can run

python3 examples/convert_notebooks_to_python.py

to convert all notebooks to python files. NOTE this command overwrites existing files.

Using pip

fenics-smart is also available on pypi and can be installed with

python3 -m pip install fenics-smart

However this requires FEniCS version 2019.2.0 or later to already be installed. Currently, FEniCS version 2019.2.0 needs to be built from source or use some of the pre-built docker images

Example usage

The SMART repository contains a number of examples in the examples directory which also run as continuous integration tests (see "Automated Tests" below):

  • Example 1: Formation of Turing patterns in 2D reaction-diffusion (rectangular domain)
  • Example 2: Simple cell signaling model in 2D (ellipse)
  • Example 2 - 3D: Simple cell signaling model in 3D (realistic spine geometry)
  • Example 3: Model of protein phosphorylation and diffusion in 3D (sphere)
  • Example 4: Model of second messenger reaction-diffusion in 3D (ellipsoid-in-an-ellipsoid)
  • Example 5: Simple cell signaling model in 3D (cube-in-a-cube)
  • Example 6: Model of calcium dynamics in a neuron (sphere-in-a-sphere)

Functionality documentation

SMART is equipped to handle:

  • Reaction-diffusion with any number of species, reactions, and compartments.
  • 3D-2D problems or 2D-1D problems; that is, you can solve a problem with many 3D sub-volumes coupled to many 2D sub-surfaces, or a problem with many 2D "sub-volumes" coupled to many 1D "sub-surfaces"
  • Conversion of units at run-time via Pint so that models can be specified in whatever units are most natural/convenient to the user.
  • Specification of a time-dependent function either algebraically or from data (SMART will numerically integrate the data points at each time-step).
  • Customized reaction equations (e.g. irreversible Hill equation).

The current version of SMART is not compatible with MPI-based mesh parallelization; this feature is in development pending a future release of DOLFIN addressing some issues when using MeshViews in parallel. However, SMART users can utilize MPI to run multiple simulations in parallel (one mesh per process), as demonstrated in Example 3 with MPI.

The general form of the mixed-dimensional partial differential equations (PDEs) solved by SMART, along with mathematical details of the numerical implementation, are documented here.

Our API documentation can be accessed here.

Automated tests

Upon pushing new code to the SMART repository, a number of tests run:

  • pre-commit tests.
    • Install pre-commit: python3 -m pip install pre-commit
    • Run pre-commit hooks: pre-commit run --all
  • unit tests (can be found in tests folder): test initialization of compartment, species, and parameter objects.
    • Install test dependencies: python3 -m pip install fenics-smart[test]. Alternatively, if you have already installed SMART, you can install pytest and pytest-cov using python3 -m pip install pytest pytest-cov.
    • Run tests from the root of the repository: python3 -m pytest
  • Examples 1-6: All 6 examples are run when building the docs. These serve as Continuous Integration (CI) tests; within each run, there is a regression test comparing the output values from the simulation with values obtained from a previous build of SMART. Outputs from examples 2 and 3 are also compared to analytical solutions to demonstrate the accuracy of SMART simulations.
  • Example 2 - 3D
  • Example 3 with MPI: Example 3 is run using MPI to run differently sized meshes in parallel (each process is assigned a single mesh).

Contributing guidelines

Detailed contributing guidelines are given here.

Dependencies

  • SMART uses FEniCS to assemble finite element matrices from the variational form
  • SMART uses [PETSc4py] to solve the resultant linear algebra systems.
  • SMART uses pandas as an intermediate data structure to help organize and process models.
  • SMART uses Pint for unit tracking and conversions.
  • SMART uses matplotlib to generate plots in examples
  • SMART uses sympy to allow users to input custom reactions and also to determine the appopriate solution techniques (e.g. testing for non-linearities).
  • SMART uses numpy and scipy for general array manipulations and basic calculations.
  • SMART uses tabulate to make ASCII tables.
  • SMART uses termcolor for colored terminal output.

License

LGPL-3.0

SMART development team

Previous contributors:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fenics_smart-2.2.3.tar.gz (83.7 kB view details)

Uploaded Source

Built Distribution

fenics_smart-2.2.3-py3-none-any.whl (83.9 kB view details)

Uploaded Python 3

File details

Details for the file fenics_smart-2.2.3.tar.gz.

File metadata

  • Download URL: fenics_smart-2.2.3.tar.gz
  • Upload date:
  • Size: 83.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for fenics_smart-2.2.3.tar.gz
Algorithm Hash digest
SHA256 b7a4940010182ff022916775153b0827ad69d33747076da3604745e4dd2ef56c
MD5 eec7001299fedf59f1c2c750f4087e08
BLAKE2b-256 bb6804aca1ce6f76185b4df11548715c20a15af4515781efb03d9d8ee3ac1471

See more details on using hashes here.

File details

Details for the file fenics_smart-2.2.3-py3-none-any.whl.

File metadata

  • Download URL: fenics_smart-2.2.3-py3-none-any.whl
  • Upload date:
  • Size: 83.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for fenics_smart-2.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5182014c394d185a7cc60a3daeea57d1d03d84a08e79cb2b5d082c7906091125
MD5 ca87f2597291efaac23bf3238c0f4e81
BLAKE2b-256 d6f81e8cf1a9d6c61040ecfd370691404da46778467d6873a1ab8f7e83c2c353

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page