AMATH 581 ( c○J. N. Kutz) 37n=N+1Δ xn=Nn=N-1Δ yyψ mnψm(n-1)ψ (m-1)nψ m(n+1)ψ (m+1)nn=3n=2n=1m=1 m=2 m=3m=M-1 m=M m=M+1xFigure 12: Discretization stencil for solving for the streamfunction with secondorderaccurate central difference schemes. Note that ψ mn = ψ(x m ,y n ).where⎡A=⎢⎣and−4 1 0 1 1 0 0 0 0 0 0 0 1 0 0 01 −4 1 0 0 1 0 0 0 0 0 0 0 1 0 00 1 −4 1 0 0 1 0 0 0 0 0 0 0 1 01 0 1 −4 0 0 0 1 0 0 0 0 0 0 0 11 0 0 0 −4 1 0 1 1 0 0 0 0 0 0 00 1 0 0 1 −4 1 0 0 1 0 0 0 0 0 00 0 1 0 0 1 −4 1 0 0 1 0 0 0 0 00 0 0 1 1 0 1 −4 0 0 0 1 0 0 0 00 0 0 0 1 0 0 0 −4 1 0 1 1 0 0 00 0 0 0 0 1 0 0 1 −4 1 0 0 1 0 00 0 0 0 0 0 1 0 0 1 −4 1 0 0 1 00 0 0 0 0 0 0 1 1 0 1 −4 0 0 0 11 0 0 0 0 0 0 0 1 0 0 0 −4 1 0 10 1 0 0 0 0 0 0 0 1 0 0 1 −4 1 00 0 1 0 0 0 0 0 0 0 1 0 0 1 −4 10 0 0 1 0 0 0 0 0 0 0 1 1 0 1 −4⎤⎥⎦(2.1.13)ψ =(ψ 11 ψ 12 ψ 13 ψ 14 ψ 21 ψ 22 ψ 23 ψ 24 ψ 31 ψ 32 ψ 33 ψ 34 ψ 41 ψ 42 ψ 43 ψ 44 ) T(2.1.14a)
AMATH 581 ( c○J. N. Kutz) 38ω =δ 2 (ω 11 ω 12 ω 13 ω 14 ω 21 ω 22 ω 23 ω 24 ω 31 ω 32 ω 33 ω 34 ω 41 ω 42 ω 43 ω 44 ) T .(2.1.14b)Any matrix solver can then be used to generate the values of thetwo-dimensionalstreamfunction which are contained completely in the vector ψ.Step 2: Time-SteppingAfter generating the matrix A and the value of the streamfunction ψ(x, y, t),we use this updated value along with the current value of the vorticity to take atime step ∆t into the future. The appropriate equation is the advection-diffusionevolution equation:∂ω∂t +[ψ, ω] =ν∇2 ω. (2.1.15)Using the definition of the bracketed term and the Laplacian, this equation is∂ω∂t = ∂ψ ∂ω∂y ∂x − ∂ψ (∂ω ∂ 2 )∂x ∂y + ν ω∂x 2 + ∂2 ω∂y 2 . (2.1.16)Second order central-differencing discretization then yields( )( )∂ω ψ(x, y+∆y, t)−ψ(x, y−∆y, t) ω(x+∆x, y, t)−ω(x−∆x, y, t)=∂t2∆y2∆x( )( )ψ(x+∆x, y, t)−ψ(x−∆x, y, t) ω(x, y+∆y, t)−ω(x, y−∆y, t)−2∆x2∆y{ ω(x+∆x, y, t)−2ω(x, y, t)+ω(x−∆x, y, t)+ν∆x 2}ω(x, y+∆y, t)−2ω(x, y, t)+ω(x, y−∆y, t)+∆y 2 . (2.1.17)This is simply a large system of differential equations which can be steppedforward in time with any convenient time-stepping algorithm suchas4thorderRunge-Kutta. In particular, given that there are N +1 points and periodicboundary conditions, this reduces the system of differential equationstoanN ×N coupled system. Once we have updated the value of the vorticity, we mustagain update the value of streamfunction to once again update thevorticity.This loop continues until the solution at the desired future time is achieved.Figure 13 illustrates how the five-point, two-dimensional stencil advances thesolution.The behavior of the vorticity is illustrated in Fig. 14 where the solution isadvanced for eight time units. The initial condition used in this simulation is)ω 0 = ω(x, y, t =0)=exp(−2x 2 − y2. (2.1.18)20This stretched Gaussian is seen to rotate while advecting and diffusingvorticity.Multiple vortex solutions can also be considered along with oppositely signedvortices.