# SLEPc: EPSSolve ERROR

**URL:** <https://community.freefem.org/t/slepc-epssolve-error/2887>\
**Category:** General Discussion\
**Created:** [January 17, 2024, 10:20am UTC](https://community.freefem.org/t/slepc-epssolve-error/2887 "2024-01-17T10:20:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![WeiQLiu](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/weiqliu/32/1043_2.png) [@WeiQLiu](https://community.freefem.org/u/WeiQLiu)\
**Post date:** [January 17, 2024, 10:20am UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/1 "2024-01-17T10:20:10Z")

</div>

Dear all,  
I’m currently reproducing a paper: [Sabino et.al 2020](https://www.cambridge.org/core/journals/journal-of-fluid-mechanics/article/abs/vortexinduced-vibration-prediction-via-an-impedance-criterion/4B8ABEAAE22F916624ADA0FB138CAC25). It’s background in physics is the vortex-induced vibration of a spring-mounted, damped, rigid circular cylinder, immersed in a Newtonian viscous flow and capable of moving in the direction orthogonal to the unperturbed flow.

 ![sabino2020](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/2/2f3b23fd60ec694314e9c2a3f6908011603c6b20.jpeg)  
I wrote a similar program based on this script——[navier-stokes-2d-SLEPc-complex.edp](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-SLEPc-complex.edp), but it made some errors that I couldn’t understand.  
 ![error1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/9/96f721e82f6dc1a82deb218cf9684501e5bf3a59.jpeg)

This is my script and log files:  
[wqliu.zip](https://community.freefem.org/uploads/short-url/kK4I425b8eAazn75syeXFBg13qD.zip) (688.2 KB)  
I have simplified the script as much as possible. I guess the error is in the matrix entered into  
`EPSSolve()`. But I don’t know the exact reason for the error.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 17, 2024, 2:02pm UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/2 "2024-01-17T14:02:24Z")

</div>

Please update your FreeFEM/PETSc installation if you want to feed a `MatNest` to `EPSSolve()` directly, or use an intermediate call to `MatConvert()`.

---

<div class="post-metadata">

**Author:** ![WeiQLiu](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/weiqliu/32/1043_2.png) [@WeiQLiu](https://community.freefem.org/u/WeiQLiu)\
**Post date:** [January 18, 2024, 3:46am UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/3 "2024-01-18T03:46:50Z")

</div>

Dear [@prj](https://community.freefem.org/u/prj/summary),  
Thank you very much for your quick reply.

1. My FreeFem++ version is 4.13 and I’m running on Windows 11. Although the FreeFem++ official website has been updated to version 4.14, it is currently a pre-release, and there is no windows version. In fact, I did find that my macro\_ddm.idp file was different from that in [FreeFem-sources](https://github.com/FreeFem/FreeFem-sources/blob/master/idp/macro_ddm.idp). For example, the difference between `macro DmeshBuild()` and `DmeshCreate()`. I’m not sure what the difference is, but I think the functionality embodied in the scripts is the same.
2. Thanks again for your help. Although I don’t understand the meaning of `MatNest` and `MatConvert()`, my script is running. There may still be some problems with the scripts, but I will continue to debug it. In addition , can you help me understand the meaning of `MatNest` and `MatConvert()`.

Sincerely,  
wqliu.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 18, 2024, 6:45am UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/4 "2024-01-18T06:45:26Z")

</div>

Here are some references: [FreeFem-sources/examples/hpddm/laplace-lagrange-PETSc.edp at 220957ed86797a6c1ed771f1fe1c27078e94f28a · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/220957ed86797a6c1ed771f1fe1c27078e94f28a/examples/hpddm/laplace-lagrange-PETSc.edp#L49) and [MATNEST — PETSc v3.20.3-461-g585a01bd688 documentation](https://petsc.org/main/manualpages/Mat/MATNEST/).

---

<div class="post-metadata">

**Author:** ![WeiQLiu](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/weiqliu/32/1043_2.png) [@WeiQLiu](https://community.freefem.org/u/WeiQLiu)\
**Post date:** [January 19, 2024, 7:16am UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/5 "2024-01-19T07:16:10Z")

</div>

Dear prj,  
Thank you so much for your assistance. I think the scripts has the effect I wanted. And these references help me understand `MatConvert()` and `MatNest`. But now I have some new questions. In my script, `EPSSolve()` take the following `sparams`:

> string params = " -eps\_tol 1.0e-10 " +  
> " -eps\_nev " + nev + " " +  
> " -eps\_type krylovschur " +  
> " -st\_type sinvert " +  
> // " -st\_pc\_type lu " +  
> " -st\_pc\_type cholesky " +  
> // " -st\_matstructure same " +  
> // " -eps\_monitor\_all " +  
> // " -eps\_view " +  
> // " -eps\_view\_value " +  
> " -eps\_target " + real(SHIFT) + “+” + imag(SHIFT) + “i” + " " +  
> " -eps\_gen\_nonhermitian"  
> ;  
> int k = EPSSolve(A, B, array = EigenVEC, values = val, sparams = params);

Of course, during testing I found that iterations would not converge if I used ` -st_pc_type cholesky`. So I used ` -st_pc_type lu`, and I got really good results because of it.  
I can understand the meaning of some of these `sparams`, but these `sparams` are transferred from other scripts. Is there a specific reference to introduce all the `sparams` of `EPSSolve()`?

Sincerely,  
wqliu

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 19, 2024, 2:17pm UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/6 "2024-01-19T14:17:58Z")

</div>

You can have a look at the SLEPc and PETSc users manual, e.g., [https://slepc.upv.es/documentation/slepc.pdf](https://slepc.upv.es/documentation/slepc.pdf).

---

<div class="post-metadata">

**Author:** ![WeiQLiu](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/weiqliu/32/1043_2.png) [@WeiQLiu](https://community.freefem.org/u/WeiQLiu)\
**Post date:** [January 19, 2024, 2:22pm UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/7 "2024-01-19T14:22:34Z")

</div>

Ok, I get it. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![WeiQLiu](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/weiqliu/32/1043_2.png) [@WeiQLiu](https://community.freefem.org/u/WeiQLiu)\
**Post date:** [March 28, 2024, 9:17am UTC](https://community.freefem.org/t/slepc-epssolve-error/2887/8 "2024-03-28T09:17:20Z")

</div>

Dear prj,

I have a new question about EPSSolve. I;m reading this help manual [slepc.pdf](https://slepc.upv.es/documentation/slepc.pdf). I find the Advanced Usage of EPS described in Chapter 2, section 6. Section 2.6.1 is about entering an initial guess into EPS.

This gives me a little insight that I can assign the calculated eigenmode to the next eigenvalue as an initial guess. In SLEPc, they provide the command `EPSSetInitialSpace(EPS eps, PetscInt n, Vec is[])`. However, I did not find similar examples in FreeFem.

In the source file FreeFem-sources/plugin/mpi/SLEPc-code.hpp, there have the command `EPSSetInitialSpace()`– [EPSSetInitialSpace()](https://github.com/FreeFem/FreeFem-sources/blob/2b2052ae9ec86ae7f0048607b20084234e03858f/plugin/mpi/SLEPc-code.hpp#L348). Therefore, I believe it is possible to add an initial guess for `EPSSolve()` in FreeFem. Can you give me a typical example. Thank you in advance!
