SIMPLE ALGORITHM FOR PIPE FLOW

17 views (last 30 days)
majid
majid on 1 Jul 2014
Edited: majid on 1 Jul 2014
I am trying to write a code in Matlab for semi implicit pressure linked equations I have put about a month for doing this but i am still unable to do it I have used velocity inlet and pressure outlet boundary conditions and also two walls boundary conditions jacobi algorithms is used for solving the equations and upwind scheme is used if there is any misunderstanding in my code please tell me and i will explain it to you I think I have problems with boundary conditions I have attached a picture in this coment the green nodes are pressure nodes the red and blue nodes are for the velocity in the x direction and y direction respectively what is the boundary condition for pressure? for example I have cut the link to the west of the first column of pressure nodes and set the velocity of the the west boundary to the velocity inlet in additon when I am using a pressure outlet boundary condition am I able to set the pressure of outlet to zero? the problem with the code is that velocity in the pipe directon reduces when the distance from the inlet increases until it becomes negative i have tried to change the guessed pressure I have checked my program for about a thousand times Please help :D

Accepted Answer

Jan
Jan on 1 Jul 2014
You forgot to ask a question. It is impossible to guess, which problem you have. It is extremely hard to understand a foreign code without meaningful comments.
Your "else if" constructions are confusing. Please use either "elseif" or move the two commands to different lines, such that the code indentations reflects the inner structure of the code.
Using Matlab's power of matrix operations would simplify the code. E.g.:
for j=1:ny
for i=1:nx-1
p(i,j)=p(i,j)+alfap*pc(i,j);
end
end
To:
p(1:nx-1, 1:ny) = p(1:nx-1, 1:ny) + alfap * pc(1:nx-1, 1:ny);
And perhaps you can replace "1:ny" by ":" in addition.
If you omit the tedious clear all, you could use the debugger to see, what's going on in your code. Impeding the debugger by this brute clearing is a really bad idea.
  2 Comments
majid
majid on 1 Jul 2014
Edited: majid on 1 Jul 2014
thank you for your answer I think I have problems with boundary conditions I have attached a picture in this coment the green nodes are pressure nodes the red and blue nodes are for the velocity in the x direction and y direction respectively what is the boundary condition for pressure? for example I have cut the link to the west of the first column of pressure nodes and set the velocity of the the west boundary to the velocity inlet in additon when I am using a pressure outlet boundary condition am I able to set the pressure of outlet to zero? I know my else if construction is confusing but let me explain it to you the domain of this problem has four sides for example for the southern boundary for the velocity in the x direction we have: i=1:nx and j=1 that nx is the number of the segments in the x direction when i=1 and j=1 this node is the left boundary condition which is the velocity inlet so velocity in this cell is set to inlet velocity or when i=nx in this cell the pressure outlet boundary is assumed so the velocity of this cell is equaled the velocity of the cell in i=nx+1 and j=1 this procedure continues in the 4 side of this domain and then if nodes are not in the boundary conditions the governing equation is used I hope my explanations were explicit Thanks a lot
majid
majid on 1 Jul 2014
I have updated the code and changed it based on your answer however I can not change all the for loops by matlab power of matrix cause the counter if the involved matrixes in almost all of the lines are not the same

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!