Processing math: 53%
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

17: Flow Past an Obstacle

( \newcommand{\kernel}{\mathrm{null}\,}\)

We now consider a classic problem in computational fluid dynamics: the steady, two-dimensional flow past an obstacle. Here, we consider flows past a rectangle and a circle.

First, we consider flow past a rectangle. The simple Cartisian coordinate system is most suitable for this problem, and the boundaries of the internal rectangle can be aligned with the computational grid. Second, we consider flow past a circle. Here, the polar coordinate system is most suitable, and this introduces some additional analytical complications to the problem formulation. Nevertheless, we will see that the computation of flow past a circle may in fact be simpler than flow past a rectangle. Although flow past a rectangle contains two dimensionless parameters, flow past a circle contains only one. Furthermore, flow past a circle may be solved within a rectangular domain having no internal boundaries.

Flow past a rectangle

The free stream velocity is given by u=Uˆx and the rectangular obstacle is assumed to have width W and height H. Now, the stream function has units of velocity times length, and the vorticity has units of velocity divided by length. The steady, two-dimensional Poisson equations for the stream function and the vorticity, given by (16.14) and (16.18), may be nondimensionalized using the velocity U and the length W. The resulting dimensionless equations can be written as

2ψ=ω,2ω=Re(ψxωyψyωx),

where the dimensionless parameter Re is called the Reynolds number. An additional dimensionless parameter arises from the aspect ratio of the rectangular obstacle, and is denoted by a. These two dimensionless parameters are defined by

Re=UWV,a=WH.

A solution for the scalar stream function and scalar vorticity field will be sought for different values of the Reynolds number Re at a fixed aspect ratio a

Finite difference approximation

We construct a rectangular grid for a numerical solution. We will make use of square grid cells, and write

xi=ih,i=0,1,,Nx;yj=jh,j=0,1,,Ny,

where Nx and Ny are the number of grid cells spanning the x - and y-directions, and h is the side length of a grid cell.

To obtain an accurate solution, we require the boundaries of the obstacle to lie exactly on the boundaries of the grid cell. The width of the obstacle in our dimensionless formulation is unity, and we place the front of the obstacle at x=mh and the back of the obstacle at x=(m+I)h, where we must have

hI=1

With I specified, the grid spacing is determined by h=1/I.

We will only look for steady solutions for the flow field that are symmetric about the midline of the obstacle. Assuming symmetry, we need only solve for the flow field in the upper half of the domain. We place the center line of the obstacle at y=0 and the top of rectangle at hJ. The dimensionless half-height of the obstacle is given by 1/2a, so that

hJ=12a.

Forcing the rectangle to lie on the grid lines constrains the choice of aspect ratio and the values of I and J such that

a=I2J

Reasonable values of a to consider are a=,1/4,1/2,1,2,4,, etc, and I and J can be adjusted accordingly.

The physics of the problem is specified through the two dimensionless parameters Re and a. The numerics of the problem is specified by the parameters Nx,Ny,h, and the placement of the rectangle in the computational domain. We look for convergence of the numerical solution as h0,Nx,Ny and the rectangle is placed far from the boundaries of the computationally domain.

Discretizing the governing equations, we now write

ψi,j=ψ(xi,yj),ωi,j=ω(xi,yj).

To solve the coupled Poisson equations given by (17.1) and (17.2), we make use of the SOR method, previously described in §7.1. The notation we use here is for the Jacobi method, but faster convergence is likely to be achieved using red-back Gauss-Seidel. The Poisson equation for the stream function, given by (17.1), becomes

ψn+1i,j=(1rψ)ψni,j+rψ4(ψni+1,j+ψni1,j+ψni,j+1+ψni,j1+h2ωni,j).

The Poisson equation for the vorticity, given by (17.2), requires use of the centered finite difference approximation for the derivatives that appear on the right-hand-side. For x=xi,y=yi, these approximations are given by

ψx12h(ψi+1,jψi1,j),ψy12h(ψi,j+1ψi,j1)ωx12h(ωi+1,jωi1,j),ωy12h(ωi,j+1ωi,j1).

We then write for (17.2),

ωn+1i,j=(1rω)ωni,j+rω4(ωni+1,j+ωni1,j+ωni,j+1+ωni,j1+Re4fni,j),

where

fnij=(ψni+1,jψni1,j)(ωni,j+1ωni,j1)(ψni,j+1ψni,j1)(ωni+1,jωni1,j)

Now, the right-hand-side of (17.11) contains a nonlinear term given by (17.12). This nonlinearity can result in the iterations becoming unstable.

The iterations can be stabilized as follows. First, the relaxation parameters, rψ and rω, should be less than or equal to unity, and unstable iterations can often be made stable by decreasing rω. One needs to numerically experiment to obtain the best trade-off between computationally stability and speed. Second, to determine the solution with Reynolds number Re, the iteration should be initialized using the steady solution for a slightly smaller Reynolds number. Initial conditions for the first solution with Re slightly larger than zero should be chosen so that this first iteration is stable.

