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

Using the Simple Algorithm for 2D Staggered Grid in Matlab

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

Like Tree3Likes
  • 1 Post By banmakadachha
  • 1 Post By tas38
  • 1 Post By engrmansoor2534

Reply
 
LinkBack Thread Tools Display Modes
Old   December 9, 2010, 16:29
Default Using the Simple Algorithm for 2D Staggered Grid in Matlab
  #1
New Member
 
Joshua Lieblong
Join Date: Dec 2010
Posts: 1
Rep Power: 0
jal121387 is on a distinguished road
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.
jal121387 is offline   Reply With Quote

Old   April 1, 2014, 14:00
Default have you figured this out yet
  #2
New Member
 
Banma Kadachha
Join Date: Mar 2014
Posts: 3
Rep Power: 4
banmakadachha is on a distinguished road
If you have figured this out, could you please send me the code at banmakadachha@gmail.com
Md. Intishar likes this.
banmakadachha is offline   Reply With Quote

Old   April 1, 2014, 15:56
Default
  #3
Senior Member
 
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 120
Rep Power: 9
tas38 is on a distinguished road
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...en-cavity-flow
tas38 is offline   Reply With Quote

Old   April 9, 2014, 15:41
Default Matlab code for SIMPLEC Algortihm
  #4
Member
 
Mansoor Ahmed
Join Date: Apr 2014
Location: Pakistan
Posts: 45
Rep Power: 4
engrmansoor2534 is on a distinguished road
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
engrmansoor2534 is offline   Reply With Quote

Old   April 9, 2014, 16:55
Default
  #5
Senior Member
 
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 120
Rep Power: 9
tas38 is on a distinguished road
Can you please post both the SIMPLE and SIMPLEC versions of the codes? As they are one-dimensional, it should be relatively easy to find the error.
engrmansoor2534 likes this.
tas38 is offline   Reply With Quote

Old   April 10, 2014, 02:16
Default Matlab code for SIMPLEC Algortihm
  #6
Member
 
Mansoor Ahmed
Join Date: Apr 2014
Location: Pakistan
Posts: 45
Rep Power: 4
engrmansoor2534 is on a distinguished road
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_B-F_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_C-F_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_D-F_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:m-1

press= A(i,i) - (A(i,i-1) * A(i-1,i));

A(i,i+1)= A(i,i+1) / press;

b(i)= ( b(i) - A(i,i-1) * b(i-1) ) / press;
end

i=m;

X(m)=(b(i) - (A(i,i-1) * b(i-1))) / (A(i,i) - (A(i,i-1) * A(i-1,i)));

for a=m-1:-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
Md. Intishar likes this.
engrmansoor2534 is offline   Reply With Quote

Reply

Tags
matlab, pipe flow, simple algorithm, staggered grid

Thread Tools
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 On
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 08:41.