# Dominant Eigen Value Computation

**URL:** https://community.freefem.org/t/dominant-eigen-value-computation/1493
**Category:** General Discussion
**Created:** [February 13, 2022, 6:03pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493 "2022-02-13T18:03:34Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)
#### Post date: [February 13, 2022, 6:03pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/1 "2022-02-13T18:03:34Z")

</div>

For eigen value computation in FreeFem++, some guess shift eigen value needs to be specified.

If I am working with a system, where there is no idea about dominant eigen value, what shift eigen value should be used for calculation of dominant eigen values?

---

<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: [February 13, 2022, 6:57pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/2 "2022-02-13T18:57:23Z")

</div>

You don’t need a shift.

---

<div class="post-metadata">

### Author: ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)
#### Post date: [February 14, 2022, 4:04am UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/3 "2022-02-14T04:04:54Z")

</div>

Say, I have already computed the base flow solution.

Then, I am trying to use the following code for dominant eigen value computation: [FreeFem-sources/navier-stokes-2d-SLEPc-complex.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-SLEPc-complex.edp).

To run the above code without a complex shift value, the code should be run without line no-47 (as no shift value needs to be specified) and line no-50.

So, string params (as defined in lines 48 & 49) should be:  
string params = "-eps\_tol 1.0e-6 -eps\_nev " + nev + " " +  
"-eps\_type krylovschur -st\_type sinvert -eps\_monitor\_all ";

Am I correct?

---

<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: [February 14, 2022, 2:23pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/4 "2022-02-14T14:23:29Z")

</div>

You don’t need `-st_type sinvert` if you are looking for the dominant eigenmode (`-eps_largest_magnitude`). If you use `-st_type sinvert`, then you must use as a shift something that is close to what you believe is the dominant eigenmode (`-eps_target_magnitude`).

---

<div class="post-metadata">

### Author: ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)
#### Post date: [February 14, 2022, 5:55pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/5 "2022-02-14T17:55:26Z")

</div>

I used the following statement:

string params = "-eps\_tol 1.0e-6 -eps\_nev " + nev + " " +  
"-eps\_type krylovschur -eps\_largest\_magnitude -eps\_monitor\_all ";

And got the following error:

 ![DomiantEigen_Error](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/0ce1c14379506d79f8c8a31939917eff54eb346a.jpeg)

---

<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: [February 14, 2022, 6:49pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/6 "2022-02-14T18:49:54Z")

</div>

You’ll have to read the MUMPS documentation if you don’t understand what this error means.

---

<div class="post-metadata">

### Author: ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)
#### Post date: [February 16, 2022, 6:31pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/7 "2022-02-16T18:31:26Z")

</div>

I still could not figure out why the error is coming.

What options are available for use with “EPSSolve” in FreeFEM? Is there any documentation other than this: [Eigen value problems](https://doc.freefem.org/models/eigen-value-problems.html)?

---

<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: [February 16, 2022, 9:23pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/8 "2022-02-16T21:23:16Z")

</div>

The link you mentioned is about ARPACK, not SLEPc. If you want SLEPc documentation, you can go to [SLEPc - Documentation :: Manual](https://slepc.upv.es/documentation/).

---

<div class="post-metadata">

### Author: ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)
#### Post date: [February 17, 2022, 6:22pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/9 "2022-02-17T18:22:10Z")

</div>

I am going through the documentation.

In the meantime, I tried the following without using any shift value:

string params = "-eps\_tol 1.0e-6 -eps\_nev " + nev + " " +  
"-eps\_type krylovschur -st\_type sinvert -eps\_monitor\_all ";

int k = EPSSolve(J,M, vectors = vec, values = val, sparams = params);

This is not giving any error and giving results as before. I do not know as no shift value is being mentioned, if it is taking any default shift value of σ = 0+0i.

---

<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: [February 18, 2022, 1:48pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/10 "2022-02-18T13:48:35Z")

</div>

Use `-eps_view` to view what is being used by SLEPc.

---

<div class="post-metadata">

### Author: ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)
#### Post date: [February 23, 2022, 7:12pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/11 "2022-02-23T19:12:21Z")

</div>

For the eigen computation, I am carrying out, “PETSc-complex” is being used.

What parameter options are available for “PETSc-complex” like “-eps\_type krylovschur”, “-st\_type sinvert”, “-eps\_monitor\_all”, etc?

To check what parameter options are available in “PETSc-complex”, I tried opening the file “PETSc-complex.dll” in the directory where FreeFEM has been installed. But I could not open the file “PETSc-complex.dll”.

Where can I find what parameter options are available for “PETSc-complex.dll”? Any documentation is available?

---

<div class="post-metadata">

### Author: ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)
#### Post date: [February 23, 2022, 8:10pm UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/12 "2022-02-23T20:10:16Z")

</div>

Dear @D_N_Sarkar ,

You can use the shift-invert techniquefor hydrodynamic stability problems. You can scan the relevant portion of the spectrum with repeated eigenvalue calculation with different shifts. The shifts (eigenvalue geusses) can be chosen based on literature data on problems that are similar to yours.

You can find the basic options of `EPSSolve` in the [SLEPc users manual](https://slepc.upv.es/documentation/slepc.pdf).

---

<div class="post-metadata">

### Author: ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)
#### Post date: [February 25, 2022, 9:03am UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/14 "2022-02-25T09:03:05Z")

</div>

I am running the given example: [FreeFem-sources/navier-stokes-2d-SLEPc-complex.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-SLEPc-complex.edp).  
This solved example uses “PETSc-complex”.

This problem works with the following:  
string params = "-eps\_tol 1.0e-6 -eps\_nev " + nev + " " +  
"-eps\_type krylovschur -st\_type sinvert -eps\_monitor\_all " +  
"-eps\_target " + real(s) + “+” + imag(s) + “i”;

I followed the given SLEPc documentation: [https://slepc.upv.es/documentation/slepc.pdf](https://slepc.upv.es/documentation/slepc.pdf).

In the SLEPc documentation, there are options like: -eps\_largest\_magnitude, -eps\_smallest\_magnitude, -eps\_smallest\_real, etc. These three are used as follows:

string params = "-eps\_tol 1.0e-10 -eps\_nev " + nev + " " +  
"-eps\_type krylovschur -eps\_largest\_magnitude -eps\_monitor\_all ";  
int k = EPSSolve(J, M, vectors = vec, values = val, sparams = params);  
The following error came:

 ![-eps_largest_magnitude](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/cb72b794e6ab5d8d1cc39ad9894132b9fea7bf16.jpeg)

string params = "-eps\_tol 1.0e-10 -eps\_nev " + nev + " " +  
"-eps\_type krylovschur -eps\_smallest\_magnitude -eps\_monitor\_all ";  
int k = EPSSolve(J, M, vectors = vec, values = val, sparams = params);  
The following error came:

 ![-eps_smallest_magnitude](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/b/b9de67d9ea1c5da8a0066808f4d70396d15c3eb4.jpeg)

string params = "-eps\_tol 1.0e-10 -eps\_nev " + nev + " " +  
"-eps\_type krylovschur -eps\_smallest\_real -eps\_monitor\_all ";  
int k = EPSSolve(J, M, vectors = vec, values = val, sparams = params);  
The following error came:

 ![-eps_smallest_real](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/a/a6143feac94f046db22a28434b8163b8eea676de.jpeg)

I am using FreeFEM version 4.9 on Windows 10. I do not understand if the option “-st\_type sinvert” is working successfully, why SLEPc options such as “-eps\_largest\_magnitude”, “-eps\_smallest\_magnitude”, and “-eps\_smallest\_real” are giving error.

---

<div class="post-metadata">

### Author: ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)
#### Post date: [February 25, 2022, 9:12am UTC](https://community.freefem.org/t/dominant-eigen-value-computation/1493/15 "2022-02-25T09:12:24Z")

</div>

I think the reason for this is that in the case of the LNS eigenvalue problem, your B matrix is singular. Therefore, I think you need to use `-st_type sinvert -eps_target`, and you cannot use options as `-eps_smallest_magnitude` instead.
