Eigenvalues of Stiffness matrix

Asked by Lutz Gross

Is there an easy way to calculate the smallest eigenvalues of the stiffness matrix used by a PDE?

Question information

Language:
English Edit question
Status:
Solved
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Solved by:
Lutz Gross
Solved:
Last query:
Last reply:
Revision history for this message
Bob (caltinay) said :
#1

This can be done with the help of scipy for single-rank runs (no MPI). Assuming 'pde' is your LinearPDE instance:

from scipy.io import mmread
from scipy.sparse.linalg import eigs

pde.getOperator().saveMM('matrix.mtx')
mtx=mmread('matrix.mtx')
print(eigs(mtx, k=5, return_eigenvectors=False, which='SM'))

For a description of 'eigs' see here:
http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.eigs.html#scipy.sparse.linalg.eigs

Revision history for this message
Lutz Gross (l-gross) said :
#2

That works. Two things to add

a) make sure that you do';t use the DIRECT solver as for this case saveMM seams not work.
b) pay attention to the remark "ARPACK is generally better at finding large values than small values. If small eigenvalues are desired, consider using shift-invert mode for better performance. " in the scipy.sparse.linalg.eigs documentation.

Revision history for this message
ceguo (hhh-guo) said :
#3

Hi,

It's interesting. But is there other more convenient way (in memory) to convert operator to numpy matrix in stead of using this hard-disk i/o?

Ning

Revision history for this message
Bob (caltinay) said :
#4

At the moment, escript does not expose operator internals to the python layer as the focus has been running large-scale MPI-based simulations with distributed operators.

Having said that, it would be relatively easy to add wrappers for the matrix data structure (for single-rank matrices) if there was a use case that would benefit from it.