From charlesreid1

Revision as of 18:25, 13 January 2014 by Admin (talk | contribs) (→‎Using Fipy)

Fipy is a finite-volume partial differential equation solver written in Python.

Installing Fipy

Installing FiPy with Pip

These instructions worked for Mountain Lion and Maverick (OS X 10.7 and 10.8).

Numpy

Keep it simple:

pip install numpy

Pysparse

Both pip and easy_install are broken for pysparse:

$ pip install pysparse
Downloading/unpacking pysparse
  Could not find a version that satisfies the requirement pysparse (from versions: 1.1.1-dev, 1.2-dev, 1.2-dev202, 1.2-dev203, 1.2-dev213, 1.3-dev)
Cleaning up...
No distributions matching the version for pysparse
Storing complete log in /Users/charles/.pip/pip.log
$ easy_install pysparse

[...]

1 error generated.
error: Setup script exited with error: Command "/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DLENFUNC_OK=1 -DNO_ATLAS_INFO=3 -I/private/var/folders/nw/1yytq18n06db0v8r1pvxf5rc0000gn/T/easy_install-dlFghq/pysparse-1.3-dev/pysparse/sparse/src -I/var/folders/nw/1yytq18n06db0v8r1pvxf5rc0000gn/T/easy_install-dlFghq/pysparse-1.3-dev/pysparse/include -I/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/var/folders/nw/1yytq18n06db0v8r1pvxf5rc0000gn/T/easy_install-dlFghq/pysparse-1.3-dev/pysparse/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c /private/var/folders/nw/1yytq18n06db0v8r1pvxf5rc0000gn/T/easy_install-dlFghq/pysparse-1.3-dev/pysparse/sparse/src/spmatrixmodule.c -o build/temp.macosx-10.6-intel-2.7/private/var/folders/nw/1yytq18n06db0v8r1pvxf5rc0000gn/T/easy_install-dlFghq/pysparse-1.3-dev/pysparse/sparse/src/spmatrixmodule.o -msse3 -I/System/Library/Frameworks/vecLib.framework/Headers" failed with exit status 1

So I built it myself:

$ git clone git://pysparse.git.sourceforge.net/gitroot/pysparse/pysparse
$ cd pysparse
$ python setup.py build && python setup.py install

Fipy

Using pip:

$ pip install fipy

Installing Fipy from Source

I was able to mostly follow this guide on Matforge (the site that hosts Fipy source code): http://matforge.org/fipy/wiki/InstallFiPy/MacOSX/SnowLeopard

Here are the steps I took:

  • Skipped virtualenv (because I manage my Python distribution intelligently/carefully, I didn't need to bother with this step. See my Python page for more information.)
  • Already had Gfortran installed.
  • Installed the latest Cmake
  • Skipped FFTW
  • Skipped SparseSuite
    • I was able to skip both of these because my Numpy was working and using the system's LAPACK/BLAS without problems.
  • Already had Numpy installed
  • Already had Matplotlib installed
  • Installed Pysparse from source

Once I had all of these dependencies installed, I was able to download and install Fipy. Note that as of this writing (December 2013), the instructions on http://matforge.org/fipy/wiki/InstallFiPy/MacOSX/SnowLeopard are out of date, because it specifies that you should check out a copy of the source code via SVN. In fact, Fipy now uses git.

Either download the latest release from this page: http://www.ctcms.nist.gov/fipy/download/ or by cloning a copy with git:

$ git clone git://code.matforge.org/nist/fipy.git


Using Fipy

Using Fipy with Cantera

This section contains some notes on how to use Fipy with Cantera.

Fipy and Cantera

Surface Adsorption Equation

One of the examples included with Fipy is a electrochemical level set example, which defines, among other things, a surface adsorption equation class. I have compiled some scattered notes on this class here:

Fipy/Surface Adsorption Equation

My application was somewhat different - I wasn't so much interested in the evolution of the interface, as much as I was interested in the evolution of adsorbed surface species on a stationary catalyst surface.