
[Sponsors] 
Using the Simple Algorithm for 2D Staggered Grid in Matlab 

LinkBack  Thread Tools  Search this Thread  Display Modes 
December 9, 2010, 16:29 
Using the Simple Algorithm for 2D Staggered Grid in Matlab

#1 
New Member
Joshua Lieblong
Join Date: Dec 2010
Posts: 1
Rep Power: 0 
I am trying to write code for a project in Matlab. It is a pipe flow problem using the simple algorithm for a 2D staggered grid in matlab. I am quite new to the programming world and have sort of been tossed into it quickly in grad school. I need some help coding, so if anyone can offer it please let me know.


April 1, 2014, 15:00 
have you figured this out yet

#2 
New Member
Banma Kadachha
Join Date: Mar 2014
Posts: 3
Rep Power: 8 
If you have figured this out, could you please send me the code at banmakadachha@gmail.com


April 1, 2014, 16:56 

#3 
Senior Member
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 205
Rep Power: 15 
You may be able to modify the staggered lid driven cavity code available in the MATLAB file exchange to suit your needs:
http://www.mathworks.com/matlabcentr...encavityflow 

April 9, 2014, 16:41 
Matlab code for SIMPLEC Algortihm

#4 
Member
Mansoor Ahmed
Join Date: Apr 2014
Location: Pakistan
Posts: 45
Rep Power: 8 
I am trying to write Matlab code for one dimensional convergent nozzle having 5 pressure pressure nodes and 4 velocity nodes using SIMPLEC algorithm.I have done the necessary changes required in SIMPLE i.e changed the value of d term for both momentum equation and pressure correction equations. my problem is that my code is not converging it is giving NaN error.I am using an under relaxation of 0.8. SIMPLE code is running properly and converges after 18 iterations. I have kept the criteria of convergence the residual for the momentum equations.some help required....
thanks 

April 9, 2014, 17:55 

#5 
Senior Member
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 205
Rep Power: 15 
Can you please post both the SIMPLE and SIMPLEC versions of the codes? As they are onedimensional, it should be relatively easy to find the error.


April 10, 2014, 03:16 
Matlab code for SIMPLEC Algortihm

#6 
Member
Mansoor Ahmed
Join Date: Apr 2014
Location: Pakistan
Posts: 45
Rep Power: 8 
here are the values for d term for SIMPLEC algorithm and the corresponding residuals.
D_2=((A_B+A_C)/(2))/((AP(2)(AP(3)+AP(1)))); D_1=((A_B+A_A)/(2))/((AP(1)AP(2))); and similar for D_3, D_4 where AP(1) and AP(2) and so on are the coefficients of velocities As in SIMPLE d is only equal to D_2=((A_B+A_C)/(2*AP(2))); I think the error is in TDMA solution of pressure correction equation its code A_W_B=(density*D_1*((A_B+A_A)/2)); A_E_B=(density*D_2*((A_B+A_C)/2)); F_W_B=(density*U1_STAR*((A_B+A_A)/2)); F_E_B=(density*U2_STAR*((A_B+A_C)/2)); A_P_B=A_W_B+A_E_B; b_B=F_W_BF_E_B; A_W_C=(density*D_2*((A_B+A_C)/2)); A_E_C=(density*D_3*((A_D+A_C)/2)); F_W_C=(density*U2_STAR*((A_B+A_C)/2)); F_E_C=(density*U3_STAR*((A_D+A_C)/2)); A_P_C=A_W_C+A_E_C; b_C=F_W_CF_E_C; A_W_D=(density*D_3*((A_D+A_C)/2)); A_E_D=(density*D_4*((A_D+A_E)/2)); F_W_D=(density*U3_STAR*((A_C+A_D)/2)); F_E_D=(density*U4_STAR*((A_D+A_E)/2)); A_P_D=A_W_D+A_E_D; b_D=F_W_DF_E_D; P_DASH_A=0; P_DASH_E=0; A=zeros(3); A(1,1)=A_P_B; A(1,2)=A_E_B; A(2,1)=A_W_C; A(2,2)=A_P_C; A(2,3)=A_E_C; A(3,2)=A_W_D; A(3,3)=A_P_D; b(1)=b_B; b(2)=b_C; b(3)=b_D; m=3; X=zeros(m,1); A(1,2)= A(1,2) / A(1,1); b(1)= b(1) / A(1,1); for i=2:m1 press= A(i,i)  (A(i,i1) * A(i1,i)); A(i,i+1)= A(i,i+1) / press; b(i)= ( b(i)  A(i,i1) * b(i1) ) / press; end i=m; X(m)=(b(i)  (A(i,i1) * b(i1))) / (A(i,i)  (A(i,i1) * A(i1,i))); for a=m1:1:1 X(a)= b(a)(A(a,a+1) * X(a+1)); end and the residual I have set for convergence is r(1)=(AP(1)*FU(1))SU(1); r(2)=(AP(2)*FU(2))((F_w_2*FU(1))+SU(2)); r(3)=(AP(3)*FU(3))((F_w_3*FU(2))+SU(3)); r(4)=(AP(4)*FU(4))((F_w_4*FU(3))+SU(4)); res= abs(r(1)+r(2)+r(3)+r(4)); if (res<=0.00001) break end kindly check if there are any errors in my code thanks 

February 18, 2019, 14:56 

#7 
New Member
ahr
Join Date: Feb 2017
Posts: 4
Rep Power: 5 
HI,
Im writting the same problem in fortran 90; I got the same (underrelaxed) results until the first iteration for 5 nodes, it means: u1=1.78856 u2=2.29959 u3=3.21942 u4=5.36571 and also I got: pA=9.08536 pB=8.8115 pC=8.3396 pD=7.4664 pE=0 the issue is that once I run the next iteration, I dont get the mentioned equation in the book, at node 1: 1.20425(U1)=1.98592, I get: 1.14848(U1)=1.412218 I did it by hand, I dont know what I am doing wrong. 

February 19, 2019, 05:38 

#8 
Senior Member
duri
Join Date: May 2010
Posts: 245
Rep Power: 13 
Attach a debugger check along with your hand calculation.


Tags 
matlab, pipe flow, simple algorithm, staggered grid 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
SIMPLE algorithm  Fernando Herrera  Main CFD Forum  5  July 17, 2016 05:06 
Finite Volume  SIMPLE Algorithm  Roger  Main CFD Forum  8  June 25, 2011 23:49 
Staggered grid (sedimentation of solid particles)  TTY  Main CFD Forum  0  October 30, 2010 13:15 
Grid Independent Solution  Chuck Leakeas  Main CFD Forum  2  May 26, 2000 12:18 
SIMPLE algorithm  Jonathan Castro  Main CFD Forum  3  December 10, 1999 05:59 