<div dir="ltr">Hi Jose,<div><br></div><div>Thank you for your answer. The problem now is solved with setting <span style="font-size:12.8000001907349px">EPS_LARGEST_MAGNITUDE.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Xujun</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 7, 2015 at 11:53 AM, Jose E. Roman <span dir="ltr"><<a href="mailto:jroman@dsic.upv.es" target="_blank">jroman@dsic.upv.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The power method only works with which=EPS_LARGEST_MAGNITUDE (or which=EPS_TARGET_MAGNITUDE if doing shift-and-invert). The rationale is that the power iteration converges to the dominant eigenvalue (the one with largest absolute value).<br>
<span class="HOEnZb"><font color="#888888"><br>
Jose<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> El 7/8/2015, a las 18:21, Xujun Zhao <<a href="mailto:xzhao99@gmail.com">xzhao99@gmail.com</a>> escribió:<br>
><br>
> Hi all,<br>
><br>
> I am solving the max eigenvalue of a Shell matrix using SLEPc. the Shell operation is set MATOP_MULT with user-defined function u = M*f. It works with the Krylov-Schur and Arnoldi method, but fails when I use Power Iteration method and several others. This is strange, because some of those are supposed to work with any type of problem.<br>
><br>
> I also wrote a power iteration algorithm by myself, and it works well and obtains the same results with that from Krylov_Schur. I am curious why this doesn't work is SLEPc. The following are my code and error messages:<br>
><br>
> ----------------------------------------------------------------------------------<br>
> ierr = MatSetFromOptions(M); CHKERRQ(ierr);<br>
> ierr = MatShellSetOperation(M,MATOP_MULT,(void(*)())_MatMult_Stokes);CHKERRQ(ierr);<br>
><br>
> ierr = PetscPrintf(PETSC_COMM_WORLD,"\n");<br>
> printf("--->test: n = %d, N = %d, rank = %d\n",n, N, (int)rank);<br>
><br>
><br>
> /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br>
> Create the eigensolver and set various options<br>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */<br>
><br>
> ierr = EPSCreate(PETSC_COMM_WORLD,&eps); CHKERRQ(ierr);<br>
> ierr = EPSSetOperators(eps,M,NULL); CHKERRQ(ierr);<br>
> ierr = EPSSetProblemType(eps,EPS_HEP); CHKERRQ(ierr);<br>
><br>
><br>
> // EPSKRYLOVSCHUR(Default)/EPSARNOLDI/<br>
> // does NOT work: EPSPOWER/EPSLANCZOS/EPSSUBSPACE<br>
> ierr = EPSSetType(eps,EPSPOWER); CHKERRQ(ierr);<br>
><br>
><br>
> /* Select portion of spectrum */<br>
><br>
> if(option=="smallest") // LOBPCG for smallest eigenvalue problem!<br>
> { ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);CHKERRQ(ierr); }<br>
> else if(option=="largest")<br>
> { ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL); CHKERRQ(ierr); }<br>
> else<br>
> { ierr = EPSSetFromOptions(eps); CHKERRQ(ierr); }<br>
> // end if-else<br>
><br>
><br>
> // Set the tolerance and maximum iteration<br>
> ierr = EPSSetTolerances(eps, tol, maxits); CHKERRQ(ierr);<br>
> ierr = PetscPrintf(PETSC_COMM_WORLD,"EPS tol = %f, maxits = %d\n",tol,maxits);CHKERRQ(ierr);<br>
><br>
><br>
> /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br>
> Solve the eigensystem and get the solution<br>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */<br>
><br>
> ierr = PetscPrintf(PETSC_COMM_WORLD,"EPS solve starts ...\n");CHKERRQ(ierr);<br>
> ierr = EPSSolve(eps);CHKERRQ(ierr);<br>
><br>
> ----------------------------------------------------------------------------------<br>
><br>
><br>
> EPS tol = 0.000001, maxits = 100<br>
><br>
> EPS solve starts ...<br>
><br>
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>
><br>
> [0]PETSC ERROR: Wrong value of eps->which<br>
><br>
> [0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>
><br>
> [0]PETSC ERROR: Petsc Release Version 3.5.4, May, 23, 2015<br>
><br>
> [0]PETSC ERROR: ./example-opt on a arch-darwin-c-opt named <a href="http://mcswl121.mcs.anl.gov" rel="noreferrer" target="_blank">mcswl121.mcs.anl.gov</a> by xzhao Fri Aug 7 10:31:38 2015<br>
><br>
> [0]PETSC ERROR: Configure options --with-cc=gcc-4.9 --with-cxx=g++-4.9 --with-fc=gfortran-4.9 --with-cxx-dialect=C++11 --download-mpich --download-fblaslapack --download-scalapack --download-mumps --download-superlu_dist --download-hypre --download-ml --download-parmetis --download-metis --download-triangle --download-chaco --download-elemental --with-debugging=0<br>
><br>
> [0]PETSC ERROR: #1 EPSSetUp_Power() line 64 in /Users/xzhao/software/slepc/slepc-3.5.4/src/eps/impls/power/power.c<br>
><br>
> [0]PETSC ERROR: #2 EPSSetUp() line 120 in /Users/xzhao/software/slepc/slepc-3.5.4/src/eps/interface/epssetup.c<br>
><br>
> [0]PETSC ERROR: #3 EPSSolve() line 88 in /Users/xzhao/software/slepc/slepc-3.5.4/src/eps/interface/epssolve.c<br>
><br>
> [0]PETSC ERROR: #4 compute_eigenvalue() line 318 in brownian_system.C<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>