[petsc-users] How to use PETSc4py/SLEPc4py to solve an eigenvalue problem in parallel

Mengqi Zhang jollage at gmail.com
Wed Oct 29 08:56:39 CDT 2014


Hi, Jose


 Thanks for your reply.

I will specify the problem more exactly. I want to solve a big generalized
eigenvalue problem. The matrices are sparse. My question lies on how to
allocate the matrices among the processors. Do I have to do it by myself?
Or there is a routine to do so? I notice that one should do something like

from petsc4py import PETSc A = PETSc.Mat().create() A.setType('aij')
A.setSizes([M,N])  A.setPreallocationNNZ([diag_nz, offdiag_nz]) #
optional A.setUp()

I have several question regarding these lines.

(1) I presume M and N are the dimension of the matrix. Then how do the
processors divide the matrix? I guess setPreallocationNNZ does the
allocation of the matrix among the processors. What does nz mean here? Why
here appears diag and offdiag?

(2) I actually saw somewhere else that people use A.setPreallocationNNZ(5),
with a single parameter 5. What does 5 mean here?

(3) I want to make sure that the matrix so generated is sparse (since it
uses aij). It is sparse right? I feel it tricky since if the matrix is
stored as sparse, will the allocation/parallelization destroy the
efficiency of sparse matrix?



After the matrix is set up, I would like to use SLEPc4py to solve the
generalized eigenvalue problem. The example code I got online is like

E = SLEPc.EPS();
E.create()E.setOperators(A)E.setProblemType(SLEPc.EPS.ProblemType.GNHEP)E.setFromOptions()E.solve()

I'm afraid this script is not designed for the parallel computation since
in the options there is no indication of parallelization. Do you know how
to set it up?


Thank you very much for your time. I appreciate it very much.

Best,

Mengqi

2014-10-26 15:21 GMT-02:00 Jose E. Roman <jroman at dsic.upv.es>:

>
> El 26/10/2014, a las 17:10, Mengqi Zhang escribió:
>
> > Dear all PETSc users,
> >
> > I'm new to PETSc/SLEPc. And I'm currently trying to use
> Python/PETSc4py/SLEPc4py to solve a big generalized eigenvalue problem, A x
> = B lambda x.
> >
> > After several days' digging and trying, I can write a script for solving
> a smaller eigenvalue problem locally, but when the problem size increases,
> I realize I should go parallel. My question is how to do it in parallel?
> How could I preallocate the matrices among the processors? I presume there
> should be a way to do that, but I couldn't find a clear guide on the
> Internet.
> >
> > Currently, the matrices are implemented locally, and then I use
> >
> > E = SLEPc.EPS(); E.create()
> >
> > E.setOperators(A,B)
> >
> > E.setProblemType(SLEPc.EPS.ProblemType.GNHEP)
> >
> > E.setFromOptions()
> >
> > to locally solve the eigenvalue problem.
> >
> >
> >
> > Could you help me and guide me to set the code up?  Any suggestion is
> welcomed and appreciated. Thank you very much.
> >
> >
> >
> > Best regards,
> >
> > Mengqi
> >
>
> You may want to do A.setPreallocationNNZ(5) or something like that.
> Also, take into account that in generalized eigenproblems you will
> probably want to use a parallel linear solver, see discussion in section
> 3.4.1 of SLEPc's users guide.
>
> Jose
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141029/ca8b2507/attachment.html>


More information about the petsc-users mailing list