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

Simple Algorithm for flow between parallel plates

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 10, 2020, 13:14
Default Simple Algorithm for flow between parallel plates
  #1
New Member
 
Vaibhav
Join Date: Feb 2020
Posts: 5
Rep Power: 6
vaibhavkhanna is on a distinguished road
Hey, I am quite new to CFD programming and was writing my own Matlab code for flow between parallel plates to get more familiar with the simple algorithm which I will be using for my thesis. I am trying to simulate the entrance development region which results in the parabolic velocity profile.
So I am getting NaN values after about 50 iterations of my solver. I have given constant velocity at inlet and u=0 at the walls along with zero pressure correction at the outlet. My guess is that it is related to some fundamental mistakes regarding the coefficients in the momentum equations since I am getting a centreline velocity greater than inlet before solving the pressure correction (continuity) equation but have been unsuccessful in finding that mistake.
Attached Files
File Type: txt salgo1.txt (14.9 KB, 18 views)
File Type: txt gauss_seidel1.txt (789 Bytes, 11 views)
vaibhavkhanna is offline   Reply With Quote

Old   April 10, 2020, 14:04
Default
  #2
Senior Member
 
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 220
Rep Power: 19
tas38 is on a distinguished road
Asking for others to sift through your codes for bugs, be they theoretical or in numerical implementation, is asking too much. I suggest you narrow your question or provide some sample results (e.g. contour plots before divergence) to better solicit assistance.
tas38 is offline   Reply With Quote

Old   April 15, 2020, 22:07
Default
  #3
New Member
 
Vaibhav
Join Date: Feb 2020
Posts: 5
Rep Power: 6
vaibhavkhanna is on a distinguished road
Can you provide some insight on how to debug my code? I have been trying to find the problem but there might be a mistake in the formulation? I am not asking you to debug my code. I am asking how I should proceed with debugging because I don't even know yet what is causing the error
vaibhavkhanna is offline   Reply With Quote

Old   April 16, 2020, 02:24
Default
  #4
New Member
 
Marrie
Join Date: Dec 2014
Posts: 13
Rep Power: 0
manle0312 is on a distinguished road
Your code is full of missing errors and I am not even digging into the main SIMPLE algorithm. Please dont name your matlab file as .txt. I am not going to do the whole thing for you but here are a few pointers:

1. You are calling the wrong function name from salgo1.m: it is gauss_seidel1, not gauss_seidel.

2. Your gauss_seidel1 function has an error on line 24, it is A(i,j), not a(i,j)

3. I can confirm that your coefficients Feu, Feu_r, Fev....etc. are NaN. My suggestion is to run it on a smaller grid with nicer number: like Lx = 1 and Nx = 5; so we have nicer numbers to work with.

4. Print stuff out. I see you only print out gauss iteration and count.. Your first big for loop to solve for the X momentum involves coefficients Feu, Feu_r....etc. Print them out along with iteration number of the for loop so you can see when things become NaN. Even better, make an if statement that if Feu is NaN then break then print out other important variables: iteration number, dx, dy...etc.


5. It looks like you have 4 BCs for top, bottom, left and right wall. For your first implementation, keep them simple: perhaps only left and right wall are constants. I dont know, I dont work with parallel pipe but make keep them simple. The best thing is to get your SIMPLE algorithm works first before tweaking.

6. Make sure your Gauss Seidel scheme works perfectly first before plugging it in the SIMPLE algorithm.

TL,DR: just print stuff out, and keep track of when stuff becomes NaN. When in doubt, try to do a hand calculation of the expression that becomes NaN and backtrack.
A side note on gauss_seidel1.m, not sure why you do: PHI = phi, use a different variable name would help I think. Matlab is case sensitive and you might have written a wrong variable somewhere.

Last edited by manle0312; April 16, 2020 at 07:43.
manle0312 is offline   Reply With Quote

Old   May 28, 2020, 20:50
Default
  #5
New Member
 
Vaibhav
Join Date: Feb 2020
Posts: 5
Rep Power: 6
vaibhavkhanna is on a distinguished road
Thanks Man Le for your advice. I found several bugs and now it finally seems to converge. However, the issue I am facing with my simulations now is that the residuals (L2 norm of mass imbalance) for different Re and different fluids all seem to oscillate about a fixed value instead of decreasing as the iterations proceed. The termination criteria for my simulation is never met. What are your thoughts on this?
Here are some of the residual plots from my simulation. The velocity values are oscillating about the right solution (the centreline velocity is 1.5 times the inlet velocity) but the residuals do not decrease with iterations.

https://drive.google.com/file/d/16fb...ew?usp=sharing
vaibhavkhanna is offline   Reply With Quote

Reply

Tags
cfd, nan error, parallel plate flow, simple algorithm


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
Finite Volume -- SIMPLE Algorithm Roger Main CFD Forum 9 September 25, 2023 13:04
SIMPLE algorithm Fernando Herrera Main CFD Forum 5 July 17, 2016 05:06
simpleFoam parallel AndrewMortimer OpenFOAM Running, Solving & CFD 12 August 7, 2015 19:45
Injection between parallel plates, homogenous mode Terje CFX 7 September 7, 2008 20:51
About Phase Coupled SIMPLE (PC-SIMPLE) algorithm Yan Kai Main CFD Forum 0 April 18, 2007 04:48


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