CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Help with coding SIMPLE for Lid-Driven Cavity

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 12, 2013, 09:19
Smile Help with coding SIMPLE for Lid-Driven Cavity
  #1
New Member
 
Sam Gregson
Join Date: Jul 2013
Posts: 4
Rep Power: 12
samgregson is on a distinguished road
Hi all,

I am new to CFD but very interested in the field. I have been trying to write a very simple code to solve the lid-driven cavity problem with a staggered grid using a steady SIMPLE method and have encountered some problems.

Currently, solving the momentum equations gives reasonable results for the first iteration and the pressure correction does correct for divergence after updating the velocities. However as the SIMPLE iterations progress the solution becomes unrealistic and I notice that the pressure corrections increases wildly with every iteration along with the divergence of each cell.

It is difficult to ask a specific question (sorry) as I don't know where the problem lies but maybe people could give me pointers on the implementation or advice on how to check various parts of the code?

Here is some info on what I have done:
  • At boundaries I am using ghost cells for the velocities and setting them so that the linearly interpolated velocities at boundaries are right.
  • For pressure equations I have set the east coefficient to zero at the east boundary, north coefficient to zero at the north boundary etc.
  • I am using Gauss Seidel iterative solver for all equations (just for simplicity).
  • I am using first order upwind for convection.
  • There is no time advancement as I am solving for a steady solution.

I would really appreciate any help.

Thank you in advance,
Sam

Here are the x velocities and pressures after 1 iteration (including correcting velocities and ghost cells are included):



Here they are after 2:

samgregson is offline   Reply With Quote

Old   August 16, 2013, 05:06
Default
  #2
New Member
 
Sam Gregson
Join Date: Jul 2013
Posts: 4
Rep Power: 12
samgregson is on a distinguished road
UPDATE:

I am currently testing my code using Poiseuille flow between two parallel plates (following advice by HouKen in this post: http://www.cfd-online.com/Forums/mai...ng-simple.html).

I am reasonably convinced that my momentum equations are in order since they do not change the initial conditions when the precise solution is given as initial conditions. Furthermore when setting arbitrary initial conditions (apart from the inflow velocity) the momentum equations give good answers. This result also gives me confidence that boundary conditions are in order.

As for the pressure equation, when given a velocity field it seems to produce a solution that has a better mass balance (for each cell), which is good news. And therefore I am reasonably happy with the pressure correction equations.

So, what's the problem???? Well, when I iterate in the outer loop between the momentum equations and the pressure equation the solution just gives nonsense results, the mass imbalance grows (between outer iterations, but diminishes within an iteration) and the momentum equations finally just diverge.

What is going on here??? I just don't seem to be getting anywhere. Any tips? I would be very grateful!
samgregson is offline   Reply With Quote

Old   August 18, 2013, 11:04
Default
  #3
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 427
Rep Power: 19
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
Since you are writing a new code, please make sure your matrix coefficient are right calculated.
Since your procedure diverge, one reason is the underelaxtion is too high. and the other is your matrix coeffcient is wrong.
good luck to you.
ztdep is offline   Reply With Quote

Old   August 19, 2013, 06:11
Default
  #4
New Member
 
Sam Gregson
Join Date: Jul 2013
Posts: 4
Rep Power: 12
samgregson is on a distinguished road
Thank you for your reply P Ding. Yes I spent a long time staring at the coefficients but can't see anything wrong with them. I think you are right about the under-relaxation though. I think I misunderstood the under-relaxation of the momentum equations. I applied under-relaxation by using the SOR method. However this under-relaxes the process of solving the system of equations rather than under-relaxing the solution itself. Is this correct?
samgregson is offline   Reply With Quote

Old   August 19, 2013, 07:06
Default
  #5
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 427
Rep Power: 19
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
yes , you are right. ap/alpha*U=sigma*Uab+Source+(1-alpha)/alpha*U*

in my blog in this web, there is a fortran code for the simple algorithm
ztdep is offline   Reply With Quote

Old   August 19, 2013, 10:22
Default
  #6
New Member
 
Sam Gregson
Join Date: Jul 2013
Posts: 4
Rep Power: 12
samgregson is on a distinguished road
Great, thanks. I'm getting somewhere now.

I can't seem to find your blog, do you have a link?

I was wondering whether the coefficients for momentum updated in the inner iterations or only in the outer iterations? It seems that my code is slightly more stable when they are updated in the inner iterations but I don't know what the norm is and whether this has any disadvantages?
samgregson is offline   Reply With Quote

Old   September 12, 2013, 22:48
Default
  #7
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 427
Rep Power: 19
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
Quote:
Originally Posted by samgregson View Post
Great, thanks. I'm getting somewhere now.

I can't seem to find your blog, do you have a link?

I was wondering whether the coefficients for momentum updated in the inner iterations or only in the outer iterations? It seems that my code is slightly more stable when they are updated in the inner iterations but I don't know what the norm is and whether this has any disadvantages?
http://www.cfd-online.com/Forums/blogs/ztdep/
yes, outer iteration resolve the nonlinearity , it update the coefficients. and inner iteration only solve the linear equation with a constant coefficients
ztdep is offline   Reply With Quote

Reply

Tags
boundary condition, code, lid driven cavity, simple method, staggered grid


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
Boundary Condition for Driven Cavity problem dado Main CFD Forum 6 August 15, 2015 20:29
Lid Driven Cavity using Ghost Cell Method and in C++ illuminati5288 Main CFD Forum 0 August 12, 2011 22:05
Traditional driven cavity Azfarizal b Mukhtar CFX 0 July 27, 2004 21:22
SIMPLE Cavity Flow Kunal Jain Main CFD Forum 1 August 26, 2001 11:43
2D driven cavity and chaos Abhijit Joshi Main CFD Forum 6 February 1, 1999 13:51


All times are GMT -4. The time now is 21:59.