python interface to PETSC

Matthew Knepley knepley at
Thu Oct 30 17:59:30 CDT 2008

On Thu, Oct 30, 2008 at 5:34 PM, Nichols A. Romero
<naromero at> wrote:
> Hi,
> I am post-doc in LCF working on scaling a real-space DFT code called GPAW.
> This code is a mixture of Python and C.
> The PETSC webpage states that there is now a Python interface but I could
> not find a lot of documentation about it in the manual. I did download the
> PETSC tarball and see that there is a python directory.

The PETSc Python interface is maintained by Lisandro Dalcin. You can have it
automatically downloaded by configuring with --with-petsc4py. It has bindings
for all functions. I am not sure if there is a manual, but he reads this list.

> Right now the GPAW uses NumPy for basic array manipulation, element-wise
> dot products, and other simple manipulation. The time consuming part of
> the GPAW is spent in the solution of a sparse eigenvalue problem.
> H*Psi=lambda*S*Psi

You probably want SLEPc, which also has slepc4py. They use Numpy as well.
I think it would not be hard to formulate your problem for SLEPc. You can
use a MatShell object for your H*Psi product, and I believe use a Python
function for it with Lisandro's awesome wrappers.


> The Hamiltonian matrix (H) is not stored at all, only H*Psi products are
> computed (Psi are the eigenvectors). It would seem like PETSc could be
> helpful for solving this problem.
> Is there a python interface to all the PETSc functions?
> Nichols A. Romero, Ph.D.
> Argonne Leadership Computing Facility
> Argonne National Laboratory
> Building 360 Room L-146
> 9700 South Cass Avenue
> Argonne, IL 60490
> (630) 252-3441

What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener

More information about the petsc-users mailing list