# Implementation of Simple Algorithm

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 LinkBack Thread Tools Display Modes
August 20, 2012, 03:10
#21
Senior Member

Join Date: Aug 2011
Posts: 251
Rep Power: 8
Quote:
 Originally Posted by JunaidAhmad why we need SIMPLE Algorithm when We have Artificial compressibility?

Artificial compressibility is designed and works only for steady problems.

August 20, 2012, 03:37
#22
Senior Member

Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 487
Rep Power: 13
Quote:
 Originally Posted by JunaidAhmad I don't understand i did exactly what is written in book. it didn't work. I did the same think using artificial compressibility and it worked but using SIMPLE method it did not. the only thing left for me is to paste the code a let you guys decide what is wrong with it. But first i have to go through one more time.
if your artificial compressiblity method works and SIMPLE does not work then i would suggest have a look at your linear system solver, that probably is not working well for SIMPLE case. Thats because the nature of linear system in both cases is very different.

August 20, 2012, 04:04
#23
Senior Member

Join Date: Aug 2011
Posts: 251
Rep Power: 8
Quote:
 Originally Posted by arjun if your artificial compressiblity method works and SIMPLE does not work then i would suggest have a look at your linear system solver, that probably is not working well for SIMPLE case. Thats because the nature of linear system in both cases is very different.

His linear system is fine because it works in artificial compressibility case for the velocity componnents. Recall indeed that in artificial compressibility you don't have a linear system to solve for pressure since it is determined explicitly with an expression like P(i,j)_k+1= P(i,j)_k + c*div(U*).
k is the indice loop to reach the steady state, c is a pseudo celerity of pressure waves.

So if his SIMPLE does not work it should no be due to the linear system solver but rather due to its implementation which should have a bugg.

August 20, 2012, 04:08
#24
Senior Member

Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 487
Rep Power: 13
Quote:
 Originally Posted by leflix So if his SIMPLE does not work it should no be due to the linear system solver but rather due to its implementation which should have a bugg.

i think this part is never ruled out.

 August 20, 2012, 17:55 #25 Member     Junaid Ahmad Khan Join Date: Mar 2010 Location: Islamabad Posts: 33 Rep Power: 8 Hi Every one, Thanks for all your support tonight i have seen results that i was hopping to see for about more then a week. and some how i have solve the Lid Driven Cavity by simple algorithm. I will post the code and procedure later for future reference. well there is still order of convergence problems and the understanding of relaxation factor which will be discuss later. Thanks Again. Regards Junaid

 August 20, 2012, 19:27 #26 Member   Michael Moor Join Date: May 2012 Location: Ireland Posts: 30 Rep Power: 6 Hi Junaid, Congratulations on your results!! Please may you also send the program on to me? I am curious as to how you implemented the boundary conditions for the vertical walls.

August 21, 2012, 01:55
#27
Senior Member

Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 487
Rep Power: 13
Quote:
 Originally Posted by JunaidAhmad Hi Every one, Thanks for all your support tonight i have seen results that i was hopping to see for about more then a week. and some how i have solve the Lid Driven Cavity by simple algorithm. I will post the code and procedure later for future reference. well there is still order of convergence problems and the understanding of relaxation factor which will be discuss later. Thanks Again. Regards Junaid

In case of SIMPLE algo enclosed with walls (lid driven cavity) your pressure equation shall be all neumann BC type problem, which should be singular. How did you solve that. Probably that is main issue for your convergence problems.

 August 21, 2012, 03:25 #28 Member   Ren/Xingyue Join Date: Jan 2010 Location: Nagoya , Japan Posts: 44 Rep Power: 8 good topic! I think artificial compressiblity method is more stable then SIMPLE with a bad linear solver in your case. Junaid, can you tell me your solver? Maybe you didn't use a suitable solver. Last edited by hilllike; August 21, 2012 at 03:59.

August 21, 2012, 04:41
#29
Senior Member

Join Date: Aug 2011
Posts: 251
Rep Power: 8
Quote:
 Originally Posted by hilllike good topic! I think artificial compressiblity method is more stable then SIMPLE with a bad linear solver in your case. Junaid, can you tell me your solver? Maybe you didn't use a suitable solver.
As I mentioned it previously there is no linear system to solve for pressure in the artificial compressibility method.

