# SLEPc different values with -np 1 vs -np 2+

**URL:** https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663
**Category:** General Discussion
**Created:** [April 12, 2022, 10:00am UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663 "2022-04-12T10:00:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)
#### Post date: [April 12, 2022, 10:00am UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663/1 "2022-04-12T10:00:38Z")

</div>

Dear forum,

I am using FreeFEM++ v4.8 for Windows to perform a stability analysis with the SLEPc library. If I set -np 1 and I repeat the simulations without changing anything else I get everytime the same results. When I change -np 2 and I repeat the simulations without changing anything else I get different results and I don’t understand why. I attach the code without the equations:

> mesh Th=…  
> fespace XXXXXFES(Th,[P1,P1,P1,P1]);   
> XXXXXFES[u,v,w,p];  
> XXXXXFES[ue,ve,we,pe];  
> XXXXXFES[hy,hx,hz,q];   
> func E = [P1, P1, P1, P1];  
> varf LNSE ([ue,ve,we,pe],[hy,hx,hz,q])   
> =int2d(Th)…  
> varf b([ue,ve,we,pe],[hy,hx,hz,q])  
> =int2d(Th)…  
> Mat M;  
> macro def(j) [j, j#A, j#B, j#C]  
> macro init(j) [j, j, j, j]   
> createMat(Th, M, E);  
> M = LNSE(XXXXXFES, XXXXXFES);  
> matrix B = b(XXXXXFES, XXXXXFES);  
> Mat J(M, B);  
> int nev = 100;   
> int ncv = 2\*nev;   
> real tol = 1e-12;   
> complex[int] EigenVal(nev);  
> XXXXXFES[int] [EigenVecu,EigenVecv,EigenVecw,EigenVecp] (nev);   
> complex Shift = getARGV(“-shift\_real”, 0) + getARGV(“-shift\_imag”, 10) \* 1i; /  
> string EVSParam =  
> “-eps\_tol " + tol +” "+  
> “-eps\_nev " + nev +” "+  
> "-eps\_type krylovschur " +   
> "-st\_type sinvert " +   
> "-eps\_monitor\_conv " +   
> "-eps\_target " + real(Shift) + “+” + imag(Shift) + “i”;   
> int i, k;  
> k = EPSSolve(M, J, values=EigenVal, vectors=EigenVecu, sparams = EVSParam);

Did someone encounter this problem before?  
Regards,  
Robert

---

<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: [April 12, 2022, 10:26am UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663/2 "2022-04-12T10:26:33Z")

</div>

Near impossible to help you out without a runnable piece of code. What do you mean by “different results”? Consider upgrading your FreeFEM installation as well.

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [April 13, 2022, 1:37pm UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663/3 "2022-04-13T13:37:58Z")

</div>

Also note that your finite element space consisting of P1-P1 elements is not inf-sup stable for Stokes problems. Try Taylor-Hood (P2-P1) or MINI (P1b-P1) elements.

---

<div class="post-metadata">

### Author: ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)
#### Post date: [April 13, 2022, 2:41pm UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663/4 "2022-04-13T14:41:20Z")

</div>

Hello,  
Thank you both for suggestions. I did some more tests and the problem might come from the boundary conditions as I have an axi-symmetrical problem and I use the weak form of the N-S equations written in the cylindrical components. By different results I mean that I just run the simulation to compute 100 eigenvalues. Instead of getting the exactly 100 eigenvalue I get different values each time, not even close to the previous simulation. In another case where I use the weak form of the N-S equation written in the cartesian components I always get the same eigenvalues.

I have to put as a boundary condition on the symmetry-axis the partial derivative of a flow component in respect to a direction equal to 0, du/dx=0. Is it correct to write it as it follows?

```auto
+int1d(Mesh, SymmetryAxis)((dx(u)*TestFunction)*1e30)

```

Regards,  
Robert

---

<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: [April 13, 2022, 3:06pm UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663/5 "2022-04-13T15:06:24Z")

</div>

No, it does not look like a proper way to impose such a boundary condition.

---

<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: [April 13, 2022, 4:10pm UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663/6 "2022-04-13T16:10:00Z")

</div>

I recommend to check out the [StabFem](https://stabfem.gitlab.io/StabFem/) library. The StabFem gitlab repository contains various examples which can be very helpful to guide the correct implementation of the boundary conditions.

---

<div class="post-metadata">

### Author: ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)
#### Post date: [April 13, 2022, 5:07pm UTC](https://community.freefem.org/t/slepc-different-values-with-np-1-vs-np-2/1663/7 "2022-04-13T17:07:27Z")

</div>

Dear @aszaboa ,  
Thank you for the link, indeed is a very nice repository. Actually in [this](https://gitlab.com/stabfem/StabFem/-/blob/master/SOURCES_FREEFEM/Stab_2D.edp) example, on line 148 I saw that kind of boundary condition.  
Regards,  
Robert