The path of convergence can be tracked during the iterations. We define

εn+1ψ=maxi,j|ψn+1i,jψni,j|εn+1ω=maxi,j|ωn+1i,jωni,j|.

The iterations are to be stopped when the values of εn+1ψ and εn+1ω are less than some pre-defined error tolerance, say 108.

Boundary conditions

Boundary conditions on ψi,j and ωi,j must be prescribed at i=0 (inflow), i=Nx (outflow), j=0 (midline), and j=Ny (top of computational domain). Also, boundary conditions must be prescribed on the surface of the obstacle; that is, on the front surface: i=m,0jI; the back surface: i=m+I,0jJ; and the top surface: mim+I,j=J. Inside of the obstacle, m<i<m+I,0<j<J, no solution is sought.

For the inflow and top-of-domain boundary conditions, we may assume that the flow field satisfies dimensionless free-stream conditions; that is,

u=1,v=0.

The vorticity may be taken to be zero, and the stream function satisfies

ψy=1,ψx=0

Integrating the first of these equations, we obtain

ψ=y+f(x);

and from the second equation we obtain f(x)=c, where c is a constant. Without loss of generality, we may choose c=0. Therefore, for the inflow and top-of-domain boundary conditions, we have

ψ=y,ω=0

At the top of the domain, notice that y=Nyh is a constant.

For the outflow boundary conditions, we have two possible choices. We could assume freestream conditions if we place the outflow boundary sufficiently far away from the obstacle. However, one would expect that the disturbance to the flow field downstream of the obstacle might be substantially greater than that upstream of the obstacle. Perhaps better outflow boundary conditions may be zero normal derivatives of the flow field; that is

ψx=0,ωx=0

For the midline boundary conditions, we will assume a symmetric flow field so that the flow pattern will look the same when rotated about the x-axis. The symmetry conditions are therefore given by

u(x,y)=u(x,y),v(x,y)=v(x,y).

The vorticity exhibits the symmetry given by

ω(x,y)=v(x,y)xu(x,y)(y)=v(x,y)x+u(x,y)(y)=ω(x,y)

On the midline (y=0), then, ω(x,0)=0. Also, v(x,0)=0. With v=ψ/x, we must have ψ(x,0) independent of x, or ψ(x,0) equal to a constant. Matching the midline boundary condition to our chosen inflow condition determines ψ(x,0)=0.

Our boundary conditions are discretized using (17.4). The outflow condition of zero normal derivative could be approximated either to first- or second-order. Since it is an approximate boundary condition, first-order is probably sufficient and we use ψNx,j=ψNx1,j and ωNx,j= ωNx1,j.

Putting all these results together, the boundary conditions on the borders of the computational domain are given by

ψi,0=0,ωi,0=0, midline; ψ0,j=jh,ω0,j=0, inflow; ψNx,j=ψNx1,j,ωNx,j=ωNx1,j outflow; ψi,Ny=Nyh,ωi,Ny=0, top-of-domain. 

Boundary conditions on the obstacle can be derived from the no-penetration and no-slip conditions. From the no-penetration condition, u=0 on the sides and v=0 on the top. Therefore, on the sides, ψ/y=0, and since the side boundaries are parallel to the y-axis, ψ must be constant. On the top, ψ/x=0, and since the top is parallel to the x-axis, ψ must be constant. Matching the constant to the value of ψ on the midline, we obtain ψ=0 along the boundary of the obstacle.

From the no-slip condition, v=0 on the sides and u=0 on the top. Therefore, ψ/x=0 on the sides and ψ/y=0 on the top. To interpret the no-slip boundary conditions in terms of boundary conditions on the vorticity, we make use of (17.1); that is,

ω=(2ψx2+2ψy2)

First consider the sides of the obstacle. Since ψ is independent of y we have 2ψ/y2=0, and (17.19) becomes

ω=2ψx2

We now Taylor series expand ψ(xmh,yj) and ψ(xm2h,yj) about (xm,yj), corresponding to the front face of the rectangular obstacle. We have to order h3 :

ψm1,j=ψm,jhψx|m,j+12h22ψx2|m,j16h33ψx3|m,j+O(h4),ψm2,j=ψm,j2hψx|m,j+2h22ψx2|m,j43h33ψx3|m,j+O(h4).

The first terms in the two Taylor series expansions are zero because of the no-penetration condition, and the second terms are zero because of the no-slip condition. The third terms acan be rewritten using (17.20), and we obtain

ψm1,j=12h2ωm,j16h33ψx3|m,j+O(h4)ψm2,j=2h2ωm,j43h33ψx3|m,j+O(h4)

We multiply the first equation by 8 and add it to the second equation to eliminate the h3 term. We obtain

8ψm1,j+ψm2,j=2h2ωm,j+O(h4).

Solving for the vorticity, we have a second-order accurate boundary condition given by

ωm,j=ψm2,j8ψm1,j2h2