August 21, 2012, 04:55
#30
Member

Ren/Xingyue
Join Date: Jan 2010
Location: Nagoya , Japan
Posts: 44
Rep Power: 8
Quote:
 Originally Posted by leflix As I mentioned it previously there is no linear system to solve for pressure in the artificial compressibility method.
That's why I think it is more stable, pressure was calculate explicitly.
I don't know if his SIMPLE code is two phase flow model. If it is the linear solver may be the problem.

I talked about the solver in SIMPLE code.

 August 21, 2012, 05:54 #31 Member     Junaid Ahmad Khan Join Date: Mar 2010 Location: Islamabad Posts: 33 Rep Power: 8 The problem with convergence is that when i let the program to iterate to go to more then about 8,000 the streamlines become distorted. As for pressure i solve it explicitly. as given below Kindly go through it and try to debug it. it is a working code #include #include #include #include #include #include #include #include #include using namespace std; //Number of NODEs #define NODE 81 //Write file After that number of Iterations #define AutoSave 1000 //Under-Relaxation Factor for p,u,v float urfp=0.0001; float urfu=0.3; float urfv=0.7; //--------------------------------- //Boundary conditions velocitys float B[2]={1,0}; //--------------------------------- //X and Y coordinate float x[NODE] = {0}; float y[NODE] = {0}; //--------------------------------- //U-velocity, V-velocity, and Pressure float u[NODE][NODE+1] = {0}; float us[NODE][NODE+1] = {0}; float du[NODE][NODE+1] = {0}; float uo[NODE][NODE+1] = {0}; float v[NODE+1][NODE] = {0}; float vs[NODE+1][NODE] = {0}; float dv[NODE+1][NODE] = {0}; float vo[NODE+1][NODE] = {0}; float p[NODE+1][NODE+1] = {0.0}; float ps[NODE+1][NODE+1] = {0.0}; float pp[NODE+1][NODE+1] = {0.0}; float po[NODE+1][NODE+1] = {0.0}; //--------------------------------- void TDMsolve (int n, float *a, float *b, float *c, float *v, float *x) { /** * n - number of equations * a - sub-diagonal (means it is the diagonal below the main diagonal) -- indexed from 1..n-1 * b - the main diagonal * c - sup-diagonal (means it is the diagonal above the main diagonal) -- indexed from 0..n-2 * v - right part * x - the answer */ for (int i = 1; i < n; i++) { double m = a[i]/b[i-1]; b[i] = b[i] - m*c[i-1]; v[i] = v[i] - m*v[i-1]; } x[n-1] = v[n-1]/b[n-1]; for (int i = n - 2; i >= 0; i--) x[i]=(v[i]-c[i]*x[i+1])/b[i]; } float MAX(float f,float d) { if(f>d) return f; if(d>f) return d; else return f; } void writetoFile(int Nx,int Ny,float comp_time,float er, char* name) { ofstream outfile2; outfile2.open(name); outfile2<<"TITLE = \"Computation Time = "<0&&col<(Nx-1)) { FP=u[col][row]; FW=u[col-1][row]; FE=u[col+1][row]; FSE=v[col+1][row]; FSW=v[col][row]; FNE=v[col+1][row-1]; FNW=v[col][row-1]; Fw=A*(FP+FW)/2.0; Fe=A*(FE+FP)/2.0; Fs=A*(FSE+FSW)/2.0; Fn=A*(FNE+FNW)/2.0; dF=Fe-Fw+Fn-Fs; aw=MAX(G+Fw/2.0,MAX(Fw,0.0)); ae=MAX(G-Fe/2.0,MAX(-Fe,0.0)); as=MAX(G+Fs/2.0,MAX(Fs,0.0)); an=MAX(G-Fn/2.0,MAX(-Fn,0.0)); ap=(aw+ae+as+an+dF)/urfu; a1[sb]=-aw; c1[sb]=-ae; b1[sb]=ap; v1[sb]=( as*u[col][row+1] + an*u[col][row-1] + A*(p[col][row]-p[col+1][row]) + ((1-urfu)*ap)*uo[col][row] ); //a(i,j)/alpha_u x u(i,j) = Sigma (a_nb x v_nb) + (p(I,J)+p(I+1,J)) x A +[(1-alpha_u)a(i,j)/alpha_u] x u^(n-1)_(I,j) } sb++; } TDMsolve (NODE, a1, b1, c1, v1, x1 ); for(int k=0;k0&&row<(Ny-1)) { FSW=(u[col-1][row+1]); FNW=(u[col-1][row]); FNE=(u[col][row]); FSE=(u[col][row+1]); FP=(v[col][row]); FS=(v[col][row+1]); FN=(v[col][row-1]); Fw=A*(FSW+FNW)/2.0; Fe=A*(FNE+FSE)/2.0; Fs=A*(FS+FP)/2.0; Fn=A*(FN+FP)/2.0; dF=Fe-Fw+Fn-Fs; D=G; aw=MAX(D+Fw/2.0,MAX(Fw,0.0)); ae=MAX(D-Fe/2.0,MAX(-Fe,0.0)); as=MAX(D+Fs/2.0,MAX(Fs,0.0)); an=MAX(D-Fn/2.0,MAX(-Fn,0.0)); ap=(aw+ae+as+an+dF)/urfv; a2[sb]=-an; c2[sb]=-as; b2[sb]=ap; v2[sb]=( aw*v[col-1][row] + ae*v[col+1][row] + A*(p[col][row+1]-p[col][row]) + ((1-urfv)*ap)*vo[col][row] //a(I,j)/alpha_v x v(I,j) = Sigma (a_nb x v_nb) + (p(I,J+1)+p(I,J)) x A +[(1-alpha_v)a(I,j)/alpha_v] x v^(n-1)_(I,j) ); } sb++; } TDMsolve (NODE, a2, b2, c2, v2, x2); for(int k=0;k0&&col<(Nx-1)) { FP=us[col][row]; FW=us[col-1][row]; FE=us[col+1][row]; FSE=vs[col+1][row]; FSW=vs[col][row]; FNE=vs[col+1][row-1]; FNW=vs[col][row-1]; Fw=A*(FP+FW)/2.0; Fe=A*(FE+FP)/2.0; Fs=A*(FSE+FSW)/2.0; Fn=A*(FNE+FNW)/2.0; dF=Fe-Fw+Fn-Fs; aw=MAX(G+Fw/2.0,MAX(Fw,0.0)); ae=MAX(G-Fe/2.0,MAX(-Fe,0.0)); as=MAX(G+Fs/2.0,MAX(Fs,0.0)); an=MAX(G-Fn/2.0,MAX(-Fn,0.0)); ap=aw+ae+as+an+dF; du[col][row]=A/ap; a1[sb]=-aw; c1[sb]=-ae; b1[sb]=ap; v1[sb]=( as*us[col][row+1] + an*us[col][row-1] + A*(ps[col][row]-ps[col+1][row]) ); //a(I,j) x u*(I,j) = Sigma (a_nb x u*_nb) + (p*(I,J)+p*(I+1,J)) x A } sb++; } TDMsolve (NODE, a1, b1, c1, v1, x1 ); for(int k=0;k0&&row<(Ny-1)) { FSW=(us[col-1][row+1]); FNW=(us[col-1][row]); FNE=(us[col][row]); FSE=(us[col][row+1]); FP=(vs[col][row]); FS=(vs[col][row+1]); FN=(vs[col][row-1]); Fw=A*(FSW+FNW)/2.0; Fe=A*(FNE+FSE)/2.0; Fs=A*(FS+FP)/2.0; Fn=A*(FN+FP)/2.0; dF=Fe-Fw+Fn-Fs; D=G; aw=MAX(D+Fw/2.0,MAX(Fw,0.0)); ae=MAX(D-Fe/2.0,MAX(-Fe,0.0)); as=MAX(D+Fs/2.0,MAX(Fs,0.0)); an=MAX(D-Fn/2.0,MAX(-Fn,0.0)); ap=aw+ae+as+an+dF; dv[col][row]=A/ap; a2[sb]=-an; c2[sb]=-as; b2[sb]=ap; v2[sb]=( aw*vs[col-1][row] + ae*vs[col+1][row] + A*(ps[col][row+1]-ps[col][row]) ); //a(I,j) x v*(I,j) = Sigma (a_nb x v*_nb) + (p*(I,J+1)+p*(I,J)) x A } sb++; } TDMsolve (NODE, a2, b2, c2, v2, x2); for(int k=0;ktemp) temp = val; } return temp; } /***********MAIN*************/ int main() { /**********Variables and Constants******/ float Lx = 1.0; float Ly = 1.0; int nx = NODE; int ny = NODE; float deltaX = Lx/(nx-1); float deltaY = Ly/(ny-1); float RE = 1000.0; float Gm = (1.0/RE); float er = 100.0; float tempx = 0.0; for (int col=0; col=Er) { //Set Boundary Condition calcUs(nx,ny,Area,Gm); calcVs(nx,ny,Area,Gm); //Calculate p' calcPp(nx,ny,Area,Gm); //Corrected Pressure PressureCorrection(nx,ny); //Set Wall Gradient setWallGradient(nx,ny); UCorrection(nx,ny,Area,Gm); VCorrection(nx,ny,Area,Gm); setBC(nx,ny); U_urf(nx,ny,Area,Gm); V_urf(nx,ny,Area,Gm); setBC(nx,ny); //Copy Values From Field Variable to Guessed copyValues(nx,ny); er = calcError(nx,ny); CPO(nx,ny); cout<

