CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General 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 Search this Thread 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, 15:00
Default have you figured this out yet
  #2
New Member
 
Banma Kadachha
Join Date: Mar 2014
Posts: 3
Rep Power: 12
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, 16:56
Default
  #3
Senior Member
 
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 220
Rep Power: 19
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, 16:41
Default Matlab code for SIMPLEC Algortihm
  #4
Member
 
Mansoor Ahmed
Join Date: Apr 2014
Location: https://t.me/pump_upp
Posts: 47
Rep Power: 12
engrmansoor2534 is on a distinguished road
Send a message via ICQ to engrmansoor2534 Send a message via AIM to engrmansoor2534 Send a message via Yahoo to engrmansoor2534
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, 17:55
Default
  #5
Senior Member
 
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 220
Rep Power: 19
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, 03:16
Default Matlab code for SIMPLEC Algortihm
  #6
Member
 
Mansoor Ahmed
Join Date: Apr 2014
Location: https://t.me/pump_upp
Posts: 47
Rep Power: 12
engrmansoor2534 is on a distinguished road
Send a message via ICQ to engrmansoor2534 Send a message via AIM to engrmansoor2534 Send a message via Yahoo to engrmansoor2534
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

Old   February 18, 2019, 14:56
Default
  #7
ahr
New Member
 
ahr
Join Date: Feb 2017
Posts: 4
Rep Power: 9
ahr is on a distinguished road
HI,

Im writting the same problem in fortran 90; I got the same (under-relaxed) 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.
ahr is offline   Reply With Quote

Old   February 19, 2019, 05:38
Default
  #8
Senior Member
 
duri
Join Date: May 2010
Posts: 245
Rep Power: 17
duri is on a distinguished road
Attach a debugger check along with your hand calculation.
duri is offline   Reply With Quote

Reply

Tags
matlab, pipe flow, simple algorithm, staggered grid

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
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
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


All times are GMT -4. The time now is 16:39.