A Python Library for Solving Partial Differential Equations

Johannes Ring · NORA - Norwegian Open Research Archives · 2007

The aim with this thesis is to investigate how we can create unified interfaces to some key software components that are needed when solving partial differential equations. Two particular components are addressed here: sparse matrices and visualization. We want the interfaces to be simple to use, preferably with a Matlab-like syntax. We also want the interfaces to be "thin" in the sense that the interface code is small and provides access to core functionality only, not all nice-to-have options that one can think of. The interfaces are written in Python [29], a scripting language with a simple, clean and easy-to-use syntax, great software development flexibility, rapidly growing popularity, and rich libraries for both numerical and administrative tasks. The idea is to use Python to write the main algorithm for solving PDEs and thereby steer underlying numerical software. Chapter 1 presents a matrix library for storage, factorization, and "solve" operations. The goal is to have a unified interface to many different types of matrix formats, mainly sparse matrix formats, where the various formats typically have the core numerics in widely different packages (BLAS, LAPACK, PySparse, for instance). PDE solvers written in Python can then work with one API for creating matrices and solving linear systems. This idea is not new and has been explored in many C++ libraries, e.g., Diffpack [3], DOLFIN [5] and GLAS [10]. The new contribution in this thesis is to have such an interface in Python and explore some of Python's flexibility. We also have a more heterogeneous collection of underlying matrix libraries than what the cited C++ packages aim at. Python is slow for number crunching so it is crucial to perform the factorization and solve operations in compiled Fortran, C or C++ libraries. The PyACTS project [26] has a goal quite similar to ours, but is aimed at the tools in the ACTS collection only (ScaLAPACK, SuperLU, Hyper, to mention some). A natural future extension of our matrix library will be to incorporate PyACTS. This will also provide support for parallel computing. The present thesis is limited to serial computing only. At the end of Chapter 1 we explore the matrix library for solving diffusion equations. In particular, we compare the the efficiency of the traditional ADI methods with sparse matrix factorization-based solution techniques. Chapter 2 deals with a unified interface, called Easyviz, to visualization packages, both for curve plotting and for 2D/3D visualization of scalar and vector fields. The interface calls up various plotting packages, some simple and easy-to-install like Gnuplot and some more comprehensive like VTK and Matplotlib. The Easyviz syntax almost coincides with that of Matlab, thus making it easy for students and researchers trained in Matlab to start plotting with a Python-based platform. Or in other words, one can use Matlab-like syntax for accessing a wide range of visualization tools. In this way, PDE solvers can visualize the solutions with a code independent of the underlying plotting package that actually produces the plots. Chapter 2 acts as a tutorial for Easyviz and has been written together with my supervisor Hans Petter Langtangen. The focus of this thesis has been on developing reusable and stable software and to document this software such that it can readily be applied by students and scientists.

Read the paper · More papers on PaperTik