SIMPLE ALGORITHM FOR PIPE FLOW
17 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!