2010 jncasr juniper flow instability matlab handout

9
 Flow Instability Matlab Tutorial Bangalore, January 2010 Matthew Juniper, Dan Henningson, Peter Schmid  1 1 Si mple di erenti at ion mat ri ces Imagine a vector that represents the values of a function  y  at  N  equispaced points between 1  < x <  1. We can create a simple matrix that , at each poin t, approxima tes d/dx  of this vector: 1.1 prog 1.m function [D1 ] = pro g 1(N) % Create a 2nd order central differen ce matrix, D1, that differentiates the % vector on which it operates. The vector represents the values of y at N % equispaced points between -1 < x < 1. % % Operate this matrix on a sin wave and compare the result with the % analytical solu tion. 1 0.5 0 0.5 1 4 3 2 1 0 1 2 3 4 N = 17  y(x) y’(x) D y(x) To do  F or small  N, e.g.  N = 7, run with the command line  D1 = prog 1(N) . Examine matrix  D1 to under stand why it dier enti ates the vector on whic h it acts. Vary  N and run with the command line  D1 = prog 1(N); to examine its behaviour. 1.2 prog 2.m Repeat this for a 4th order central dierence matrix,  D1. 1 This tutorial is based on one given at JNCASR by Peter Schmid in January 2009 1

Upload: khor-shu-heng

Post on 16-Jul-2015

104 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 1/9

 

Flow Instability Matlab Tutorial

Bangalore, January 2010Matthew Juniper, Dan Henningson, Peter Schmid 1

1 Simple differentiation matrices

Imagine a vector that represents the values of a function y at N  equispaced points between−1 < x < 1. We can create a simple matrix that, at each point, approximates d/dx of this vector:

1.1 prog 1.m

function [D1] = prog 1(N)

% Create a 2nd order central difference matrix, D1, that differentiates the

% vector on which it operates. The vector represents the values of y at N

% equispaced points between -1 < x < 1.

%

% Operate this matrix on a sin wave and compare the result with the

% analytical solution.

−1 −0.5 0 0.5 1−4

−3

−2

−1

0

1

2

3

4N = 17

 

y(x)

y’(x)

D y(x)

To do For small N, e.g. N = 7, run with the command line D1 = prog 1(N). Examine

matrix D1 to understand why it differentiates the vector on which it acts. Vary N and runwith the command line D1 = prog 1(N); to examine its behaviour.

1.2 prog 2.m

Repeat this for a 4th order central difference matrix, D1.

1This tutorial is based on one given at JNCASR by Peter Schmid in January 2009

1

Page 2: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 2/9

 

−1 −0.5 0 0.5 1−4

−3

−2

−1

0

1

2

3

4N = 17

 

y(x)

y’(x)

D y(x)

To do Same as for D1 = prog 1(N). Examine matrix D1 to understand why it is more

accurate than that inprog 1

. VaryN

and compare with the results of prog 1

.

1.3 prog 5.m

Repeat this for a Chebyshev differentiation matrix

−1 −0.5 0 0.5 1−4

−3

−2

−1

0

1

2

3N = 7

 

y(x)

y’(x)

D y(x)

To do For small N, e.g. N = 7, run with the command line D1 = prog 5(N). Examinematrix D1 and note the differences with those from prog 1 and prog 2. Vary N andcompare with the previous results.

2 Eigenvalue problems

2.1 prog 6.m

We will now solve a simple eigenvalue problem:

d2u

dx2+ λu = 0

with homogenous boundary conditions (u = 0 at x = ±1). This is the solution for a wave

on a string that is held at both ends. The first eigenvalue corresponds to the fundamental

2

Page 3: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 3/9

 

mode. Higher eigenvalues correspond to higher harmonics.% Calculate the Chebyshev matrix and the 2nd order differential operator matrix.

[D,x] = cheb(N); D2 = D^2;

% Apply the homogenous boundary conditions

D2 = D2(2:N,2:N);% Find the eigenvalues and corresponding eigenvectors

[V,Lam] = eig(-D2);

eig 1 = 1.0000000000000*4/pi2

eig 2 = 4.0000000000000*4/pi2

