We have two equations to solve.
We have the stream function equation and we have
the time-dependent vorticity equation.
Let's first discuss the computation
of the stream function.
We're going to assume then that the vorticity
is known and we want to find the stream function.
We need to convert this to a matrix equation and then use
a direct method of solution
using the backslash operator in Matlab.
What we do is we apply natural ordering,
I talked about this in my numerical methods class.
Let's say we have a grid,
so I'll draw a grid here.
Let's draw three lines.
This is our Psi_i direction,
this is our Theta_j direction.
This is our grid,
so natural ordering then orders the points on
this grid in such that we go in this direction,
and then we're coming around and then we'll go this way,
come around, and we'll go this direction.
We've ordered the point 1,
2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12,
13, 14, 15, and so on.
What that means then is that we've taken our i,
j point on the grid and converted it to
a single index k which the conversion is
that it's your i where you are in
the horizontal line plus the j minus 1,
where you are on
the vertical line starting at j equals 1,
times the number of points in the horizontal line,
which is n. We have n points in
cosine and the m points in Theta.
We then convert this to a single index equation.
To do that, it's easier to first define
Omega tilde of i comma j equal to this right-hand side,
which is h squared e^2 cosine i Omega ij.
I do that because
this exponential factor only has an i index,
so that will complicate the conversion.
Once we do that, we can convert this equation.
What do we have?
Well, we have 4 Psi_k for this first term,
this increments i by 1,
so that becomes minus Psi_k plus 1.
This term becomes minus Psi_k minus 1.
But now we jump j by 1.
If we jump j by 1,
we're jumping the index by n,
so that becomes minus Psi k plus n,
and then minus Psi_k minus
n. Then the right-hand side becomes
our new variable Omega tilde sub
k. This becomes our single index equation.
If we put Psi now in a column vector,
then this is a matrix A times our column vector Psi,
using natural ordering is equal to our right-hand side b.
This is the equation we're
going to solve computationally.
This A then will have four going down
the diagonal minus 1 and a minus 1,
one above and one below the diagonal,
a minus 1n above the diagonal
and a minus 1n below the diagonal.
The right-hand side is this Omega tilde.
This matrix A then is
multiplying a column vector that is of length m times n,
so this matrix A is m times n
by m times n size, very large matrix.
This is our solution for
Psi from the finite difference equation,
but we have to treat boundary values differently.
We have to adjust
this matrix A and this right-hand side b,
so that we enforce all of
the boundary conditions when k lies on the boundaries.
That's the four sides of our grid.
This is true,
we get the matrix from here,
but we need to treat the boundary conditions separately.
We need to enforce
the boundary conditions in the matrix equation.
Let me summarize.
We have two equations to solve,
one of them is the stream function equation,
this is the discretize version.
Previously for the steady-flow solution,
we did iterative type of solutions.
Now, we're going to choose to do
a direct solution of this equation.
That means we need to write
this equation as a matrix equation.
We apply natural ordering so that we can
stack the stream function into a column vector.
Then this equation becomes a matrix times
the column vector of
the stream function equals the right-hand side.
This matrix is large,
mn by mn,
but we can solve this
basically by doing an LU decomposition of
A one time and then using
Gaussian elimination to solve A whenever b changes.
The vorticity will be evolving in time.
This is the equation except for
the boundary values when k
lies on the boundary of the domain,
then we need to modify the matrix A so that
this equation will enforce our boundary conditions.
I'm Jeff Chasnov.
Thanks for watching,
and I'll see you in the next video.