Similar considerations applied to the back face of the rectangular obstacle yields

ωm+1,j=ψm+I+2,j8ψm+I+1,j2h2

On the top of the obstacle, y=Jh is fixed, and since ψ is independent of x, we have 2ψ/x2= 0 . Therefore,

ω=2ψy2

We now Taylor series expand ψ(xi,yJ+1) and ψ(xi,yJ+2) about (xi,yJ). To order h3,

ψi,J+1=ψi,J+hψy|i,J+12h22ψy2|i,J+16h33ψy3|i,J+O(h4),ψi,J+2=ψi,J+2hψy|i,J+2h22ψy2|i,J+43h33ψy3|i,J+O(h4).

Again, the first and second terms in the Taylor series expansion are zero, and making use of (17.24), we obtain

ψi,J+1=12h2ωi,J+16h33ψy3|i,J+O(h4),ψi,J+2=2h2ωi,J+43h33ψy3|i,J+O(h4).

Again, we multiply the first equation by 8 and add it to the second equation to obtain

8ψi,J+1+ψi,J+2=2h2ωi,J+O(h4)

Solving for the vorticity on the top surface, we have to second-order accuracy

ωi,J=ψi,J+28ψi,J+12h2

We summarize the boundary conditions on the obstacle:

 front face: ψm,j=0,ωm,j=ψm2,j8ψm1,j2h2,0jJ; back face: ψm+I,j=0,ωm+I,j=ψm+I+2,j8ψm+I+1,j2h2,0jJ; top face: ψi,J=0,ωi,J=ψi,J+28ψi,J+12h2,mim+I.

Flow past a circle

We now consider flow past a circular obstacle of radius R, with free-stream velocity u=Uˆx Here, we nondimensionalize the governing equations using U and R. We will define the Reynolds number-the only dimensionless parameter of this problem-by

Re=2URv.

The extra factor of 2 bases the definition of the Reynolds number on the diameter of the circle rather than the radius, which allows a better comparison to computations of flow past a square (a=1), where the Reynolds number was based on the side length

The dimensionless governing equations in vector form, can be written as

2ψ=ω2ω=Re2uω

where the extra factor of one-half arises from nondimensionalizing the equation using the radius of the obstacle R, but defining the Reynolds number in terms of the diameter 2R.

Log-polar coordinates

Although the free-stream velocity is best expressed in Cartesian coordinates, the boundaries of the circular obstacle are more simply expressed in polar coordinates, with origin at the center of the circle. Polar coordinates are defined in the usual way by

x=rcosθ,y=rsinθ,

with the cartesian unit vectors given in terms of the polar unit vectors by

ˆx=cosθˆrsinθˆθ,ˆy=sinθˆr+cosθˆθ

The polar unit vectors are functions of position, and their derivatives are given by

ˆrr=0,ˆrθ=ˆθ,ˆθr=0,ˆθθ=ˆr

The del differential operator in polar coordinates is given by

=ˆrr+ˆθ1rθ

and the two-dimensional Laplacian is given by

2=1r2((rr)(rr)+2θ2)

The velocity field is written in polar coordinates as

u=urˆr+uθˆθ

The free-stream velocity in polar coordinates is found to be

u=Uˆx=U(cosθˆrsinθˆθ),

from which can be read off the components in polar coordinates. The continuity equation u= 0 in polar coordinates is given by

1rr(rur)+1ruθθ=0

so that the stream function can be defined by

rur=ψθ,uθ=ψr.

The vorticity, here in cylindrical coordinates, is given by

ω=×u=ˆz(1rr(ruθ)1rurθ),

so that the z-component of the vorticity for a two-dimensional flow is given by

ω=1rr(ruθ)1rurθ.

Furthermore,

\begin{align} \nonumber \mathbf{u} \cdot \nabla &=\left(u_{r} \hat{\mathbf{r}}+u_{\theta} \hat{\boldsymbol{\theta}}\right) \cdot\left(\hat{\mathbf{r}} \frac{\partial}{\partial r}+\hat{\theta} \frac{1}{r} \frac{\partial}{\partial \theta}\right) \\ \nonumber &=u_{r} \frac{\partial}{\partial r}+\frac{u_{\theta}}{r} \frac{\partial}{\partial \theta} \\ &=\frac{1}{r} \frac{\partial \psi}{\partial \theta} \frac{\partial}{\partial r}-\frac{1}{r} \frac{\partial \psi}{\partial r} \frac{\partial}{\partial \theta} \end{align} \nonumber

The governing equations given by (17.29), then, with the Laplacian given by (17.34), and the convection term given by (17.40), are

\begin{align} \nabla^{2} \psi &=-\omega \\ \nabla^{2} \omega &=\frac{\operatorname{Re}}{2}\left(\frac{1}{r} \frac{\partial \psi}{\partial \theta} \frac{\partial \omega}{\partial r}-\frac{1}{r} \frac{\partial \psi}{\partial r} \frac{\partial \omega}{\partial \theta}\right) \end{align} \nonumber

