CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > CFD Online Community > CFD-Wiki

Sample code for SIMPLE-algorithm and solving Lid-Driven Cavity flow test is uploaded

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 3 Post By Michail
  • 1 Post By Michail

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2010, 12:05
Smile Sample code for SIMPLE-algorithm and solving Lid-Driven Cavity flow test is uploaded
  #1
Member
 
Michail's Avatar
 
Michail
Join Date: Apr 2009
Location: Lithuania
Posts: 41
Rep Power: 17
Michail is on a distinguished road
Dear colleagues!

I uploaded sample code for SIMPLE-algorithm and solving lid-driven cavity flow test (Re=1000).

It has a lot of shortcomings, but I think that it will be useful for all newcomers. I intend to develop it further, but now it very slowly converges. All notes will be useful, and hope it can be discussed.

The code can be found here:

http://www.cfd-online.com/Wiki/Sampl...9_-_Fortran_90

It predecessor - the code for solving Smith-Hutton test can be found here:

http://www.cfd-online.com/Wiki/Appro...s_and_examples

http://www.cfd-online.com/Wiki/Sampl...t_-_Fortran_90

I'll be glad and grateful to get your opinion about it
hamza dg, siddiquesil and L2e2o4 like this.
Michail is offline   Reply With Quote

Old   May 18, 2010, 13:05
Default Simple-Algorithm
  #2
New Member
 
Mijail Febres
Join Date: May 2010
Posts: 4
Rep Power: 16
Mijail is on a distinguished road
HI, I started programming a SIMPLE-algorithm myself based on Malalaskera's book on a staggered grid for a 1-d constant density permanent flow. It's not working properly, velocities converge in 2 or 3 iterations but pressures don't, I think I have a problem with BC's treatment (constant known velocity on one side and constant known pressure on the other). Do you know any book that shows a clear example on boundary conditions treatment?, I mean, all books, from Patankar, Anderson, Versteg, etc talk about it, but no one has a clear example.
The code you wrote is on a colocated grid, do you think it has advantages over a staggered grid for the 1-d problem I'm trying to solve?

Thanks in advance
Mijail is offline   Reply With Quote

Old   May 18, 2010, 13:23
Default
  #3
Member
 
Michail's Avatar
 
Michail
Join Date: Apr 2009
Location: Lithuania
Posts: 41
Rep Power: 17
Michail is on a distinguished road
Hi! Look here, may be this will be useful http://www.cfd-online.com/Forums/mai...flow-pipe.html
Michail is offline   Reply With Quote

Old   June 14, 2010, 14:38
Default SIMPLE Algortihm in Matlab
  #4
New Member
 
Jame
Join Date: Jun 2010
Posts: 3
Rep Power: 16
bikash89 is on a distinguished road
Hi all..I have been trying to code for viscous incompressible flows using SIMPLE algorithm in Matlab using a staggered grid approach. The code worked really well for Couette flow. However for lid driven cavity, it is not showing required results. I have tried using different Reynolds number like 10, 100, 1000. Initially the code seems as if it will give the required result, however after a few iterations, oscillations begin and the solution fails. Is there any stability criteria for this flow problem? The time step I had used was 0.001 secs. Any kind of help in this regards will be highly appreciated. Thanks a lot.
bikash89 is offline   Reply With Quote

Old   October 12, 2018, 09:14
Default
  #5
New Member
 
Join Date: Oct 2018
Posts: 4
Rep Power: 8
hamza dg is on a distinguished road
hi,
1- in boundary conditions, the velocity in the wall is Up or Uface?
2- or we need to define the boundary conditions for both velocities? and how?
hamza dg is offline   Reply With Quote

Old   October 12, 2018, 17:52
Default
  #6
Member
 
Michail's Avatar
 
Michail
Join Date: Apr 2009
Location: Lithuania
Posts: 41
Rep Power: 17
Michail is on a distinguished road
Hi Hamza

We specify both velocity components on the wall u and v (0,0 for solid walls, 1,0 for moving wall)

Just fixed them (they are not corrected during solution).

U_face calculated inside program. check the code,it's quite simple.
Michail is offline   Reply With Quote

Old   December 27, 2018, 13:28
Default
  #7
New Member
 
Join Date: Oct 2018
Posts: 4
Rep Power: 8
hamza dg is on a distinguished road
Hi, thank you Michail for your answers they are very useful, i realized the code for Newtonian and Non-Newtionian fluids.
Now i am trayin the viscoelastic case, but i have a problem of numerical stability when increasing WE (WE is a parameter in the equations), i want to know if you have an idea about this.
you can find the problem and equations in the article "Finite volume simulation of viscoelastic laminar flow in a lid-driven cavity" (Kerim Yapici, Bulent Karasozen, Yusuf Uludag) (2009)
hamza dg is offline   Reply With Quote

Old   December 28, 2018, 21:30
Default
  #8
Member
 
Michail's Avatar
 
Michail
Join Date: Apr 2009
Location: Lithuania
Posts: 41
Rep Power: 17
Michail is on a distinguished road
hallo Hamza

I took a glance through the paper You referred.

First of all I would like to ask - how many equations do You solve?

If 3 You are wrong. There are 3 additional equations for stresses.

They are solving the same way as momentum equations.

so if You want to apply my code for this problem You should:

1) Add to solver 3 equations for stresses, likewise for scalar here

https://www.cfd-online.com/Wiki/Samp...t_-_Fortran_90

(the same scheme i used here for momentum equations U,V)

2) Modify source term in momentum equations
3) Modify boundary conditions (eq. 7 in that paper)

so there is some work here. But not too complicated )
Michail is offline   Reply With Quote

Old   December 29, 2018, 12:42
Default
  #9
New Member
 