August 21, 2012, 06:00
#32
Senior Member

Join Date: Aug 2011
Posts: 251
Rep Power: 8
Quote:
 Originally Posted by hilllike I don't know if his SIMPLE code is two phase flow model. If it is the linear solver may be the problem. I talked about the solver in SIMPLE code.

When Junaid started he was speaking about a two-phase flow situation.
As this kind of problem has a numerous potential sources of problems, I advised him to first check his Navier-Stokes solver in an incompressible classical problem like lidd driven cavity where it is easy to validate the code.
Then he saw that he had some problems in his SIMPLE implementation.
Now Junaid claimed that his code was runing well, but we don't know really where was the problem and how he overcomed it.

But for me his linear system solver couldn't be the reason why it failed because, with the artificial compressibility algorithm it worked fine. Thus it means that the linear systeme solver worked fine to compute the velocity componnents.

But as Arjun aptly mentionned it, his solver could run well with dirichlet boundary conditions, but not with neumann BC as it is required for pressure correction in the SIMPLE algorithm. It could be indeed the reason..

 August 21, 2012, 07:30 #33 Member     Junaid Ahmad Khan Join Date: Mar 2010 Location: Islamabad Posts: 33 Rep Power: 8 First let me clear that it is not fine but it gives similar results what LDC should give. Problems: the residual of pressure is not going beyond 0.00012. it take urfp =0.0001 if i use 0.001 it diverges. at least 1st problem should not be there. So my next step is to remove that problem Thanks for all ur help i still need it though

