how do you implement an iteration for a stream function?
Show older comments
Hello, so I'm trying to create a stream function contour plot. I created my mesh and have implemented my boundary conditions that I calculated by hand. I'm getting my functions from my fluids book, and it has psi as psi = psi(i,j)+ .25*( psi(i,j+1) + psi(i,j-1) + psi(i+1,j) + psi(i-1,j)). So I run this over the i and j components that I want to calculate, and I am not getting the values I want because it is not iterating and I don't know how to do that. For reference I am using an excel version of this where I calculated in node using that equation mentioned earlier. I have a snapshot of my excel sheet and the calculation I used.

and this the code I currently have for calculating the stream function after the boundary conditions
for i = 2:Nx
for j = 2:Ny
psi(i,j) = psi(i,j)+ .25*( psi(i,j+1) + psi(i,j-1) + psi(i+1,j) + psi(i-1,j));
end
end
Thank for any help you guys can provide
4 Comments
Walter Roberson
on 3 May 2019
What did you initialize psi to?
Notice by the way that psi(i, j-1) and psi(i-1,j) are referring to values that you calculated on this run, not to just initially stored values. For example when you are working on 3 3 then it accesses the 3 2 value that you just stored on the immediately prior j iteration and the 2 3 value you calculated on the previous i iteration. Order of calculation is important: you only iterate most as you head down and right. The bottom right corner will have been affected by all of the other iterations.
Rashid Coulibaly
on 3 May 2019
Walter Roberson
on 3 May 2019
What boundary conditions are you setting? If you are not initializing psi row 1 or column 1 at least then all of your calculation would be on zeros.
Rashid Coulibaly
on 3 May 2019
Answers (0)
Categories
Find more on Hypothesis Tests 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!