Bookmark and Share FiPy: A Finite Volume PDE Solver Using Python
Version 3.1

Previous topic


Next topic

Diffusion Examples

This Page


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



Any given module “example.something.input” can be found in the file “examples/something/”.

These examples can be used in at least four ways:

  • Each example can be invoked individually to demonstrate an application of FiPy:

    $ python examples/something/
  • Each example can be invoked such that when it has finished running, you will be left in an interactive Python shell:

    $ python -i examples/something/

    At this point, you can enter Python commands to manipulate the model or to make queries about the example’s variable values. For instance, the interactive Python sessions in the example documentation can be typed in directly to see that the expected results are obtained.

  • Alternatively, these interactive Python sessions, known as doctest blocks, can be invoked as automatic tests:

    $ python test --examples

    In this way, the documentation and the code are always certain to be consistent.

  • Finally, and most importantly, the examples can be used as a templates to design your own problem scripts.


    The examples shown in this manual have been written with particular emphasis on serving as both documentation and as comprehensive tests of the FiPy framework. As explained at the end of examples/diffusion/steadyState/, your own scripts can be much more succint, if you wish, and include only the text that follows the “>>>” and “...” prompts shown in these examples.

    To obtain a copy of an example, containing just the script instructions, type:

    $ python copy_script --From --To

In addition to those presented in this manual, there are dozens of other files in the examples/ directory, that demonstrate other uses of FiPy. If these examples do not help you construct your own problem scripts, please contact us.