Checkpointing and EPSMonitorSet

Issue #22 resolved
Niall Moran created an issue

I would like get checkpointing working for some exact diagonalisation calculations. It seems one way would be to write a custom monitor method which saves any states which are converged to disk and then to start from these initial space. It seems that currently (as of 3.7.0) there is no way to access the SLEPc EPSMonitorSet function via the python interface.

Is there a reason this function has not been wrapped? It seems it might be problematic passing a reference to a python function to a C interface might be problematic. In petsc4py, it appears that for shell matrces petsc has a python matrix type for this.

Perhaps there is a simpler way to get checkpointing working?

Any help or advice is greatly appreciated.

Niall.

Comments (4)

  1. Jose E. Roman

    @nmoran In the branch jose/stopping I have added a commit that allows to set a user-defined stopping test function. With this you could be able to do basic checkpointing with something like this:

    def stopping(eps, its, max_it, nconv, nev):
        if nconv >= nev: return SLEPc.EPS.ConvergedReason.CONVERGED_TOL
        if its >= max_it: return SLEPc.EPS.ConvergedReason.DIVERGED_ITS
        if (its % 10) == 0:
            if nconv > 5:
                # checkpoint
                viewer = PETSc.Viewer().createBinary('checkpoint.dat', 'w')
                V = eps.getBV()
                for i in range(nconv):
                    v = V.getColumn(i)
                    viewer(v)
                    V.restoreColumn(i,v)
    E.setStoppingTest(stopping)
    

    Note that within this function you cannot call EPS.getConverged or EPS.getEigenvector, but you can get access to eigenvectors via the BV (only in Hermitian problems). Let us know if this is useful for you.

  2. Lisandro Dalcin

    I added support for monitors. I reworked the stopping implementation a little bit. Pushed to branch maint and merged into master.

  3. Log in to comment