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

2D Lid Driven Cavity Flow simulation using MATLAB

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 23, 2010, 13:17
Default 2D Lid Driven Cavity Flow simulation using MATLAB
  #1
New Member
 
Joseph
Join Date: Feb 2010
Posts: 1
Rep Power: 0
josephlm is on a distinguished road
I have been trying to simulate the 2D lid driven cavity flow using the SIMPLE algorithm on the staggered grid, in which velocity is assumed to be coupled with pressure and momentum equations are iterated and u, v and pressure p are corrected by a correction term u_corr, v_corr and p_corr respectively. The looping stops when p_corr decreases to a sufficiently small value.

However, the flow obtain does not seem to look like how it should look like, i.e. a main vortex at the centre with counter vortices at the bottom corners. Instead, the plot I obtained shows the boundary conditions (Lid velocity at top, with no-slip condition at other walls), but the velocity arrows in the middle seem to be of a magnitude 100 times smaller than lid velocity and in random directions. It would appear that I have a problem with the correction terms, u_corr, v_corr and p_corr being too small, but i checked the discretized equations over and over and they seem to be correct..

Does anyone know what could be the likely reason for this? Appreciate any help or suggestions to modify my code!
josephlm is offline   Reply With Quote

Old   June 14, 2010, 13:25
Default
  #2
New Member
 
Jame
Join Date: Jun 2010
Posts: 3
Rep Power: 16
bikash89 is on a distinguished road
I have been also facing similar kind of problem. In my case after few iterations oscillations start and the solution fails. However the same code worked really well for Coutte flow. Can ne1 help??
Quote:
Originally Posted by josephlm View Post
I have been trying to simulate the 2D lid driven cavity flow using the SIMPLE algorithm on the staggered grid, in which velocity is assumed to be coupled with pressure and momentum equations are iterated and u, v and pressure p are corrected by a correction term u_corr, v_corr and p_corr respectively. The looping stops when p_corr decreases to a sufficiently small value.

However, the flow obtain does not seem to look like how it should look like, i.e. a main vortex at the centre with counter vortices at the bottom corners. Instead, the plot I obtained shows the boundary conditions (Lid velocity at top, with no-slip condition at other walls), but the velocity arrows in the middle seem to be of a magnitude 100 times smaller than lid velocity and in random directions. It would appear that I have a problem with the correction terms, u_corr, v_corr and p_corr being too small, but i checked the discretized equations over and over and they seem to be correct..

Does anyone know what could be the likely reason for this? Appreciate any help or suggestions to modify my code!
bikash89 is offline   Reply With Quote

Old   June 23, 2010, 08:54
Default
  #3
New Member
 
zt
Join Date: Jun 2010
Posts: 1
Rep Power: 0
mensacorp is on a distinguished road
Quote:
Originally Posted by josephlm View Post
I have been trying to simulate the 2D lid driven cavity flow using the SIMPLE algorithm on the staggered grid, in which velocity is assumed to be coupled with pressure and momentum equations are iterated and u, v and pressure p are corrected by a correction term u_corr, v_corr and p_corr respectively. The looping stops when p_corr decreases to a sufficiently small value.

However, the flow obtain does not seem to look like how it should look like, i.e. a main vortex at the centre with counter vortices at the bottom corners. Instead, the plot I obtained shows the boundary conditions (Lid velocity at top, with no-slip condition at other walls), but the velocity arrows in the middle seem to be of a magnitude 100 times smaller than lid velocity and in random directions. It would appear that I have a problem with the correction terms, u_corr, v_corr and p_corr being too small, but i checked the discretized equations over and over and they seem to be correct..

Does anyone know what could be the likely reason for this? Appreciate any help or suggestions to modify my code!
Hi

Do you have to solve your system with SIMPLE algorithm? I mean you can use picard iteration which is also very simple. I just wrote a 2D Navier Stokes code for Matlab which iterates the solution of matrix K by using picard iterations. It gives reasonable results for the cavity problem.
mensacorp is offline   Reply With Quote

Old   June 24, 2010, 01:58
Default
  #4
New Member
 
Dhileep
Join Date: Apr 2010
Posts: 10
Rep Power: 16
Dhileep T K is on a distinguished road
Hi,
i have written a matlab code for a 2D natural convection problem using malalasekara versteeg as reference. can you suggest me some reference books for lid driven cavity problem.
Dhileep T K is offline   Reply With Quote

Old   August 17, 2023, 20:36
Default
  #5
New Member
 
Chandan Varma
Join Date: Aug 2023
Posts: 2
Rep Power: 0
chandanvarma07 is on a distinguished road
Hello everyone,

Inspired by the insightful teachings of Prof. Sandip Mazumder on YouTube, I have constructed a CFD code entirely from scratch using MATLAB for a classic problem: the lid-driven cavity flow. My goal is to implement a co-located mesh approach and harness the capabilities of the SIMPLE algorithm to ensure accurate pressure-velocity coupling. But after running the code, the residuals were blowing upto infinity.

In the early stages of debugging, I closely monitored the simulation's behavior. The initial iteration yielded a promising outcome, with both X and Y momentum well-preserved—a strong validation of my approach. Employing the TDMA method, I've attached an x momentum contour from the first iteration for your reference, exhibiting similarities to patterns observed in heat conduction cases solved by the ADI Method.

However, as I delved further into debugging, a significant challenge emerged: accurately calculating face velocities. It became evident that inaccuracies at this step were rippling through the simulation, affecting pressure source term calculations and subsequently impacting the pressure correction data. Notably, certain cells exhibited discrepancies between the sign of pressure source terms and correction data.

Through careful examination, I've begun to explore whether the absence of appropriate boundary conditions in face velocity calculation might contribute to these disparities. This has prompted a deeper consideration of boundary condition implementation and its potential influence on this critical simulation stage.

To provide a comprehensive view of my progress, I've attached the code I've been diligently working on. Your insights and expertise in reviewing this code would be invaluable in helping me address these challenges.
Attached Images
File Type: jpg mom_solver.jpg (58.2 KB, 10 views)
Attached Files
File Type: zip Code.zip (66.2 KB, 4 views)
chandanvarma07 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 2d lid driven cavity using ghost cells quarkz Main CFD Forum 9 January 20, 2013 05:54
Simulation of Flow through Complex 3D Geometry EmersonKB CFX 5 July 2, 2009 08:17
3d(Axis symmetric lid driven flow) prasanthnitt Main CFD Forum 0 June 18, 2009 06:39
Natural convection - Inlet boundary condition max91 CFX 1 July 29, 2008 20:28
lid driven cavity ani Main CFD Forum 3 April 2, 2006 13:27


All times are GMT -4. The time now is 15:38.