Bookmark and Share FiPy: A Finite Volume PDE Solver Using Python
Version 3.0.1-dev139-ge5d2233

Previous topic

Installation

Next topic

Viewers

This Page

Contact

FiPy developers
Jonathan Guyer
Daniel Wheeler
James Warren

Join our mailing list

100 Bureau Drive, M/S 6555
Gaithersburg, MD 20899

301-975-5329 Telephone
301-975-4553 Facsimile

Solvers

FiPy requires either PySparse, SciPy or Trilinos to be installed in order to solve linear systems. From our experiences, FiPy runs most efficiently in serial when PySparse is the linear solver. Trilinos is the most complete of the three solvers due to its numerous preconditioning and solver capabilities and it also allows FiPy to run in parallel. Although less efficient than PySparse and less capable than Trilinos, SciPy is a very popular package, widely available and easy to install. For this reason, SciPy may be the best linear solver choice when first installing and testing FiPy (and it is the only viable solver under Python 3.x).

FiPy chooses the solver suite based on system availability or based on the user supplied Command-line Flags and Environment Variables. For example, passing --no-pysparse:

$ python -c "from fipy import *; print DefaultSolver" --no-pysparse
<class 'fipy.solvers.trilinos.linearGMRESSolver.LinearGMRESSolver'>

uses a Trilinos solver. Setting FIPY_SOLVERS to scipy:

$ FIPY_SOLVERS=scipy
$ python -c "from fipy import *; print DefaultSolver"
<class 'fipy.solvers.scipy.linearLUSolver.LinearLUSolver'>

uses a SciPy solver. Suite-specific solver classes can also be imported and instantiated overriding any other directives. For example:

$ python -c "from fipy.solvers.scipy import DefaultSolver; \
>   print DefaultSolver" --no-pysparse
<class 'fipy.solvers.scipy.linearLUSolver.LinearLUSolver'>

uses a SciPy solver regardless of the command line argument. In the absence of Command-line Flags and Environment Variables, FiPy‘s order of precedence when choosing the solver suite for generic solvers is PySparse followed by Trilinos, PyAMG and SciPy.

PySparse

http://pysparse.sourceforge.net

PySparse is a fast serial sparse matrix library for Python. It provides several sparse matrix storage formats and conversion methods. It also implements a number of iterative solvers, preconditioners, and interfaces to efficient factorization packages. The only requirement to install and use Pysparse is NumPy.

Warning

FiPy requires version 1.0 or higher of PySparse.

SciPy

http://www.scipy.org/

The scipy.sparse module provides a basic set of serial Krylov solvers, but no preconditoners.

PyAMG

http://code.google.com/p/pyamg/

The PyAMG package provides adaptive multigrid preconditioners that can be used in conjunction with the SciPy solvers.

Trilinos

http://trilinos.sandia.gov

Trilinos provides a more complete set of solvers and preconditioners than either PySparse or SciPy. Trilinos preconditioning allows for iterative solutions to some difficult problems that PySparse and SciPy cannot solve, and it enables parallel execution of FiPy (see Solving in Parallel for more details).

Attention

Be sure to build or install the PyTrilinos interface to Trilinos.

Attention

FiPy runs more efficiently when PySparse is installed alongside Trilinos.

Attention

Trilinos is a large software suite with its own set of prerequisites, and can be difficult to set up. It is not necessary for most problems, and is not recommended for a basic install of FiPy.

Trilinos requires cmake, NumPy, and swig. The following are the minimal steps to build and install Trilinos (with PyTrilinos) for FiPy:

$ cd trilinos-X.Y/
$ SOURCE_DIR=`pwd`
$ mkdir BUILD_DIR
$ cd BUILD_DIR
$ cmake \
>   -D CMAKE_BUILD_TYPE:STRING=RELEASE \
>   -D Trilinos_ENABLE_PyTrilinos:BOOL=ON \
>   -D BUILD_SHARED_LIBS:BOOL=ON \
>   -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON \
>   -D TPL_ENABLE_MPI:BOOL=ON \
>   -D Trilinos_ENABLE_TESTS:BOOL=ON \
>   -D DART_TESTING_TIMEOUT:STRING=600 \
>   ${SOURCE_DIR}
$ make
$ make install

Depending on your platform, other options may be helpful or necessary; see the Trilinos user guide available from http://trilinos.sandia.gov/documentation.html, or http://trilinos.sandia.gov/packages/pytrilinos/faq.html for more in-depth documentation.

Note

Trilinos can be installed in a non-standard location by adding the -D CMAKE_INSTALL_PREFIX:PATH=${INSTALL_DIR} and -D PyTrilinos_INSTALL_PREFIX:PATH=${INSTALL_DIR} flags to the configure step. If Trilinos is installed in a non-standard location, the path to the PyTrilinos site-packages directory should be added to the PYTHONPATH environment variable; this should be of the form ${INSTALL_DIR}/lib/${PYTHON_VERSION}/site-packages/. Also, the path to the Trilinos lib directory should be added to the LD_LIBRARY_PATH (on Linux) or DYLD_LIBRARY_PATH (on Mac OS X) environment variable; this should be of the form ${INSTALL_DIR}/lib`.

mpi4py

http://mpi4py.scipy.org/

For Solving in Parallel, FiPy requires mpi4py, in addition to Trilinos.