The recurring factor r \partial / \partial r in the polar coordinate Laplacian, (17.34), is awkward to discretize and we look for a change of variables r=r(\xi), where

r \frac{\partial}{\partial r}=\frac{\partial}{\partial \xi} . \nonumber

Now,

\frac{\partial}{\partial \xi}=\frac{d r}{d \xi} \frac{\partial}{\partial r} \nonumber

so that we require

\frac{d r}{d \xi}=r \text {. } \nonumber

This simple differential equation can be solved if we take as our boundary condition \xi=0 when r=1, corresponding to points lying on the boundary of the circular obstacle. The solution of (17.45) is therefore given by

r=e^{\zeta} \nonumber

The Laplacian in the so-called log polar coordinates then becomes

\begin{aligned} \nabla^{2} &=\frac{1}{r^{2}}\left(\left(r \frac{\partial}{\partial r}\right)\left(r \frac{\partial}{\partial r}\right)+\frac{\partial^{2}}{\partial \theta^{2}}\right) \\ &=e^{-2 \zeta}\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) . \end{aligned} \nonumber

Also, transforming the right-hand-side of (17.42), we have

\begin{aligned} \frac{1}{r} \frac{\partial \psi}{\partial \theta} \frac{\partial \omega}{\partial r}-\frac{1}{r} \frac{\partial \psi}{\partial r} \frac{\partial \omega}{\partial \theta} &=\frac{1}{r^{2}}\left(r \frac{\partial \omega}{\partial r} \frac{\partial \psi}{\partial \theta}-r \frac{\partial \psi}{\partial r} \frac{\partial \omega}{\partial \theta}\right) \\ &=e^{-2 \xi}\left(\frac{\partial \psi}{\partial \theta} \frac{\partial \omega}{\partial \zeta}-\frac{\partial \psi}{\partial \xi} \frac{\partial \omega}{\partial \theta}\right) . \end{aligned} \nonumber

The governing equations for \psi=\psi(\xi, \theta) and \omega=\omega(\xi, \theta) in log-polar coordinates can therefore be written as

\begin{align} -&\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \psi=e^{2 \xi} \omega \\ -&\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \omega=\frac{\operatorname{Re}}{2}\left(\frac{\partial \psi}{\partial \xi} \frac{\partial \omega}{\partial \theta}-\frac{\partial \psi}{\partial \theta} \frac{\partial \omega}{\partial \xi}\right) . \end{align} \nonumber

Finite difference approximation

A finite difference approximation to the governing equations proceeds on a grid in (\xi, \theta) space. The grid is defined for 0 \leq \xi \leq \zeta_{m} and 0 \leq \theta \leq \pi, so that the computational domain forms a rectangle without holes. The sides of the rectangle correspond to the boundary of the circular obstacle (\xi=0), the free stream \left(\xi=\xi_{m}\right), the midline behind the obstacle (\theta=0), and the midline in front of the obstacle (\theta=\pi).

We discretize the equations using square grid cells, and write

\begin{array}{ll} \xi_{i}=i h, & i=0,1, \ldots, n \\ \theta_{j}=j h, & j=0,1, \ldots, m \end{array} \nonumber

where n and m are the number of grid cells spanning the \xi - and \theta-directions, and h is the side length of a grid cell. Because 0 \leq \theta \leq \pi, the grid spacing must satisfy

h=\frac{\pi}{m} \nonumber

and the maximum value of \xi is given by

\xi_{\max }=\frac{n \pi}{m} \nonumber

The radius of the computational domain is therefore given by e^{\xi \max }, which is to be compared to the obstacle radius of unity. The choice n=m would yield e^{\zeta_{\max }} \approx 23, and the choice n=2 m would yield e^{\zeta_{\max }} \approx 535. To perform an accurate computation, it is likely that both the value of m (and n ) and the value of \xi_{\max } will need to increase with Reynolds number.

Again we make use of the SOR method, using the notation for the Jacobi method, although faster convergence is likely to be achieved using red-black Gauss-Seidel. The finite difference approximation to (17.47 and 14.48) thus becomes

\psi_{i, j}^{n+1}=\left(1-r_{\psi}\right) \psi_{i, j}^{n}+\frac{r_{\psi}}{4}\left(\psi_{i+1, j}^{n}+\psi_{i-1, j}^{n}+\psi_{i, j+1}^{n}+\psi_{i, j-1}^{n}+h^{2} e^{2 \xi_{i}} \omega_{i, j}^{n}\right), \nonumber

and

\omega_{i, j}^{n+1}=\left(1-r_{\omega}\right) \omega_{i, j}^{n}+\frac{r_{\omega}}{4}\left(\omega_{i+1, j}^{n}+\omega_{i-1, j}^{n}+\omega_{i, j+1}^{n}+\omega_{i, j-1}^{n}+\frac{\operatorname{Re}}{8} f_{i, j}^{n}\right), \nonumber

Where

