From charlesreid1

Line 80: Line 80:
=Using Fipy=
=Using Fipy=


==Using Fipy with Cantera==
==Fipy Scripts==
 
I have assembled notes on Fipy scripts solving a number of different types of problems:
 
===Transient===
 
* [[Fipy/Transient 0D]] - solves a transient 0D equation with a constant source term
* [[Fipy/Reaction 0D]] - solves a transient 0D equation with a reaction source term
 
===Diffusion===
 
* [[Fipy/Diffusion 1D]] - solves a steady 1D diffusion problem
* [[Fipy/Transient Diffusion 1D]] - solves a transient 1D diffusion problem
 
===Convection===
 
* [[Fipy/Convection 1D]] - solves a steady 1D convection problem
 
==Fipy and Cantera==


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

Revision as of 19:59, 16 January 2014

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

Fipy Scripts

I have assembled notes on Fipy scripts solving a number of different types of problems:

Transient

Diffusion

Convection

Fipy and Cantera

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

Fipy and Cantera

Notes on Fipy Examples

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.