[petsc-users] Nullspaces
Marco Cisternino
marco.cisternino at optimad.it
Wed Jan 5 10:21:20 CST 2022
Hello Jose and Stefano.
Thank you, Jose for your hints.
I computed the two smallest eigenvalues of my operator and they are tiny but not zero.
The smallest 0 eigenvalue is = (4.71506e-08, 0) with abs error = 3.95575e-07
The smallest 1 eigenvalue is = (1.95628e-07, 0) with abs error = 4.048e-07
As Stefano remarked, I would have expected much tinier values, closer to zero.
Probably something is wrong in what I do:
EPS eps;
EPSCreate(PETSC_COMM_WORLD, &eps);
EPSSetOperators( eps, matrix, NULL );
EPSSetWhichEigenpairs(eps, EPS_SMALLEST_MAGNITUDE);
EPSSetProblemType( eps, EPS_NHEP );
EPSSetConvergenceTest(eps,EPS_CONV_ABS);
EPSSetTolerances(eps, 1.0e-10, 1000);
EPSSetDimensions(eps,2,PETSC_DEFAULT,PETSC_DEFAULT);
EPSSetFromOptions( eps );
EPSSolve( eps );
Even commenting " EPSSetTolerances(eps, 1.0e-10, 1000);" and use default values, the results are exactly the same.
Am I correctly computing the 2 smallest eigenvalues?
They should be zeros but they are not. Any suggestions about how understanding why?
In a previous email Mark remarked: "Also you say you divide by the cell volume. Maybe I am not understanding this but that is basically diagonal scaling and that will change the null space (ie, not a constant anymore)", therefore why does the null space built with MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, nullptr, &nullspace); passes the MatNullSpaceTest??
Thank you all!
Marco Cisternino
-----Original Message-----
From: Jose E. Roman <jroman at dsic.upv.es>
Sent: martedì 4 gennaio 2022 19:30
To: Marco Cisternino <marco.cisternino at optimad.it>
Cc: Stefano Zampini <stefano.zampini at gmail.com>; petsc-users <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Nullspaces
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