f_{i j}^{n}=\left(\psi_{i+1, j}^{n}-\psi_{i-1, j}^{n}\right)\left(\omega_{i, j+1}^{n}-\omega_{i, j-1}^{n}\right)-\left(\psi_{i, j+1}^{n}-\psi_{i, j-1}^{n}\right)\left(\omega_{i+1, j}^{n}-\omega_{i-1, j}^{n}\right) \nonumber

Boundary conditions

Boundary conditions must be prescribed on the sides of the rectangular computational domain The boundary conditions on the two sides corresponding to the midline of the physical domain, \theta=0 and \theta=\pi, satisfy \psi=0 and \omega=0. The boundary condition on the side corresponding to the circular obstacle, \xi=0, is again determined from the no-penentration and no-slip conditions, and are given by \psi=0 and \partial \psi / \partial \xi^{\tau}=0 . And the free-stream boundary condition may be applied at \xi=\xi_{\max }.

We first consider the free-stream boundary condition. The dimensionless free-stream velocity field in polar coordinates can be found from (17.36),

\mathbf{u}=\cos \theta \hat{\mathbf{r}}-\sin \theta \hat{\boldsymbol{\theta}} \nonumber

The stream function, therefore, satisfies the free-stream conditions

\frac{\partial \psi}{\partial \theta}=r \cos \theta, \quad \frac{\partial \psi}{\partial r}=\sin \theta, \nonumber

and by inspection, the solution that also satisfies \psi=0 when \theta=0, \pi is given by

\psi(r, \theta)=r \sin \theta . \nonumber

In log-polar coordinates, we therefore have the free-stream boundary condition

\psi\left(\xi_{\max }, \theta\right)=e^{\xi_{\max }} \sin \theta \nonumber

One has two options for the vorticity in the free stream. One could take the vorticity in the free stream to be zero, so that

\omega\left(\xi_{\max }, \theta\right)=0 \nonumber

A second, more gentle option is to take the derivative of the vorticity to be zero, so that

\frac{\partial \omega}{\partial \xi}\left(\xi_{\max }, \theta\right)=0 \nonumber

This second option seems to have somewhat better stability properties for the flow field far downstream of the obstacle. Ideally, the computed values of interest should be independent of which of these boundary conditions is chosen, and finding flow-field solutions using both of these boundary conditions provides a good measure of accuracy. The remaining missing boundary condition is for the vorticity on the obstacle. Again, we need to convert the two boundary conditions on the stream function, \psi=0 and \partial \psi / \partial \xi=0 to a boundary condition on \psi and \omega. From (17.47 and 17.48), we have

\omega=-e^{-2 \tilde{}}\left(\frac{\partial^{2} \psi}{\partial \tilde{\xi}^{2}}+\frac{\partial^{2} \psi}{\partial \theta^{2}}\right) \nonumber

and since on the circle \psi=0, independent of \theta, and \xi=0, we have

\omega=-\frac{\partial^{2} \psi}{\partial \xi^{2}} \nonumber

A Taylor series expansion one and two grid points away from the circular obstacle yields

\begin{aligned} &\psi_{1, j}=\psi_{0, j}+\left.h \frac{\partial \psi}{\partial \xi}\right|_{(0, j)}+\left.\frac{1}{2} h^{2} \frac{\partial^{2} \psi}{\partial \xi^{2}}\right|_{(0, j)}+\left.\frac{1}{6} h^{3} \frac{\partial^{3} \psi}{\partial \xi^{3}}\right|_{(0, j)}+\mathrm{O}\left(h^{4}\right), \\ &\psi_{2, j}=\psi_{0, j}+\left.2 h \frac{\partial \psi}{\partial \xi}\right|_{(0, j)}+\left.2 h^{2} \frac{\partial^{2} \psi}{\partial \xi^{2}}\right|_{(0, j)}+\left.\frac{4}{3} h^{3} \frac{\partial^{3} \psi}{\partial \xi^{3}}\right|_{(0, j)}+\mathrm{O}\left(h^{4}\right) . \end{aligned} \nonumber

Now, both \psi=0 and \partial \psi / \partial \xi=0 at the grid point (0, j) . Using the equation for the vorticity on the circle, (17.62), results in

\begin{aligned} &\psi_{1, j}=-\frac{1}{2} h^{2} \omega_{0, j}+\left.\frac{1}{6} h^{3} \frac{\partial^{3} \psi}{\partial \zeta^{3}}\right|_{(0, j)}+\mathrm{O}\left(h^{4}\right), \\ &\psi_{2, j}=-2 h^{2} \omega_{0, j}+\left.\frac{4}{3} h^{3} \frac{\partial^{3} \psi}{\partial \xi^{3}}\right|_{(0, j)}+\mathrm{O}\left(h^{4}\right) . \end{aligned} \nonumber

We multiply the first equation by -8 and add it to the second equation to eliminate the h^{3} term. We obtain

-8 \psi_{1, j}+\psi_{2, j}=2 h^{2} \omega_{0, j}+\mathrm{O}\left(h^{4}\right) \nonumber