Join Date: Oct 2018
Posts: 4
Rep Power: 8
hamza dg is on a distinguished road
Hi michail,

yes i see, we have three unknowns added so automatically we need 3 others equations which are given in the constitutive equations.

i have applied all your remarks, and when i take WE=0 (newtonian case) the results are good, but for WE#0 here the convergence problem occurs, I think i need a special treatment of source term !!
hamza dg is offline   Reply With Quote

Old   December 29, 2018, 16:09
Default
  #10
Member
 
Michail's Avatar
 
Michail
Join Date: Apr 2009
Location: Lithuania
Posts: 41
Rep Power: 17
Michail is on a distinguished road
Hallo

the source term in equations of motion (for U and V) summarized from pressure gradient and stresses.]

I guess, You should implement underrelaxation for stresses' equations:

(look in S. Patankar)

!---------------------------- under-relaxation ---------------------------------
Alfa = 0.8
Urf = 1. / Alfa

Ap(1:NXmaxC,1:NYmaxC,1) = Ap(1:NXmaxC,1:NYmaxC,1) * Urf
Sp(1:NXmaxC,1:NYmaxC,1) = Sp(1:NXmaxC,1:NYmaxC,1) + (1. - Alfa )* &
Ap(1:NXmaxC,1:NYmaxC,1)*F(1:NXmaxC,1:NYmaxC,1) ! / Alfa
Ap(1:NXmaxC,1:NYmaxC,2) = Ap(1:NXmaxC,1:NYmaxC,2) * Urf
Sp(1:NXmaxC,1:NYmaxC,2) = Sp(1:NXmaxC,1:NYmaxC,2) + (1. - Alfa )* &
Ap(1:NXmaxC,1:NYmaxC,2)*F(1:NXmaxC,1:NYmaxC,2) ! / Alfa
!---------------------------------------------------------------------------------

I would make relaxation koeffitient alfa=0.2..0.3 in stress equations.

and...

Check for bugs.
Check for bugs.

sleep a night and again: Check for bugs

Good luck!
Michail is offline   Reply With Quote

Old   December 30, 2018, 15:20
Default
  #11
New Member
 
Join Date: Oct 2018
Posts: 4
Rep Power: 8
hamza dg is on a distinguished road
Hi Michail, I hope you had a good day,

Yes i am used the underrelaxation for stresses equations.
and now i am trying again...

thank you for your encouragement
hamza dg is offline   Reply With Quote

Old   December 30, 2018, 22:37
Default
  #12
Member
 
Michail's Avatar
 
Michail
Join Date: Apr 2009
Location: Lithuania
Posts: 41
Rep Power: 17
Michail is on a distinguished road
Okay, then let's take it more seriously:

1) First of all, check all math in Your code.
For this:
a) go through all possible references-issues - at least 20, better 30.
a0) the solution of the problem is already found, search it in publications
b) make yourself sure, that you have complete understanding of mathematical formulation
of governing equations and solution algorithm
c) check all signs and coefficients in your code, write out all math with pencil and paper, compare them.

2) Debug Your code.

a) make UDS scheme for momentum ans stresses equations
b) make the lowest possible underrelaxation coefficients - 0.5-0.7 for velocities, 0.1 for pressure.
c) search for suitable relaxation coefficients for stresses - vary them from 0.01 till 0.99
d) get convergence.

then you can go for improvement
L2e2o4 likes this.
Michail is offline   Reply With Quote

Old   January 29, 2019, 02:14
Default Boundary Condition Treatment
  #13
New Member
 
Osman
Join Date: Jul 2018
Posts: 7
Rep Power: 8
usman nazir is on a distinguished road
Hello Mijail,
I am solving the lid driven cavity using SIMPLE algorithm in C++. I am facing same problem as yours, the treatment of boundary condition as no clear example is available in Patankar and Malalaskera's Book.
Please recommend me some solution to your problem

Quote:
Originally Posted by Mijail View Post
HI, I started programming a SIMPLE-algorithm myself based on Malalaskera's book on a staggered grid for a 1-d constant density permanent flow. It's not working properly, velocities converge in 2 or 3 iterations but pressures don't, I think I have a problem with BC's treatment (constant known velocity on one side and constant known pressure on the other). Do you know any book that shows a clear example on boundary conditions treatment?, I mean, all books, from Patankar, Anderson, Versteg, etc talk about it, but no one has a clear example.
The code you wrote is on a colocated grid, do you think it has advantages over a staggered grid for the 1-d problem I'm trying to solve?

Thanks in advance
usman nazir is offline   Reply With Quote

Old   January 28, 2020, 04:43
Default
  #14
New Member
 
Mateja
Join Date: Jan 2020
Posts: 20
Rep Power: 6
Mateja is on a distinguished road
Hello,
I just started solving Lid Driven Cavity with PISO algorithm. I am using FORTRAN for this. Can someone tell me about the implementation of the pressure boundary condition? I would be thankful if you can refer to any literature.
Mateja is offline   Reply With Quote

Old   February 23, 2020, 11:26
Default SIMPLE algorithm in collocated non orthogonal body fitted grid in 3D
  #15
New Member
 
Waliur Rahman
Join Date: Apr 2018
Location: Dhaka,Bangladesh
Posts: 27
Rep Power: 8
Waliur Rahman is on a distinguished road
Dear all,
Can anyone give me any book or paper that describe SIMPLE algorithm in collocated non orthogonal body fitted grid in 3D?

Regards,
Waliur Rahman
Waliur Rahman is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sample MAPLE code for SIMPLE algorithm mia Main CFD Forum 0 February 28, 2009 00:22
About the difference between steady and unsteady problems Lisa Main CFD Forum 11 July 5, 2000 15:37


All times are GMT -4. The time now is 19:49.