def help(args=None): import sys # program name try: prog = sys.argv[0] except Exception: prog = getattr(sys, 'executable', 'python') # arguments if args is None: args = sys.argv[1:] elif isinstance(args, str): args = args.split() else: args = [str(a) for a in args] # initialization import slepc4py slepc4py.init([prog, '-help'] + args) from slepc4py import SLEPc # and finally ... COMM = SLEPc.COMM_SELF if 'eps' in args: eps = SLEPc.EPS().create(comm=COMM) eps.setFromOptions() eps.destroy() del eps if 'svd' in args: svd = SLEPc.SVD().create(comm=COMM) svd.setFromOptions() svd.destroy() del svd if 'pep' in args: pep = SLEPc.PEP().create(comm=COMM) pep.setFromOptions() pep.destroy() del pep if 'nep' in args: nep = SLEPc.NEP().create(comm=COMM) nep.setFromOptions() nep.destroy() del nep if 'mfn' in args: mfn = SLEPc.MFN().create(comm=COMM) mfn.setFromOptions() mfn.destroy() del mfn if 'st' in args: st = SLEPc.ST().create(comm=COMM) st.setFromOptions() st.destroy() del st if 'bv' in args: bv = SLEPc.BV().create(comm=COMM) bv.setFromOptions() bv.destroy() del bv if 'rg' in args: rg = SLEPc.RG().create(comm=COMM) rg.setFromOptions() rg.destroy() del rg if 'fn' in args: fn = SLEPc.FN().create(comm=COMM) fn.setFromOptions() fn.destroy() del fn if 'ds' in args: ds = SLEPc.DS().create(comm=COMM) ds.setFromOptions() ds.destroy() del ds
n = 1 if rank == 0 else 0 aux = PETSc.Vec().createMPI((n, PETSc.DECIDE), comm=comm) if rank == 0: aux[0] = x[0] aux.assemble() x0 = aux.sum() sign = x0 / abs(x0) x.scale(sign) opts = PETSc.Options() n = opts.getInt('n', 128) kappa = opts.getReal('kappa', 1.0) pde = MyPDE(kappa, 1.0 / n) # Setup the solver nep = SLEPc.NEP().create() F = PETSc.Mat().create() F.setSizes([n, n]) F.setType('aij') F.setPreallocationNNZ(3) F.setUp() nep.setFunction(pde.formFunction, F) J = PETSc.Mat().create() J.setSizes([n, n]) J.setType('aij') J.setPreallocationNNZ(3) J.setUp() nep.setJacobian(pde.formJacobian, J) nep.setTolerances(tol=1e-9)