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

Backward Facing Step using Simple Algorithm

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

Like Tree9Likes
  • 3 Post By aar_out
  • 2 Post By FMDenaro
  • 4 Post By aar_out

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 6, 2017, 12:12
Default Backward Facing Step using Simple Algorithm
  #1
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
Hi all,

I've solved the lid-driven cavity flow problem in MATLAB using the Simple algorithm. I am now working to solve the backward-facing step flow problem, also using the simple algorithm. Based on my literature review, I should be able to modify the lid-driven cavity flow code for this purpose by simply changing the boundary conditions. I've tried to do this several different ways, but can't seem to get it right.

Here are the boundary conditions:

inlet:
u = 4*Umax*(y/Hs)*(1-y/Hs); Hs = height of parabolic flow inlet
v = 0

outlet:
du/dx = dv/dx = 0

top and bottom walls:
u = v = 0

Reynolds number is defined as Re = Umax(H-Hs)/v; H = total height

I've attached the MATLAB code that I've been working on. Any help would be greatly appreciated!
Attached Files
File Type: zip Backward_AO_CFD_Online.zip (2.2 KB, 133 views)
ssh123, TheVictorVS and snowquote like this.
aar_out is offline   Reply With Quote

Old   March 6, 2017, 12:17
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
It is much better you explain the problems and post some plot of your solution
lcarasik and TheVictorVS like this.
FMDenaro is offline   Reply With Quote

Old   March 6, 2017, 12:31
Default
  #3
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
Okay, here are some of the simulation details:

H = 1.5
Hs = 1.0
h = H-Hs
L = 30*h
Re = 10 (uMax = 20)
Iterations = 1000

Plot is attached. Notice that all of the velocities are negative, which is counter-intuitive with a positive x parabolic inflow. As I increase the Re to 100, the u-velocity becomes more negative.
Attached Images
File Type: jpg u_centerline_Re_10.jpg (15.1 KB, 68 views)
aar_out is offline   Reply With Quote

Old   March 6, 2017, 12:38
Default
  #4
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
since H=1.5 and Hs=1, using you function the flow inlet u(y) is described for y=1 to 1.5 and u is negative at the inflow
FMDenaro is offline   Reply With Quote

Old   March 6, 2017, 12:47
Default
  #5
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
Thanks FMDenaro.

I was given that specific parabolic function as part of the problem description, and had noticed that the velocity profile was negative at the left boundary. I think I will either have to change the origin point from the bottom left to top left, or derive a new inlet parabolic function.
aar_out is offline   Reply With Quote

Old   March 6, 2017, 14:54
Default
  #6
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
Okay, next question:

To solve for x-momentum as uStar, I use the following code:

% setup coefficients
for i = 2:Nx
for j = 2:Ny+1
% convective flux using central differencing
uCe = dx*0.5*(uOld(i,j)+uOld(i+1,j));
uCw = dx*0.5*(uOld(i,j)+uOld(i-1,j));
uCn = dy*0.5*(vOld(i,j)+vOld(i+1,j));
uCs = dy*0.5*(vOld(i,j-1)+vOld(i+1,j-1));
% central coefficient using applied under-relaxation
uDx = dy/dx*(1/Re);
uDy = dx/dy*(1/Re);
auP(i,j) = (0.5*(uCe+uCw+uCn+uCs)+2*uDx+2*uDy)/alphaU;
% boundary coefficients using hybrid schemes
% change numerical method as required
auE_h = [-uCe,-0.5*uCe+uDx,0];
auW_h = [uCw,-0.5*uCw+uDx,0];
auN_h = [-uCn,-0.5*uCn+uDy,0];
auS_h = [uCs,-0.5*uCs+uDy,0];
auE(i,j) = max(auE_h);
auW(i,j) = max(auW_h);
auN(i,j) = max(auN_h);
auS(i,j) = max(auS_h);
% set u velocity component of PCE
dU(i,j) = dx/auP(i,j);
end
end
% use previous calculation as initial guess in numerical method
uStar = uOld;

(similar code is used to solve for y-momentum).

Notice the uDx and uDy values contain the Re value. When I have it coded as is, the solution blows up, as in the first image attached. However, if I do not divide by Re (i.e. for uDx = dy/dx*Re), then my solution trends in the right way, but with the wrong u-momentum values (as in the second image attached).

