PETSC4PY(1) | PETSc for Python | PETSC4PY(1) |
petsc4py - PETSc for Python
This document describes petsc4py, a Python port to the PETSc libraries.
PETSc (the Portable, Extensible Toolkit for Scientific Computation) is a suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations. It employs the MPI standard for all message-passing communication.
This package provides an important subset of PETSc functionalities and uses NumPy to efficiently manage input and output of array data.
A good friend of petsc4py is:
Other projects depends on petsc4py:
PETSc is a suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations. It employs the MPI standard for all message-passing communication.
PETSc is intended for use in large-scale application projects [petsc-efficient], and several ongoing computational science projects are built around the PETSc libraries. With strict attention to component interoperability, PETSc facilitates the integration of independently developed application modules, which often most naturally employ different coding styles and data structures.
PETSc is easy to use for beginners [petsc-user-ref]. Moreover, its careful design allows advanced users to have detailed control over the solution process. PETSc includes an expanding suite of parallel linear and nonlinear equation solvers that are easily used in application codes written in C, C++, and Fortran. PETSc provides many of the mechanisms needed within parallel application codes, such as simple parallel matrix and vector assembly routines that allow the overlap of communication and computation.
PETSc is designed with an object-oriented style. Almost all user-visible types are abstract interfaces with implementations that may be chosen at runtime. Those objects are managed through handles to opaque data structures which are created, accessed and destroyed by calling appropriate library routines.
PETSc consists of a variety of components. Each component manipulates a particular family of objects and the operations one would like to perform on these objects. These components provide the functionality required for many parallel solutions of PDEs.
You can use pip to install petsc4py and its dependencies (mpi4py is optional but highly recommended):
$ pip install [--user] numpy mpi4py $ pip install [--user] petsc petsc4py
Alternatively, you can use easy_install (deprecated):
$ easy_install petsc4py
If you already have a working PETSc installation, set environment variables PETSC_DIR and PETSC_ARCH to appropriate values and next use pip:
$ export PETSC_DIR=/path/to/petsc $ export PETSC_ARCH=arch-linux2-c-opt $ pip install petsc4py
You need to have the following software properly installed in order to build PETSc for Python:
The PETSc for Python package is available for download at the Python Package Index. You can use curl or wget to get a release tarball.
$ curl -LO https://pypi.io/packages/source/p/petsc4py/petsc4py-X.Y.Z.tar.gz
$ wget https://pypi.io/packages/source/p/petsc4py/petsc4py-X.Y.Z.tar.gz
After unpacking the release tarball:
$ tar -zxf petsc4py-X.Y.Z.tar.gz $ cd petsc4py-X.Y.Z
the distribution is ready for building.
NOTE:
$ export MACOSX_DEPLOYMENT_TARGET=10.6 $ export SDKROOT=/ $ export ARCHFLAGS='-arch x86_64'
Some environment configuration is needed to inform the location of PETSc. You can set (using setenv, export or what applies to you shell or system) the environment variables PETSC_DIR, and PETSC_ARCH indicating where you have built/installed PETSc:
$ export PETSC_DIR=/usr/local/petsc $ export PETSC_ARCH=arch-linux2-c-opt
Alternatively, you can edit the file setup.cfg and provide the required information below the [config] section:
[config] petsc_dir = /usr/local/petsc petsc_arch = arch-linux2-c-opt ...
Finally, you can build the distribution by typing:
$ python setup.py build
After building, the distribution is ready for installation.
If you have root privileges (either by log-in as the root user of by using sudo) and you want to install PETSc for Python in your system for all users, just do:
$ python setup.py install
The previous steps will install the petsc4py package at standard location prefix/lib/pythonX.Y/site-packages.
If you do not have root privileges or you want to install PETSc for Python for your private use, just do:
$ python setup.py install --user
XXX To be written … Any contribution welcome!
If PETSc for Python been significant to a project that leads to an academic publication, please acknowledge that fact by citing the project.
Lisandro Dalcin
2021, Lisandro Dalcin
January 13, 2021 | 3.1 |