August 21, 2012, 08:22
#34
Senior Member

Join Date: Aug 2011
Posts: 251
Rep Power: 8
Quote:
 Originally Posted by JunaidAhmad Problems: the residual of pressure is not going beyond 0.00012. it take urfp =0.0001 if i use 0.001 it diverges.

Using a URF_p <0.1-0.2 is very pathologic
It's not acceptable especially for lidd driven cavity problem.

August 21, 2012, 08:30
#35
Senior Member

Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 487
Rep Power: 13
Quote:
 Originally Posted by leflix Using a URF_p <0.1-0.2 is very pathologic It's not acceptable especially for lidd driven cavity problem.
+1

if you have to go below 0.05 then either you have very very bad mesh or you are doing something really wrong.

(by you i here mean a general person and not lefix)

 November 17, 2012, 14:36 Dear Junaid - dividing by 2.0 - bad programming style #36 Member     Michail Join Date: Apr 2009 Location: Lithuania Posts: 34 Rep Power: 9 Dear Junaid - dividing by 2.0 - bad programming style Fw=A*(FP+FW)/2.0; Fe=A*(FE+FP)/2.0; Fs=A*(FSE+FSW)/2.0; Fn=A*(FNE+FNW)/2.0; cause usually multipication operation executed more rapidly than dividing

 May 12, 2013, 04:48 #37 New Member   hans Join Date: Sep 2012 Posts: 7 Rep Power: 6 Gents, I'm running into the same problem. Looking at the reactions in this thread help me a bit, but still not there. If I look at eq. 6.36, 6.37 and the equations below that for the multiplier (d). I still end up with a problem. If I take the central differencing scheme from Chap. 5 for the central coefficient (pag 136): ap=aw+ae+Fe-Fw; (Assume A and rho = 1 and D=0) aw=Fw/2; ae=-Fe/2; Fw=uw;Fe=ue; ap=uw/2 -ue/2 + uw/4 -ue/4; When uw approaches ue (which happens if all works well in a 1D situation) ap goes to 0 and the multiplier (d) approaches infinity. Resulting in all sorts of problems. I'm not quite sure how the URF solves this issue. Can someone help me figuring out where I'm going wrong?

 May 12, 2013, 22:56 same problem #38 New Member   David Join Date: Feb 2013 Posts: 15 Rep Power: 5 I am also implementing versteeg's book, the pressure correction got similar problem. The velocity distribution profile, pattern are all ok, but the magnitude value, if compared with slit flow theoretical value u(y)=(-dp/dx)H^2/8Miu*(1-(y/0.5H)^2) the max velocity is always 50% higher than the theoretical number, I believe the problem is at pressure correction and don't know how to solve it.

 May 14, 2013, 14:47 #39 New Member   hans Join Date: Sep 2012 Posts: 7 Rep Power: 6 northfly, Do you run into the same problem with the multiplier (d) that approaches infinity when all neighbour cells (velocity )have the same value? How have you solved this? Kind regards

