[petsc-users] Nullspaces
Jose E. Roman
jroman at dsic.upv.es
Tue Jan 4 12:30:07 CST 2022
To compute more than one eigenpair, call EPSSetDimensions(eps,nev,PETSC_DEFAULT,PETSC_DEFAULT).
To compute zero eigenvalues you may want to use an absolute convergence criterion, with EPSSetConvergenceTest(eps,EPS_CONV_ABS), but then a tolerance of 1e-12 is probably too small. You can try without this, anyway.
Jose
> El 4 ene 2022, a las 18:44, Marco Cisternino <marco.cisternino at optimad.it> escribió:
>
> Hello Stefano and thank you for your support.
> I never used SLEPc before but I did this:
> right after the matrix loading from file I added the following lines to my shared tiny code
> MatLoad(matrix, v);
>
> EPS eps;
> EPSCreate(PETSC_COMM_WORLD, &eps);
> EPSSetOperators( eps, matrix, NULL );
> EPSSetWhichEigenpairs(eps, EPS_SMALLEST_MAGNITUDE);
> EPSSetProblemType( eps, EPS_NHEP );
> EPSSetTolerances(eps, 1.0e-12, 1000);
> EPSSetFromOptions( eps );
> EPSSolve( eps );
>
> Vec xr, xi; /* eigenvector, x */
> PetscScalar kr, ki; /* eigenvalue, k */
> PetscInt j, nconv;
> PetscReal error;
> EPSGetConverged( eps, &nconv );
> for (j=0; j<nconv; j++) {
> EPSGetEigenpair( eps, j, &kr, &ki, xr, xi );
> EPSComputeError( eps, j, EPS_ERROR_ABSOLUTE, &error );
> std::cout << "The smallest eigenvalue is = (" << kr << ", " << ki << ") with error = " << error << std::endl;
> }
>
> I launched using
> mpirun -n 1 ./testnullspace -eps_monitor
>
> and the output is
>
> 1 EPS nconv=0 first unconverged value (error) -1499.29 (6.57994794e+01)
> 2 EPS nconv=0 first unconverged value (error) -647.468 (5.39939262e+01)
> 3 EPS nconv=0 first unconverged value (error) -177.157 (9.49337698e+01)
> 4 EPS nconv=0 first unconverged value (error) 59.6771 (1.62531943e+02)
> 5 EPS nconv=0 first unconverged value (error) 41.755 (1.41965990e+02)
> 6 EPS nconv=0 first unconverged value (error) -11.5462 (3.60453662e+02)
> 7 EPS nconv=0 first unconverged value (error) -6.04493 (4.60890030e+02)
> 8 EPS nconv=0 first unconverged value (error) -22.7362 (8.67630086e+01)
> 9 EPS nconv=0 first unconverged value (error) -12.9637 (1.08507821e+02)
> 10 EPS nconv=0 first unconverged value (error) 7.7234 (1.53561979e+02)
> …
> 111 EPS nconv=0 first unconverged value (error) -2.27e-08 (6.84762319e+00)
> 112 EPS nconv=0 first unconverged value (error) -2.60619e-08 (4.45245528e+00)
> 113 EPS nconv=0 first unconverged value (error) -5.49592e-09 (1.87798984e+01)
> 114 EPS nconv=0 first unconverged value (error) -9.9456e-09 (7.96711076e+00)
> 115 EPS nconv=0 first unconverged value (error) -1.89779e-08 (4.15471472e+00)
> 116 EPS nconv=0 first unconverged value (error) -2.05288e-08 (2.52953194e+00)
> 117 EPS nconv=0 first unconverged value (error) -2.02919e-08 (2.90090711e+00)
> 118 EPS nconv=0 first unconverged value (error) -3.8706e-08 (8.03595736e-01)
> 119 EPS nconv=1 first unconverged value (error) -61751.8 (9.58036571e-07)
> Computed 1 pairs
> The smallest eigenvalue is = (-3.8706e-08, 0) with error = 4.9707e-07
>
> Am I using SLEPc in the right way at least for the first smallest eigenvalue? If I’m on the right way I can find out how to compute the second one.
>
> Thanks a lot
>
> Marco Cisternino
More information about the petsc-users
mailing list