Solving for the vorticity, we obtain our boundary condition accurate to second order:

\omega_{0, j}=\frac{\psi_{2, j}-8 \psi_{1, j}}{2 h^{2}} \nonumber

The boundary conditions are summarized below:

\begin{align} \nonumber \xi=0,0 \leq \theta \leq \pi: & \psi_{0, j}=0, \quad \omega_{0, j}=\frac{\psi_{2, j}-8 \psi_{1, j}}{2 h^{2}} ; \\ \xi=\xi_{\max }, 0 \leq \theta \leq \pi: & \psi_{n, j}=e^{\xi_{\max }} \sin j h, \quad \omega_{n, j}=0 \text { or } \omega_{n, j}=\omega_{n-1, j} ; \\ \nonumber 0 \leq \xi \leq \xi_{\max }, \theta=0: & \psi_{i, 0}=0, \quad \omega_{i, 0}=0 ; \\ \nonumber 0 \leq \xi \leq \xi_{\max }, \theta=\pi: & \psi_{i, m}=0, \quad \omega_{i, m}=0 . \end{align} \nonumber

Solution using Newton’s method

We consider here a much more efficient method to find the steady fluid flow solution. Unfortunately, this method is also more difficult to program. Recall from \S 7.2 that Newton’s method can be used to solve a system of nonlinear equations. Newton’s method as a root-finding routine has the strong advantage of being very fast when it converges, but the disadvantage of not always converging. Here, the problem of convergence can be overcome by solving for larger Re using as an initial guess the solution for slightly smaller Re, with slightly to be defined by trial and error. Recall that Newton’s method can solve a system of nonlinear equations of the form

F(\psi, \omega)=0, \quad G(\psi, \omega)=0 \nonumber

Newton’s method is implemented by writing

\psi^{(k+1)}=\psi^{(k)}+\Delta \psi, \quad \omega^{(k+1)}=\omega^{(k)}+\Delta \omega, \nonumber

and the iteration scheme is derived by linearizing (17.66) in \Delta \psi and \Delta \omega to obtain

\mathrm{J}\left(\begin{array}{c} \Delta \psi \\ \Delta \omega \end{array}\right)=-\left(\begin{array}{l} F \\ G \end{array}\right) \nonumber

where J is the Jacobian matrix of the functions F and G. All functions are evaluated at \psi^{(k)} and \omega^{(k)}.

Here, we should view \psi and \omega as a large number of unknowns and F and G a correspondingly large number of equations, where the total number of equations must necessarily equal the total number of unknowns.

If we rewrite our governing equations into the form given by (17.66), we have

\begin{align} \nonumber &-\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \psi-e^{2 \xi} \omega=0 \\ &-\left(\frac{\partial^{2}}{\partial \tilde{\xi}^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \omega-\frac{\operatorname{Re}}{2}\left(\frac{\partial \psi}{\partial \xi} \frac{\partial \omega}{\partial \theta}-\frac{\partial \psi}{\partial \theta} \frac{\partial \omega}{\partial \xi}\right)=0 \end{align} \nonumber

With n and m grid cells in the \xi - and \theta-directions, the partial differential equations of (17.69) represent 2(n-1)(m-1) coupled nonlinear equations for \psi_{i, j} and \omega_{i, j} on the internal grid points. We will also include the boundary values in the solution vector that will add an additional two unknowns and two equations for each boundary point, bringing the total number of equations (and unknowns) to 2(n+1)(m+1).

The form of the Jacobian matrix may be determined by linearizing (17.69) in \Delta \psi and \Delta \omega. Using (17.67), we have

-\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right)\left(\psi^{(k)}+\Delta \psi\right)-e^{2 \xi}\left(\omega^{(k)}+\Delta \omega\right)=0 \nonumber

and

\begin{aligned} -\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right)\left(\omega^{(k)}+\Delta \omega\right) & \\ &-\frac{\operatorname{Re}}{2}\left(\frac{\partial\left(\psi^{(k)}+\Delta \psi\right)}{\partial \xi} \frac{\partial\left(\omega^{(k)}+\Delta \omega\right)}{\partial \theta}-\frac{\partial\left(\psi^{(k)}+\Delta \psi\right)}{\partial \theta} \frac{\partial\left(\omega^{(k)}+\Delta \omega\right)}{\partial \xi}\right)=0 . \end{aligned} \nonumber

Liinearization in \Delta \psi and \Delta \omega then results in

-\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \Delta \psi-e^{2 \xi} \Delta \omega=-\left[-\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \psi^{(k)}-e^{2 \xi} \omega^{(k)}\right] \nonumber

and