May 22, 2013, 04:14
#40
New Member

sina gilassi
Join Date: May 2013
Posts: 17
Rep Power: 5
Quote:
 Originally Posted by JunaidAhmad HI to All, I am trying to solve Lid Driven Cavity problem using Finite Volume Method, for that i want to use Simple Algorithm. I have all ready solve LDC using Artificial Compressibility now i want to use SIMPLE Algorithm to solve velocity-pressure coupling, for that i am following Versteeg's book. I am using steady navier stokes equations for LDC. The procedure that i have adopted is given below: 1. Initialize u*,v*,p* 2. Solve Discretised momentum equation and Calculated u*,v* NOW comes the problem. in step 3 when i try to calculate p'. 3. the equation is a[i,j]p'[i,j]=a[i-1,j]p'[i-1,j]+a[i+1,j]p'[i+1,j]+a[i,j-1]p'[i,j-1]+a[i,j+1]p'[i,j+1]+b'[i,j] a[i-1,j]=(d A)[i-1,j] a[i+1,j]=(d A)[i+1,j] a[i,j-1]=(d A)[i,j-1] a[i,j+1]=(d A)[i,j+1] b'[i,j] = (u*A)[i-1,j]-(u*A)[i+1,j]+(v*A)[i,j+1]-(v*A)[i,j-1] In this equation i need d to be calculated which is d=A/a where a is the centeral coefficient of velocity equation. where i try to calculate this it some how a become zero which makes d=infinity. and p' become undefined or infinity. that cause problems in step 4 i.e. 4. p[i,j]=p*[i,j]+p'[i,j] u[i,j]=u*[i,j]+d[i,j]*(p'[i-1,j]-p'[i,j]) u[i,j]=u[i,j]+u[i,j]*(p'[i,j-1]-p'[i,j]) 5. Set Boundary condition for u and v 6. Set Wall presure gradient to zero 7. Copy Values p*=p u*=u v*=v 8. Check Convergence. and goto Step 1 My main problem is step 3 any sugesstions for that? (I am using c++) Regards Junaid
Dear ahmad,

based on the book "an introduction to fluid dynamic ..." page 142, there are two main equation of momentum, after I guess P(star), then the v and u (start) are calculated, my question is about the a.u(star) and the coefficient of these equation. how they are defined ?!!!!
could you explain briefly

thank you

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post zouchu Main CFD Forum 1 January 20, 2014 18:02 Roger Main CFD Forum 8 June 25, 2011 22:49 lost.identity Main CFD Forum 1 October 7, 2010 11:48 Sergio Costa Main CFD Forum 2 July 29, 2007 06:44 Yan Kai Main CFD Forum 0 April 18, 2007 03:48

All times are GMT -4. The time now is 06:55.

 Contact Us - CFD Online - Top