eig 3 = 9.0000000000001*4/pi2

eig 4 = 16.0000000000151*4/pi2

eig 5 = 24.9999999939847*4/pi2

eig 6 = 35.9999998570717*4/pi2

eig 7 = 49.0000063662937*4/pi2

eig 8 = 64.0000448323456*4/pi2

eig 9 = 81.0001741406969*4/pi2

To do Look at how the second order difference matrix is created. Look at how thehomogenous boundary conditions are applied. How many eigenvalues are there? Whathappens as you reduce N? Why? How would you change the boundary conditions to enforce

a zero gradient at x = ±1 (harder)?

2.2 prog 7.m

We will now solve another eigenvalue problem of the Sturm-Liouville type:

d

dx

x2

dy

dx

+ x

dy

dx= λy

with boundary conditions y = 0 at x = 2 and x = 4.

3

Page 4: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 4/9

 

2 3 40

0.05

0.1

0.15

0.2

−21.54228846

2 3 4−0.2

−0.1

0

0.1

0.2

−83.16915382

2 3 4−0.2

0

0.2

0.4

0.6

−185.8805961

2 3 4−0.2

0

0.2

0.4

0.6

−329.6766153

2 3 4−0.2

0

0.2

0.4

0.6

−514.5572114

2 3 4−0.4

−0.2

0

0.2

0.4

−740.5223844

2 3 4−0.4

−0.2

0

0.2

0.4

−1007.572134

2 3 4−0.2

0

0.2

0.4

0.6

−1315.706461

2 3 4−0.2

0

0.2

0.4

0.6

−1664.925365

To do Watch the eigenvalues and eigenfunctions change as you increase N.

2.3 prog 9.m

We will now solve the Orr-Sommerfeld eigenvalue problem for planar Poiseuille flow, as-suming that the perturbations are two-dimensional. (Later on we will allow for pertur-bations to vary in the direction into the page, which introduces the Squire modes.) Thisproblem is adapted from p40.m in Spectral Methods in Matlab by Lloyd N. Trefethen(SIAM 2000). The Orr-Sommerfeld equation is:

R−1

d4u

dx4− 2

d2u

dx2+ u

− 2iu− i(1− x2)

d2u

dx2− u

= λ

d2u

dx2− u

with boundary conditions:du

dx= u = 0 at x = ±1

We express this as a generalized eigenvalue problem:

Au = λBu

We plot the eigenvalues in the complex plane. In this formulation, the eigenvalue withthe highest real part is the most unstable / least stable. In this formulation, the axialwavenumber has been taken to be 1. The figures below are for 60 Chebyshev points andare created by typing prog 9(60).

4

Page 5: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 5/9

 

−0.8 −0.6 −0.4 −0.2 0 0.2−1

−0.8

−0.6

−0.4

−0.2

0

real(λ)

     i    m    a    g     (        λ     )

eigenvalues for N = 60

−1 −0.5 0 0.5 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

x

    a    m    p     l     i     t    u     d    e

Highlighted eigenvector

To do Click on eigenvalues to plot the corresponding eigenvector. Investigate the dif-ferent branches of the eigenvalue plot. What happens as you increase N? Change theReynolds number, R, by editing the program.

3 The Orr-Sommerfeld-Squire system

This section is a practical demonstration of parts of  §2.1 of Peter Schmid’s 2007 AnnualReview paper, Schmid (2007). We will start by considering planar Poiseuille flow atReynolds number R. Unlike in the previous section, we will allow the perturbation to

vary in the direction into the page (spanwise). We consider waves in the streamwisedirection with wavenumber α and waves in the spanwise direction with wavenumber β .

3.1 prog 10.m

We will look at planar Poiseuille flow first because it can be compared with the previoussection. prog 10.m calculates the Orr-Sommerfeld-Squire matrix, which is matrix A inequation (2.1a) of Schmid (2007). It plots out the eigenvalues of this matrix and theOrr-Sommerfeld eigenvector and Squire eigenvector of the eigenvalue that is clicked on bythe user. e.g. type [OSSQ] = prog 10(60,1.0,0.0,5772);.

