Installation¶
The FiPy finite volume PDE solver relies on several third-party packages. It is best to obtain and install those first before attempting to install FiPy. This document explains how to install FiPy, not how to use it. See Using FiPy for details on how to use FiPy.
Note
It may be useful to set up a Development Environment before beginning the installation process.
Note
By selecting the links on this page, you will be leaving NIST webspace. We have provided these links to other web sites because they may have information that would be of interest to you. No inferences should be drawn on account of other sites being referenced, or not, from this page. There may be other web sites that are more appropriate for your purpose. NIST does not necessarily endorse the views expressed, or concur with the facts presented on these sites. Further, NIST does not endorse any commercial products that may be mentioned on these sites. Please address comments about this page to fipy@list.nist.gov.
Pre-Installed on Binder¶
A full FiPy installation is available for basic exploration on Binder. The default notebook gives a rudimentary introduction to FiPy syntax and, like any Jupyter Notebook interface, tab completion will help you explore the package interactively.
Recommended Method¶
Attention
There are many ways to obtain the software packages necessary to run FiPy, but the most expedient way is with the conda package manager. In addition to the scientific Python stack, conda also provides virtual environment management. Keeping separate installations is useful e.g. for comparing Python 2 and Python 3 software stacks, or when the user does not have sufficient privileges to install software system-wide.
In addition to the default packages, many other developers provide “channels” to distribute their own builds of a variety of software. These days, the most useful channel is conda-forge, which provides everything necessary to install FiPy.
install Miniconda on your computer
run:
$ conda create --name <MYFIPYENV> --channel conda-forge python=<PYTHONVERSION> fipy gmsh
Note
This command creates a self-contained conda environment and then downloads and populates the environment with the prerequisites for FiPy from the conda-forge channel at https://anaconda.org.
Gmsh is an optional package because some versions are incompatible with FiPy, so it must be requested explicitly.
Note
The fipy conda-forge package is a convenience. You may choose to install packages explicitly, e.g.,:
$ conda create --name <MYFIPYENV> --channel conda-forge python=3 numpy scipy matplotlib-base future packaging mpich mpi4py petsc4py mayavi "gmsh <4.0|>=4.5.2"
or
$ conda create –name <MYFIPYENV> –channel conda-forge python=2.7 numpy scipy matplotlib-base future packaging pysparse mayavi “traitsui<7.0.0” “gmsh<4.0”
Attention
Windows x86_64 is fully supported, but this does not work on Windows x86_32, as conda-forge no longer supports that platform. For Python 2.7.x, you should be able to do:
conda create --name <MYFIPYENV> --channel conda-forge python=2.7 numpy scipy matplotlib pysparse mayavi weave
and for Python 3.x, you should be able to do:
conda create --name <MYFIPYENV> --channel conda-forge python=3 numpy scipy matplotlib pysparse gmsh
followed, for either, by:
activate <MYFIPYENV> python -m pip install fipy
Attention
Bit rot has started to set in for Python 2.7. One consequence is that
VTKViewer
s can raise errors (probably other uses of Mayavi, too). You may be able to remedy this by creating your environment with:$ conda create --name <MYFIPYENV> --channel conda-forge python=2.7 fipy "traitsui<7.0.0"
enable this new environment with:
$ conda activate <MYFIPYENV>
or
$ source activate <MYFIPYENV>
Note
$ activate <MYFIPYENV>
on Windowsmove on to Using FiPy.
Note
conda can be quite slow to resolve all dependencies when performing an installation. You may wish to consider using the alternative mamba installation manager to speed things up.
Note
On Linux and Mac OS X, you should have a pretty complete system to run and visualize FiPy simulations. On Windows, there are fewer packages available via conda, particularly amongst the sparse matrix Solvers, but the system still should be functional. Significantly, you will need to download and install Gmsh manually when using Python 2.7.
Attention
When installed via conda or pip, FiPy will not include its examples. These can be obtained by cloning the repository or downloading a compressed archive.
Obtaining FiPy¶
FiPy is freely available for download via Git or as a compressed archive. Please see Git usage for instructions on obtaining FiPy with Git.
Warning
Keep in mind that if you choose to download the compressed archive you will then need to preserve your changes when upgrades to FiPy become available (upgrades via Git will handle this issue automatically).
Installing FiPy¶
Details of the Required Packages and links are given below, but for the courageous and the impatient, FiPy can be up and running quickly by simply installing the following prerequisite packages on your system:
Other Optional Packages add greatly to FiPy’s capabilities, but are not necessary for an initial installation or to simply run the test suite.
It is not necessary to formally install FiPy, but if you wish to do so and you are confident that all of the requisite packages have been installed properly, you can install it by typing:
$ python -m pip install fipy
or by unpacking the archive and typing:
$ python setup.py install
at the command line in the base FiPy directory. You can also install FiPy in “development mode” by typing:
$ python setup.py develop
which allows the source code to be altered in place and executed without issuing further installation commands.
Alternatively, you may choose not to formally install FiPy and to simply work within the base directory instead. In this case or if you are making a non-standard install (without admin privileges), read about setting up your Development Environment before beginning the installation process.
Required Packages¶
Python¶
FiPy is written in the Python language and requires a
Python installation to run. Python comes pre-installed
on many operating systems, which you can check by opening a terminal
and typing python
, e.g.:
$ python
Python 2.7.15 | ...
...
Type "help", "copyright", "credits" or "license" for more information.
>>>
If necessary, you can download and install it for your platform <http://www.python.org/download>.
Python along with many of FiPy’s required and optional packages is available with one of the following distributions.
NumPy¶
Obtain and install the NumPy package. FiPy requires at least version 1.0 of NumPy.
Optional Packages¶
Gmsh¶
Gmsh is an application that allows the creation of irregular meshes. When running in parallel, FiPy requires a version of Gmsh >= 2.5 and < 4.0 or >= 4.5.2.
SciPy¶
SciPy provides a large collection of functions and tools that can
be useful for running and analyzing FiPy simulations. Significantly
improved performance has been achieved with the judicious use of C language
inlining (see the Command-line Flags and Environment Variables section for more
details), via the weave
module.
Level Set Packages¶
To use the level set ([8]) components of FiPy one of the following is required.
Scikit-fmm¶
http://packages.python.org/scikit-fmm/
Scikit-fmm is a python extension module which implements the fast marching method.
LSMLIB¶
http://ktchu.serendipityresearch.org/software/lsmlib/index.html
The Level Set Method Library (LSMLIB) provides support for the serial and parallel simulation of implicit surface and curve dynamics in two- and three-dimensions.
Install LSMLIB as per the instructions on the website. Additionally PyLSMLIB is required. To install, follow the instructions on the website, https://github.com/ktchu/LSMLIB/tree/master/pylsmlib#pylsmlib.
Development Environment¶
It is often preferable to not formally install packages in the system directories. The reasons for this include:
developing or altering the package source code,
trying out a new package along with its dependencies without violating a working system,
dealing with conflicting packages and dependencies,
or not having admin privileges.
To avoid tampering with the system Python installation, you can employ one of the utilities that manage packages and their dependencies independently of the system package manager and the system directories. These utilities include conda, Nix, Stow, Virtualenv and Buildout, amongst others. Conda and Nix are only ones of these we have the resources to support.
Our preferred development environment is set up with:
$ conda create --name <MYFIPYENV> --channel conda-forge python=<PYTHONVERSION> fipy
$ source activate <MYFIPYENV>
$ python -m pip install scikit-fmm
$ conda remove --channel conda-forge --force fipy
$ git clone https://github.com/usnistgov/fipy.git
$ cd fipy
$ python setup.py develop
Git usage¶
All stages of FiPy development are archived in a Git repository at GitHub. You can browse through the code at https://github.com/usnistgov/fipy and, using a Git client, you can download various tagged revisions of FiPy depending on your needs.
Attention
Be sure to follow Installation to obtain all the prerequisites for FiPy.
Git client¶
A git
client application is needed in order to fetch files from our
repository. This is provided on many operating systems (try executing
which git
) but needs to be installed on many others. The sources to
build Git, as well as links to various pre-built binaries for
different platforms, can be obtained from http://git-scm.com/.
Git branches¶
In general, most users will not want to download the very latest state of FiPy, as these files are subject to active development and may not behave as desired. Most users will not be interested in particular version numbers either, but instead with the degree of code stability. Different branches are used to indicate different stages of FiPy development. For the most part, we follow a successful Git branching model. You will need to decide on your own risk tolerance when deciding which stage of development to track.
A fresh copy of the FiPy source code can be obtained with:
$ git clone https://github.com/usnistgov/fipy.git
An existing Git checkout of FiPy can be shifted to a different <branch> of development by issuing the command:
$ git checkout <branch>
in the base directory of the working copy. The main branches for FiPy are:
master
designates the (ready to) release state of FiPy. This code is stable and should pass all of the tests (or should be documented that it does not).
Past releases of FiPy are tagged as
x.y.z
Any released version of FiPy will be designated with a fixed tag: The current version of FiPy is 3.4.4. (Legacy
version-x_y_z
tags are retained for historical purposes, but won’t be added to.)
Tagged releases can be found with:
$ git tag --list
Any other branches will not generally be of interest to most users.
Note
For some time now, we have done all significant development work on
branches, only merged back to master
when the tests pass
successfully. Although we cannot guarantee that master
will never
be broken, you can always check our Continuous Integration status
to find the most recent revision that it is running acceptably.
Historically, we merged to develop
before merging to master
. We
no longer do this, although for time being, develop
is kept
synchronized with master
. In a future release, we will remove the
develop
branch altogether.
For those who are interested in learning more about Git, a wide variety of online sources are available, starting with the official Git website. The Pro Git book [9] is particularly instructive.
Nix¶
Nix Installation¶
FiPy now has a Nix expression for installing FiPy using Nix. Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. The recipe works on both Linux and Mac OS X.
Getting Started with Nix¶
There are a number of tutorials on getting started with Nix. The page that I used when getting started is on the Blog of the HPC team of GRICAD,
https://gricad.github.io/calcul/nix/tuto/2017/07/04/nix-tutorial.html
I also made my own notes,
https://github.com/wd15/nixes/blob/master/NIX-NOTES.md
which are a succinct steps that I use when setting up a new system with Nix.
Installing¶
Once you have a working Nix installation use:
$ nix-shell --pure
in the base FiPy directory to install FiPy with Python
3 by default. Modify the shell.nix file to use another version of
Python. nix-shell
drops the user into a shell with a working
version of FiPy. To test your installation use:
$ nix-shell --pure --command "python setup.py test"
Additional Packages¶
To install additional packages available from Nixpkgs include them in the nativeBuildInputs list in shell.nix.
Using Pip¶
Packages unavailable from Nix can be installed using Pip. In
this case, the installation has been set up so that the Nix shell
knows about a .local
directory in the base FiPy directory
used by Pip for installation. So, for example, to install the
toolz
package from within the Nix shell use:
$ python -m pip install --user toolz
The .local
directory will persist after the Nix shell has been
closed.