Note that for the solution that 'blows up' I only ran 20 iterations because it fails with more, while for the solution that trends properly with wrong values, I ran at 200 and 1000 iterations (i.e. it doesn't 'blow up' with more iterations). I've also re-attached my code, as it has been changed since the first post.

Note also that when coded as uDx = dy/dx*(1/Re), the lid-driven cavity problem solves just fine.

Again, any advice would be appreciated.
Attached Images
File Type: jpg u_centerline_Re_100_fail.jpg (15.9 KB, 33 views)
File Type: jpg u_centerline_Re_100_fail_trend.jpg (14.8 KB, 34 views)
Attached Files
File Type: zip Backward_Step_Matlab.zip (2.2 KB, 64 views)
aar_out is offline   Reply With Quote

Old   March 9, 2017, 10:04
Default
  #7
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
I've continued to tinker with the backward step flow MATLAB code, and the simulation is trending in the right way.

My question now is about boundary conditions. I have the following:

Inlet:
u = parabolic
v = 0

Outlet:
du/dx = dv/dx = 0

Top and Bottom:
u = v = 0

I've coded this as follows:

%Left and Right
for j = 1:Ny
if y(1,j)>Hs&&y(1,j)<H
Left(1,j) = 4*uMax*(y(1,j)/Hs)*(1-(y(1,j)/Hs));
%Left(1,j) = 100;
else
Left(1,j) = 0.0;
end
uOld(1,j) = uOld(2,j) - Left(1,j);
uOld(Nx+2,j) = uOld(Nx+1,j);
%vOld(1,j) = vOld(2,j);
%vOld(Nx+2,j) = vOld(Nx+1,j);
end

%Top and Bottom
for i = 1:Nx+1
%uOld(i,1)= uOld(i,2);
%uOld(i,Ny+1)= uOld(i,Ny);
vOld(i,1)= vOld(i,2);
vOld(i,Ny+1)= vOld(i,Ny);
end

Is this a reasonable approach?
aar_out is offline   Reply With Quote

Old   March 9, 2017, 11:40
Default
  #8
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
I don't think that posting your code is useful... if you have a problem in the solution describe it, give details, figures and a list of the main setting.
FMDenaro is offline   Reply With Quote

Old   March 9, 2017, 12:49
Default
  #9
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
Thanks FMDenaro. I don't intend to use CFD Online as a 'code editor' - I just assumed that someone may have done something similar to me and could offer quick advice.

My assumption is that I do not need to change the SIMPLE algorithm code from that used in the lid-driven problem, and instead need to change my left and right (inlet and outlet) boundary conditions for the backward facing step problem.

My approach (given the boundary conditions presented in my previous post) has been to define the parabolic function at x = 1 for all y using a 'for' statement. I've then attempted to code the boundary conditions as previously described.

My results are okay, and I can 'tune' them using the the kinematic viscosity. However, my concern is that my original assumption (i.e. that the SIMPLE algorithm doesn't change) is incorrect.
aar_out is offline   Reply With Quote

Old   March 9, 2017, 12:55
Default
  #10
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by aar_out View Post
Thanks FMDenaro. I don't intend to use CFD Online as a 'code editor' - I just assumed that someone may have done something similar to me and could offer quick advice.

My assumption is that I do not need to change the SIMPLE algorithm code from that used in the lid-driven problem, and instead need to change my left and right (inlet and outlet) boundary conditions for the backward facing step problem.

My approach (given the boundary conditions presented in my previous post) has been to define the parabolic function at x = 1 for all y using a 'for' statement. I've then attempted to code the boundary conditions as previously described.

My results are okay, and I can 'tune' them using the the kinematic viscosity. However, my concern is that my original assumption (i.e. that the SIMPLE algorithm doesn't change) is incorrect.


If you wrote in a general way, the algorithm incorporates general BC.s so that you have only to set BC.s for inflow+wall on the left side and an outflow on the right side.
What I suggest is to debug the code, sometimes a code can work fine for totally confined flows but can show problems for inflow/outflow conditions. And, often, a bug is hidden...
FMDenaro is offline   Reply With Quote

Old   March 9, 2017, 13:07
Default
  #11
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
Very helpful FMDenaro - thanks! I've actually noticed several bugs in the confined flow scenario that needed fixing for the inflow/outflow scenario.

I'll keep working on the problem and post when I have more questions or a consistent solution.
aar_out is offline   Reply With Quote

Old   August 15, 2017, 19:41
Default
  #12
New Member
 
aaron outhwaite
Join Date: Mar 2016
Posts: 10
Rep Power: 10
aar_out is on a distinguished road
I've finished working on this bit of research, and I've posted the resulting paper on Scribd:

https://www.scribd.com/document/3563...MPLE-Algorithm

I'll be converting the MATLAB code here developed to Python code in the upcoming months, so I'll most likely post additional updates. Stay tuned!
lcarasik, jhawisa, MMNCH and 1 others like this.
aar_out is offline   Reply With Quote

Old   November 28, 2017, 15:53
Default Great
  #13
New Member
 
Ebara
Join Date: Nov 2017
Posts: 1
Rep Power: 0
Amin jafari is on a distinguished road
Can you send me
How do you write this code
I want your file
Mohammadaminjafari1372@yahoo.com
Amin jafari is offline   Reply With Quote

Old   March 10, 2018, 12:43
Default
  #14
New Member
 
Darsh Nathawani
Join Date: Feb 2018
Posts: 4
Rep Power: 8
Darsh Nathawani is on a distinguished road
Quote:
Originally Posted by aar_out View Post
I've finished working on this bit of research, and I've posted the resulting paper on Scribd:

https://www.scribd.com/document/3563...MPLE-Algorithm

I'll be converting the MATLAB code here developed to Python code in the upcoming months, so I'll most likely post additional updates. Stay tuned!
Thank you for sharing the paper.
Darsh Nathawani is offline   Reply With Quote

Old   March 25, 2019, 16:15
Default
  #15
New Member
 
Jamal
Join Date: Jul 2017
Posts: 2
Rep Power: 0
jhawisa is on a distinguished road
Dear Aaron: thanks for posting the code..

minor comment on your code:



should your (yy) in the code be :
yy= H-dy/2:-dy:dy/2
instead of

yy= H:-dy:0

also the same change for y ?
jhawisa is offline   Reply With Quote

Reply

Tags
backward facing step, boundary condition, matlab, simple algorithm

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
Backward facing step; x/H; U/U0; diemsionless analysis; paraview idrama OpenFOAM 1 December 3, 2013 17:10
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 13:58
Velocity drop over backward facing step warlocklw CFX 2 February 9, 2012 21:24
air-fuel mixing in backward facing step abdullahkarimi Main CFD Forum 0 March 19, 2011 18:39
Corner Vortex for Backward Facing Step Patrick G. Hu Main CFD Forum 0 August 6, 2002 09:34


All times are GMT -4. The time now is 04:29.