function [OSSQ] = prog 10(N,alp,beta,Re)% Calculate the Orr-Sommerfeld-Squire matrix for planar Poiseuille flow.

%

% N : Number of Chebyshev points

% alp : streamwise wavenumber

% beta : spanwise wavenumber

% Re : Reynolds number

5

Page 6: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 6/9

 

−0.8 −0.7 −0.6 −0.5 −0.4 −0.3 −0.2 −0.1 0 0.1 0.2−1

−0.9

−0.8

−0.7

−0.6

−0.5

−0.4

−0.3

−0.2

−0.1

0eigenvalue number = 1

−1 −0.5 0 0.5 1−2

−1

0

1

x

    a    m    p     l     i     t    u     d    e

Orr−Sommerfeld eigenfunction

−1 −0.5 0 0.5 1−1

0

1

x

    a    m    p     l     i     t    u     d    e

Squire eigenfunction

To do Compare the eigenvalue plot with that from prog 9.m at the same value of  N.Click on eigenvalues to plot the corresponding eigenvectors. Identify the Orr-Sommerfeldeigenvalues and the Squire eigenvalues. Change the Reynolds number and N. prog 10.m

returns the matrix OSSQ. Create your own routine to plot the eigenvalues of  OSSQ. Watchout for the scale on your graph.

3.2 PoiMatrix.m

Some of the Orr-Sommerfeld-Squire eigenvalues have little influence on the behaviour of the system and can safely be discarded. The function PoiMatrix.m cuts out the modes

outside a defined window. It then calls function OSSQMatrix, which computes the matrix,Q. This matrix has the same eigenvalues as the reduced OSSQ matrix and is used to calculatetransient growth. This is on the ’Maximum Amplification’ slide of Dan Henningson’s notes.This can be run with the command line [Q,invF] = PoiMatrix(60,1.0,0.0,5772);, forinstance. In the rest of this tutorial, we will used this reduced matrix, Q.

To do Plot the eigenvalues of  Q with your own routine. Compare the eigenvalue plotwith that of  prog 9.m at the same value of  N. (Optional: plot out some of the correspondingeigenfunctions).

4 Normal and non-normal matrices

This section looks at two simple matrices, one of which is normal (i.e. has orthogonaleigenvectors) and the other of which is non-normal:

An =

−5 0 0

0 −2− 2i 00 0 0.3 + i

Ann =

−5 4 4

0 −2− 2i 40 0 0.3 + i

6

Page 7: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 7/9

 

4.1 The numerical range

The numerical range is defined on page 136 of Schmid (2007). The maximum protrusion of the numerical range into the unstable half-plane determines the maximum energy growth

at t = 0+ – i.e. it is a measure of the growth rate at very small times. Eigenvalues, onthe other hand, give a measure of the growth or decay at large times.

The program AnPlot.m (A normal plot) plots the eigenvalues and numerical rangeof matrix An. The numerical range is a set of straight lines joining the eigenvalues. Ittherefore does not extend further into the right half plane than the right-most eigenvalue.This means that the growth rate at small times is the same as that at large times.

The program AnnPlot.m (A non-normal plot) plots the eigenvalues and numericalrange of matrix Ann

. The numerical range is loop around the eigenvalues and extendssignificantly into the right half plane. This means that the growth rate at small times will

be higher than that given by the right-most eigenvalue alone.

−8 −6 −4 −2 0 2 4−6

−4

−2

0

2

4

6

λr

        λ    i

a normal matrix

 

unstable regioneigenvaluesnumerical range

−8 −6 −4 −2 0 2 4−6

−4

−2

0

2

4

6

λr

        λ    i

a non−normal matrix

 

unstable regioneigenvaluesnumerical range

To do Make up your own non-normal matrices and plot their eigenvalues and numericalrange.

4.2 Pseudospectra, a.k.a. the resolvent normPseudospectra and the resolvent norm are defined four different but equivalent ways inTrefethen and Embree (2002) and on slide ‘Pseudospectra, resolvents and sensitivity’ of Dan Henningson’s notes. When a random matrix E with norm is added to a matrix L,the eigenvalues of  L move slightly. The maximum amount that they will move is givenby the pseudospectra of L. They will not move outside the pseudospectra contour levelat height . The amount that the pseudospectra extend into the right half plane gives anindication of the maximum transient growth possible with matrix L. (For a clearer defini-tion, see the first three chapters of Trefethen and Embree or the video of Nick Trefethen’stalk at the first AIM Meeting, available on the AIM website.)