\begin{align} -\left(\frac{\partial^{2}}{\partial \xi^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \Delta \omega &-\frac{\operatorname{Re}}{2}\left(\frac{\partial \omega^{(k)}}{\partial \theta} \frac{\partial \Delta \psi}{\partial \zeta}-\frac{\partial \omega^{(k)}}{\partial \xi} \frac{\partial \Delta \psi}{\partial \theta}+\frac{\partial \psi^{(k)}}{\partial \xi} \frac{\partial \Delta \omega}{\partial \theta}-\frac{\partial \psi^{(k)}}{\partial \theta} \frac{\partial \Delta \omega}{\partial \xi}\right) \nonumber \\ &=-\left[-\left(\frac{\partial^{2}}{\partial \xi ^{2}}+\frac{\partial^{2}}{\partial \theta^{2}}\right) \omega^{(k)}-\frac{\operatorname{Re}}{2}\left(\frac{\partial \psi^{(k)}}{\partial \xi} \frac{\partial \omega^{(k)}}{\partial \theta}-\frac{\partial \psi^{(k)}}{\partial \theta} \frac{\partial \omega^{(k)}}{\partial \xi}\right)\right] \end{align} \nonumber

where the first equation was already linear in the \Delta variables, but the second equation was originally quadratic, and the quadratic terms have now been dropped. The equations given by (17.71) and (17.72) can be observed to be in the form of the Newton’s iteration equations given by (17.68).

Numerically, both \Delta \psi and \Delta \omega will be vectors formed by a natural ordering of the grid points, as detailed in \$ 6.2. These two vectors will then be stacked into a single vector as shown in (17.68). To write the Jacobian matrix, we employ the shorthand notation \partial_{\tau}^{2}=\partial^{2} / \partial \xi^{2}, \psi_{\xi}=\partial \psi / \partial \xi, and so on. The Jacobian matrix can then be written symbolically as

\mathrm{J}=\left(\begin{array}{cc} -\left(\partial_{\xi}^{2}+\partial_{\theta}^{2}\right) & -e^{2 \xi} \mathrm{I} \\ 0 & -\left(\partial_{\xi}^{2}+\partial_{\theta}^{2}\right) \end{array}\right) \quad-\frac{\operatorname{Re}}{2}\left(\begin{array}{cc} 0 & 0 \\ \omega_{\theta} \partial_{\xi}-\omega_{\xi} \partial_{\theta} & \psi_{\xi} \partial_{\theta}-\psi_{\theta} \partial_{\xi} \end{array}\right) \nonumber

where I is the identity matrix and the derivatives of \psi and \omega in the second matrix are all evaluated at the k th iteration.

The Jacobian matrix as written is valid for the grid points interior to the boundary, where each row of J corresponds to an equation for either \psi or \omega at a specific interior grid point. The Laplacian-like operator is represented by a Laplacian matrix, and the derivative operators are represented by derivative matrices. The terms e^{2 \xi}, \partial \omega / \partial \theta, and the other derivative terms are to be evaluated at the grid point corresponding to the row in which they are found.

To incorporate boundary conditions, we extend the vectors \Delta \psi and \Delta \omega to also include the points on the boundary as they occur in the natural ordering of the grid points. To the Jacobian matrix and the right-hand-side of (17.68) are then added the appropriate equations for the boundary conditions in the rows corresponding to the boundary points. By explicitly including the boundary points in the solution vector, the second-order accurate Laplacian matrix and derivative matrices present in J can handle the grid points lying directly next to the boundaries without special treatment.

The relevant boundary conditions to be implemented are the boundary conditions on \Delta \psi and \Delta \omega. The boundary conditions on the fields \psi and \omega themselves have already been given by (17.65). The grid points with fixed boundary conditions on \psi and \omega that do not change with iterations will have a one on the diagonal in the Jacobian matrix corresponding to that grid point, and a zero on the right-hand-side. In other words, \psi and \omega will not change on iteration of Newton’s method, and their initial values need to be chosen to satisfy the appropriate boundary conditions.

The two boundary conditions which change on iteration, namely

\omega_{0, j}=\frac{\psi_{2, j}-8 \psi_{1, j}}{2 h^{2}}, \quad \omega_{n, j}=\omega_{n-1, j} \nonumber

must be implemented in the Newton’s method iteration as

\Delta \omega_{0, j}=\frac{\Delta \psi_{2, j}-8 \Delta \psi_{1, j}}{2 h^{2}}, \quad \Delta \omega_{n, j}=\Delta \omega_{n-1, j} \nonumber

and these equations occur in the rows corresponding to the grid points (0, j) and (n, j), with j=0 to m. Again, the initial conditions for the iteration must satisfy the correct boundary conditions.

The MATLAB implementation of (17.68) using (17.73), requires both the construction of the (n+1)(m+1) \times(n+1)(m+1) matrix that includes both the Jacobian matrix and the boundary conditions, and the construction of the corresponding right-hand-side of the equation. For the Laplacian matrix, one can make use of the function sp_laplace_new.m; and one also needs to construct the derivative matrices \partial_{\xi} and \partial_{\theta}. Both of these matrices are banded, with a band of positive ones above the main diagonal and a band of negative ones below the main diagonal. For \partial_{\xi}, the bands are directly above and below the diagonal. For \partial_{\theta}, the bands are a distance n+1 away from the diagonal, corresponding to n+1 grid points in each row. Both the Laplacian and derivative matrices are to be constructed for (n+1) \times(m+1) grid points and placed into a 2 \times 2 matrix using the MATLAB function kron.m, which generates a block matrix by implementing the so-called Kronecker product. Rows corresponding to the boundary points are then to be replaced by the equations for the boundary conditions.

The MATLAB code needs to be written efficiently, using sparse matrices. A profiling of this code should show that most of the computational time is spent solving (17.68) (with boundary conditions added) for \Delta \psi and \Delta \omega using the MATLAB backslash operator. With 4 \mathrm{~GB} RAM and a notebook computer bought circa 2013 , and with the resolution 512 \times 256 and using the R e=150 result as the initial field, I can solve for R e=200 in seven iterations to an accuracy of 10^{-12}. The total run time was about 48 \mathrm{sec} with about 42 \mathrm{sec} spent on the single line containing J \backslash \mathrm{b}.

Visualization of the flow fields

Obtaining correct contour plots of the stream function and vorticity can be a challenge and in this section I will provide some guidance. The basic MATLAB functions required are meshgrid.m, pol2cart.m, contour.m, and clabel.m. More fancy functions such as contourf.m and imagesc may also be used, though I will not discuss these here.

Suppose the values of the stream function are known on a grid in two dimensional Cartesian coordinates. A contour plot draws curves following specified (or default) constant values of the stream function in the x-y plane. Viewing the curves on which the stream function is constant gives a clear visualization of the fluid flow.

To make the best use of the function contour.m, one specifies the x-y grid on which the values of the stream function are known. The stream function variable psi, say, is given as an n-by- m matrix. We will examine a simple example to understand how to organize the data.

Let us assume that the stream function is known at all the values of x and y on the twodimensional grid specified by x=[0,1,2] and y=[0,1]. To properly label the axis of the contour plot, we use the function meshgrid, and write [X, Y]=\operatorname{meshgrid}(X, Y). The values assigned to X and Y are the following 2 -by-3 matrices:

X=\left[\begin{array}{lll} 0 & 1 & 2 \\ 0 & 1 & 2 \end{array}\right], \quad Y=\left[\begin{array}{lll} 0 & 0 & 0 \\ 1 & 1 & 1 \end{array}\right] \nonumber

The variable psi must have the same dimensions as the variables X and Y. Suppose psi is given by

\text { psi }=\left[\begin{array}{lll} a & b & c \\ d & e & f \end{array}\right] \nonumber

Then the data must be organized so that psi =a at (x, y)=(0,0), psi =b at (x, y)=(1,0), psi =d at (x, y)=(0,1), etc. Notice that the values of psi across a row (\mathrm{psi}(i, j), j=1: 3) correspond to different x locations, and the values of psi down a column ((p s i(i, j), i=1: 2)) correspond to different y locations. Although this is visually intuitive since x corresponds to horizontal variation and y to vertical variation, it is algebraically counterintuitive: the first index of psi corresponds to the y variation and the second index corresponds to the x variation. If one uses the notation psi (x, y) during computation, then to plot one needs to take the transpose of the matrix psi.

Now the computation of the flow field around a circle is done using log-polar coordinates (\xi, \theta). To construct a contour plot, the solution fields need to be transformed to cartesian coordinates. The MATLAB function pol2cart.m provides a simple solution. One defines the variables theta and xi that defines the mesh in log-polar coordinates, and then first transforms to standard polar coordinates with r=\exp (x i). The polar coordinate grid is then constructed from [THETA, R] =meshgrid (theta, r ), and the cartesian grid is constructed from

clipboard_e3bf0f34a5e3fcc2407933a583322e8a4.png
Figure 17.1: Contour plots of the stream function (y>0) and vorticity (y<0) for \operatorname{Re}=50. Negative contours are in red, the zero contour in black, and positive contours in blue. The contour levels for the stream function are -0.05,-0.04,-0.02,0,0.05,0.2,0.4,0.6,0.8,1.1 and those for the vorticity are -0.2,-0.05,0,0.25,0.5,0.75,1,1.5,2

\left[\begin{array}{ll}X, & Y\end{array}\right]= pol 2 cart ( THETA,R). The fields can then be plotted directly using the cartesian grid, even though this grid is not uniform. That is, a simple contour plot can be made with the command contour (X, Y, p s i). More sophisticated calls to contour.m specify the precise contour lines to be plotted, and their labelling using clabel.m.

A nice way to plot both the stream function and the vorticity fields on a single graph is to plot the stream function contours for y>0 and the vorticity contours for y<0, making use of the symmetry of the fields around the x-axis. In way of illustration, a plot of the stream function and vorticity contours for \operatorname{Re}=50 is shown in Fig. 17.1.


17: Flow Past an Obstacle is shared under a CC BY 3.0 license and was authored, remixed, and/or curated by LibreTexts.

Support Center

How can we help?