7

Page 8: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 8/9

 

The program RAnPlot.m plots the pseudospectra of  An and RAnnPlot.m plots thepseudospectra of Ann. The contours show log10 of the resolvent norm at that value of  σ.

−8 −6 −4 −2 0 2 4−6

−4

−2

0

2

4

6

σr

     σ    i

pseudospectra of a normal matrix

−8 −6 −4 −2 0 2 4−6

−4

−2

0

2

4

6

σr

     σ    i

pseudospectra of a non−normal matrix

The programs RAnPlot shotgun.m and RAnnPlot shotgun.m plot the pseudospectra of An and Ann followed by the eigenvalues of 100 matrices that have been perturbed by anamount . In the figures below, = log10(−0.2).

−8 −6 −4 −2 0 2 4−6

−4

−2

0

2

4

6

 −  0.  6

− 0 .6  

−0.6

−  0    

. 6    

− 0  .6  

− 0  .6  

 − 0. 6

 − 0. 6

  −   0

 .   2

   −      0 

 .      2−  0     . 2     

   −      0 

 .      2−  0     . 2     

− 0  .2   

 −   0 .   2

  −     0

 .     2

−   0      . 2      

      0  .      2

0  .2   

0       . 2       

       0  .       6

0  .6  

     0 .     6

                1

   1

σr

     σ    i

pseudospectra of a normal matrix

 

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

1.2

1.4

 

−8 −6 −4 −2 0 2 4−6

−4

−2

0

2

4

6

− 0  .6   

 − 0. 6

 −  0.  6

− 0  .6  

 −  0.  6

  −   0

 .   2

 − 0. 2

− 0 .2 

  −     0 

 .     2

 −  0.  2

− 0  .2  

−  0    . 2    

0 .2  0 .   2

    0 .    2

 0. 2

0.2

0  .6   

0.6

0       . 6       

  1

1           

1       

σr

     σ    i

pseudospectra of a non−normal matrix

 

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

1.2

1.4

To do Vary and re-run RAnPlot shotgun.m and RAnnPlot shotgun.m. Repeat foryour own non-normal matrices.

4.3 Transient growth

If a matrix, A, is non-normal, it can exhibit transient growth. The maximum possibletransient growth at time T  is called G(T ) and is the maximum singular value of the ma-trix exponential of A × T . Transient growth can occur whether or not the matrix hasunstable eigenvalues. The function TransientGrowth simple.m calculates G(T ) for therange specified by the user. Try TransientGrowth simple(A,[0 5],100).

8

Page 9: 2010 JNCASR Juniper Flow Instability Matlab Handout

5/14/2018 2010 JNCASR Juniper Flow Instability Matlab Handout - slidepdf.com

http://slidepdf.com/reader/full/2010-jncasr-juniper-flow-instability-matlab-handout 9/9

 

To do Calculate the transient growth for a non-normal matrix with stable eigenvalues.Change the non-normality of the matrix. See what happens to the transient growth.

5 Analysis of the Orr-Sommerfeld-Squire matrixYou now have all the tools you need to investigate the Orr-Sommerfeld-Squire matrixwith Poiseuille flow as the base flow. Try combining section 4 with section 3. To get youstarted, the program start.m creates this figure:

−1.5 −1 −0.5 0

−1

−0.8

−0.6

−0.4

−0.2

0

σ

r

     σ    i

Eigenvalues, pseudospectra and numerical range for Poiseuille flow

The Couette directory contains functions that generate the Orr-Sommerfeld-Squirematrix for Couette flow. To generate the matrix, use the command[Q,invF] = CouMatrix(N,alp,beta,Re). The Pipe directory contains functions thatgenerate the axisymmetric Orr-Sommerfeld-Squire matrix for round pipe flow. If youhave time, try creating the Orr-Sommerfeld-Squire matrix for your own base flows.

9