+ All Categories
Home > Documents > Linear Advection Lab - Mishaal...

Linear Advection Lab - Mishaal...

Date post: 12-Jun-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
24
Linear Advection Lab AA 543 - Computer Project 1 Mishaal Aleem February 4, 2015 Contents Introduction ............................................... 1 Background ................................................ 1 1 Forward-Time Backward Space (FTBS), Forward Euler ...................... 2 2 Forward Time Forward Space (FTFS) ................................ 3 3 Forward Time Center Space (FTCS) ................................. 3 4 Lax ................................................... 4 5 Lax-Wendroff .............................................. 5 6 Leap-Frog ................................................ 6 7 Θ-Method ............................................... 7 8 High-Order 4-2 (fourth-order space, second-order time) ...................... 7 Discussion ................................................. 8 Conclusion ................................................ 9 References ................................................. 9 Appendix ................................................. A-1 Introduction The Linear Advection Lab is a MATLAB computer program, including a graphical user interface, that studies the behavior of 8 different linear advection algorithms. The program allows selection of various parameters to help the user study the many algorithms. This report summarizes research into the Linear Advection Lab and compares theoretical and numerical behavior of the presented algorithms. Background The Linear Advection Lab shows the propagation of either a square or Guass wave with periodic boundary conditions and starting amplitude of 1 unit for square wave, 2 units for Guass wave using various algorithms that attempt to represent the linear advection equation (Eq. 1). The derivations for order of accuracy and stability criteria for each algorithm is presented in the Appendix. ∂u ∂t + a ∂u ∂x =0 (1) To study the behavior of the various linear advection algorithms, it is vital to understand certain computation phenomena. The first of these is diffusion. Numerical diffusion (also known as numerical dissipation) is the tendency of a space discretization operator to smooth out sharp corners, gradients, or discontinuities. For example, instead of having a sharp interface, such as a square wave, over 1 cell, it will spread over a few cells. 1
Transcript
Page 1: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Linear Advection LabAA 543 - Computer Project 1

Mishaal AleemFebruary 4, 2015

Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Forward-Time Backward Space (FTBS), Forward Euler . . . . . . . . . . . . . . . . . . . . . . 22 Forward Time Forward Space (FTFS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Forward Time Center Space (FTCS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Lax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Lax-Wendroff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Leap-Frog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Θ-Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 High-Order 4-2 (fourth-order space, second-order time) . . . . . . . . . . . . . . . . . . . . . . 7Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1

Introduction

The Linear Advection Lab is a MATLAB computer program, including a graphical user interface, thatstudies the behavior of 8 different linear advection algorithms. The program allows selection of variousparameters to help the user study the many algorithms. This report summarizes research into theLinear Advection Lab and compares theoretical and numerical behavior of the presented algorithms.

Background

The Linear Advection Lab shows the propagation of either a square or Guass wave with periodicboundary conditions and starting amplitude of 1 unit for square wave, 2 units for Guass wave usingvarious algorithms that attempt to represent the linear advection equation (Eq. 1). The derivations fororder of accuracy and stability criteria for each algorithm is presented in the Appendix.

∂u

∂t+ a

∂u

∂x= 0 (1)

To study the behavior of the various linear advection algorithms, it is vital to understand certaincomputation phenomena.

The first of these is diffusion. Numerical diffusion (also known as numerical dissipation) is the tendencyof a space discretization operator to smooth out sharp corners, gradients, or discontinuities. For example,instead of having a sharp interface, such as a square wave, over 1 cell, it will spread over a few cells.

1

Page 2: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

The next phenomena to understand is dispersion. Numerical dispersion results from the dependence ofwave speed on wavelength. For example, for any wavelength, the exact solution can be represented byan approximate Fourier superposition with harmonics of many different wavelengths. Dispersion makesthe components travel at different speeds, because of the varying wavelengths, so that over time theharmonics separate from the true solution.

Both numerical diffusion and dispersion are represented in Fig. 1.

Figure 1: Numerical Diffusion and Dispersion [1]

1 Forward-Time Backward Space (FTBS), Forward Euler

The theoretical accuracy and stability criteria for the FTBS algorithm are:

O(∆t,∆x) 0 ≤ c∆t

∆x≤ 1

Concurring theory, the Linear Advection Lab showed the FTBS algorithm to be unstable for all negativeCourant numbers as well as values of Courant number over 1.

There was a significant amount of diffusion with this algorithm. In the program, the greatest diffusionwas for a Courant number of .5 whereas the a Courant number of 1 showed no diffusion. This reiteratesFig. 2, where the gain is shown to be lowest at Courant number of 0.5 and the gain is 1 at a Courantnumber of 1.

Figure 2: Gain vs. Courant number for FTBS algorithm

2

Page 3: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

The diffusion continued with time, so if a wave was propagated for 10 periods, it diffused much morethan when it was propagated for a single period. Additionally, the diffusion was clearly visible for a widerange of grid point values. For example, even with as high as 500 grid points, the square wave diffusedto max amplitude ∼0.98 within a single period at a Courant number of 0.9. However, the diffusion wasmore significant pronounced as the number of grid points were decreased.

Interestingly, while this algorithm does have dispersive terms in the PDE approximation, i.e. odd spatial

derivative (∂3u

∂x3,∂5u

∂x5,...), there was no visible dispersion in the Linear Advection Lab. This points to

the dominance of the dissipative terms, i.e. even spatial derivatives, in the algorithm.

2 Forward Time Forward Space (FTFS)

The theoretical accuracy and stability criteria for the FTFS algorithm are:

O(∆t,∆x) −1 ≤ c∆t

∆x≤ 0

Expectedly, in the Linear Advection Lab this algorithm was unstable for any positive Courant numbers,as well as for any Courant numbers less than -1.

Because of the theoretical similarity of the FTFS and FTBS algorithms, there was a great deal ofsimilarity of their behaviors in the program. Like FTBS, this algorithm had very visible diffusion, whichwas most significant at moderate Courant numbers relative to its stability range (and no diffusion for aCourant number of -1). Also similar to the FTBS algorithm was the lack of visible dissipation in theFTFS algorithm.

The behavior of this algorithm effectively mirrored that of the FTBS algorithm. For the same absolutevalue of Courant number, and all other parameters the same, the two algorithms behaved the sameexcept for the direction of wave propagation (FTBS moved in the positive x-direction, whereas theFTFS moved in the negative x-direction).

3 Forward Time Center Space (FTCS)

The theoretical order and stability criteria for the FTCS algorithm are:

O(∆t,∆x2) Unconditionally Unstable

As predicted by theory, the program showed this algorithm to be unstable for any Courant number. Asthe wave propagated, the magnitude grew unchecked. However, the speed with which the magnitudegrew was dependent on the magnitude of the Courant number; lower Courant numbers seemed stablefor longer than larger magnitudes. For example, at a Courant number of 0.1, the Guass wave did notseem unstable at all over 1 period. However, when increased to 10 periods, the same wave was unstable.

When the Courant number was lowered to 0.1, studying the square wave gave insight into the algorithmsaccuracy. Figure 3 shows a plot of a square wave, with 400 grid points, after about 60 iterations. Thereare clearly dispersive terms in the algorithm. In fact, as shown in detail in the Appendix, the FTCSalgorithm has only odd spatial derivatives, which is why there was visible dispersion and no dissipation.

3

Page 4: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Figure 3: Dispersion in FTCS algorithm with Courant number = .1

4 Lax

The theoretical accuracy and stability criteria for the Lax algorithm are:

O(∆t,∆x2

∆t) −1 ≤ a∆t

∆x≤ 1

Use of the Linear Advection Lab confirmed that this algorithm was unstable for Courant numbers lessthan -1 and greater than 1.

This algorithm has a rather unique order of accuracy, ∆x2

∆t . This unique order of accuracy means thatthe algorithm may not be consistent if ∆t→ 0 faster than ∆x2 → 0.

Use of Linear Advection Lab confirmed the theoretical stability region of −1 ≤ a∆t∆x ≤ 1. Additionally,

the Linear Advection Lab showed the dominance of the diffusive terms in this algorithm. The diffusionwas often greater for this algorithm than for the FTBS space because of the unique ∆x2

∆t diffusioncoefficient. For example, in the case of a square wave with Courant number of 0.9 and 200 grid points,the amplitude diffused from 1 to ∼0.85 within a single period with Lax whereas it diffused to just 0.98with the FTBS scheme. as shown in Fig. 4.

(a) FTBS (b) Lax

Figure 4: Comparative Diffusion in the Lax and FTBS algorithms (square wave, 200 grid points, after 1 period)

4

Page 5: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

5 Lax-Wendroff

The theoretical accuracy and stability criteria for the Lax-Wendroff algorithm are:

O(∆t2,∆x2) −1 ≤ a∆t

∆x≤ 1

Concurring theory, the Linear Advection Lab showed the Lax-Wendroff algorithm to be unstable for allCourant numbers less than -1 and greater than 1.

The Lax-Wendroff algorithm was arguably one of the best algorithms implemented in the LinearAdvection Lab. While there was both dispersion, due to the presence of odd spatial derivatives in theapproximation (whereas the even ones all cancel out for he case of the linear advection equation), thealgorithm was quite successful overall. For example, with a square wave at 800 grid points and Courantnumber of 0.9 over 1 period, while there was mild dispersion an overall square wave is still recognizable,represented in Fig. 5.

Figure 5: Example of Lax-Wendroff Algorithm (square wave, 800 grid points, after 1 period)

Expectedly, the diffusion of the square wave was more pronounced as the number of grid points wasdecreased and as the final time was increased.

The Lax-Wendroff algorithm improves the approximation for the square wave, and is equally impressivein successfully capturing the Guass wave.When running the Guass wave, it was interesting to note thedispersion. As aforementioned, dispersion is clearly evident with the square wave. However, it is alsonoticeable, but much more subtly, in the Guass wave. For example, Fig. 6 shows dispersion near therise and decline of the Guass peak.

5

Page 6: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Figure 6: Example of Lax-Wendroff Algorithm (square wave, 800 grid points, after 1 period)

The Lax-Wendroff (and the Lax) algorithm clearly shows the power of “artificial viscosity”. TheLax-Wendroff algorithm is effectively the same as the FTCS algorithm with a diffusion added to theapproximation. This artificial viscosity made a previously unstable algorithm (FTCS) stable essentiallyby diffusing the previously unbounded growth. Because of this, the Lax-Wendroff scheme exhibits bothdiffusive and dispersive behavior but is clearly a stable and highly effective algorithm.

6 Leap-Frog

Similar to the Lax-Wendroff algorithm, the Leap-Frog algorithm has theoretical accuracy and stabilitycriteria that are:

O(∆t2,∆x2) −1 ≤ a∆t

∆x≤ 1

The Leap-Frog algorithm is centered in space and time. Whereas the FTCS is unstable, the Leap-Frogalgorithm is able to have a stable region because of the centering of both the time and space variable.

The Leap-Frog algorithm has some quite notable properties. First, it has time-reversibility. Second,it is a sympletic integrator, which indicates it conserves energy which makes it particularly useful forapplications in which modeling this is essential. However, a downside to the algorithm is that it requirestwo values of u to start the computation. Therefore, some other algorithm must be used to advancefrom n = 0 to n = 1 and then the Leap-Frog algorithm can be implemented.

As the detailed derivations in the Appendix show, the Leap-Frog algorithm has no diffusive termsbecause all even spatial derivatives cancel out. The Linear Advection Lab confirms this by showing onlydispersion with this algorithm. Increasing the number of grid points tames the dispersion, but witheven as many as 2000 grid points it is very visible, as evident in the Fig. 7 of a square wave at Courantnumber of 0.7.

6

Page 7: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Figure 7: Example of Leap-Frog Algorithm (square wave, 2000 grid points, after ∼ 0.5 period)

7 Θ-Method

The θ-method has a theoretical order of accuracy and stability criteria of:

O(∆t,∆x2) for θ 6= 1

2O(∆t2,∆x2) for θ =

1

2

Unconditionally Unstable for 0 ≤ θ < 1

2Unconditionally Stable for

1

2≤ θ ≤ 1

Note that for θ = 1 this algorithm is the implicit Forward Euler scheme and for θ = 0 this algorithm isthe FTCS scheme.

First, this algorithm was explored for a range of θ values greater than and equal to 12 and was expectedly

found to be stable for all tested Courant numbers. The algorithm did exhibit diffusion and dispersion inall these cases, except for θ = 1

2 , which corresponds to the Crank-Nicolson algorithm, in which casethere was no diffusion, corroborating the theoretical unity gain at that particular θ value.

Next, the algorithm was explored for θ values less than 12 . In these cases, the algorithm was unstable.

However, unlike the previously discussed instability cases, the algorithm took a few seconds beforeexhibiting great magnitude gains indicating instability. For example, one tested case was θ = 0.4 andCourant number of .2. Initially, the algorithm simply appeared to be highly dispersive. However, after1.5 periods it became clear it was unstable; this is different to the previous algorithms where instability(from an inappropriate Courant number) was obvious within half a period.

8 High-Order 4-2 (fourth-order space, second-order time)

The theoretical order of accuracy and stability criteria for the High-Order 4-2 algorithm are:

O(∆t2,∆x4) −0.7827 ≤ a∆t

∆x≤ 0.7827

7

Page 8: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

This was a particularly interesting algorithm to explore due to its non-integer stable Courant numberbounds. Rounding the Courant number to ± 0.73 was unacceptable and caused instability; marginallyacceptable stability was only achieved around 0.72.

The Linear Advection Lab showed this algorithm to be only dispersive, as expected by lack of evenspatial derivatives. However, the dispersion was much tamer than that of any of previously discussedalgorithms. This is due to the high order of accuracy of this particular algorithm which diminishes themagnitude of the truncation error causing the dispersion to be much less prominent. An example of thisrelatively mild dispersion is presented in Fig. 8 for a Guass wave over 10 periods with 350 grid pointsand Courant number of 0.5.

Figure 8: Example of 4-2 algorithm (guass wave, 350 grid points, 0.5 Courant number, after 10 periods)

Discussion

While each of the explored algorithms were attempting to represent the same linear advection partialdifference equation, they in fact ended up having varying properties. This is because the numericalsolution of the differential equation requires that they be transformed into algebraic form. This is doneby the method of finite differences, where the continuous variables are represented by their values at afinite set of points, and derivatives are approximated by differences between values at adjacent points.The algorithms each had a unique finite difference scheme and unique truncation error (the derivationsof which are presented in the Appendix) causing the unique behaviors amongst each algorithm.

Within all these schemes, even-numbered spatial derivative terms caused numerical diffusion whileodd-numbered derivative terms caused numerical dispersion. These numerical computation phenomenadirectly support physical intuition; physical viscosity is a dampening and dispersion describes theproperties of wave propagation, e.g. the phase and the group velocity of a wave.

The numerical behavior of the various discretization schemes was therefore largely dependent on therelative importance of dispersive and dissipative effects. This affects the behavior of the algorithmssolution, and also dictates the appropriate context of their applications.

A particularly interesting computational problem is that of shock capturing. Flow through shock wavesis complex because such flows result in sharp, discontinuous changes. Using the Linear Advection Lab,

8

Page 9: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

each algorithm’s ability to successfully capture shocks was tested by propagating a square wave. Thosealgorithms with more dispersion dominance were able to better capture the large discontinuity (diffusiondamped out the discontinuities), however this was at the expense of the phase shifts.

This tradeoff between capturing the discontinuity and increasing dispersion speaks to the fundamentalnature of using numerical algorithms to solve the partial differential equation. There is an inherentbalance to strike between diffusion and dispersion, as well as between accuracy and stability. Forexample, the FTCS algorithm is theoretically able to capture shocks aptly, but is instable for thelinear advection application. However, if an artificial diffusion is introduced, the algorithm becomes theLax-Wendroff algorithm which is stable but introduces diffusive properties to the solution. Anotherexample of tradeoffs has to do with the Courant number (a ∆t

Deltax), whereby decreasing the magnitudefo the Courant number increases stability for many of the algorithms, but this is at the cost of increaseddiffusion (FTBS and Lax algorithms).

Numerical diffusion and dispersion are inherent in finite difference models and ultimately the context ofthe application dictates which aspect of a tradeoff is more valueable and which algorithm is the mostappropriate choice.

Conclusion

The Linear Advection Lab was a convenient program to compare and contrast 8 algorithms and studytheir behaviors in detail as applied to the linear advection equation.

The program confirmed the theoretical stability regions for each algorithm and displayed their accuracy,included diffusive and dispersive errors.

The FTBS and FTFS algorithms were shown to be dominated by diffusion. The FTCS algorithm wasunstable for all Courant numbers. The Lax algorithm was highly diffusive, but provided an exampleof an algorithm previously unstable (FTCS) becoming stabilized through the addition of an artificialdiffusion term. The Lax-Wendroff improved on this concept and was an even better algorithm, thoughit did exhibit mild dispersion. The Leap-Frog method was found to be dispersive. The Θ-method wasfound to be diffusive and dispersive, except for the Crank-Nicolson case. Finally, the High-Order 4-2algorithm was found to be dispersive, but less so than the Leap-Frog method. Shock capturing wasdiscussed, particularly the ability of dispersive schemes to better capture shocks.

There inherent tradeoff nature of finite differencing schemes was explored in detail and it was ultimatelyunderstood that the context of the application dictates which algorithm is the most appropriate choice.

References

[1] Zikanov, O. Essential Computational Fluid Dynamics, John Wiley & Sons, Hoboken, NJ, 2010.

[2] Eberhardt, D.S. and Shumlak, U. AA543 Computational Fluid Dynamics I, University of Washington,Seattle, WA, 2013.

9

Page 10: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Appendix

Presented below are mathematical derivations of the order of accuracy and stability criteria for each ofthe algorithms.

A1 FTBS, Forward Euler

Order

The algorithm is given by:

un+1j = unj −

a∆t

∆x(unj − unj−1)

The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 + ...

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...

Expand the algorithm and simplify:

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 + ... = unj −

a∆t

∆x(unj − (unj −

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2− 1

6

∂3u

∂x3∆x3± ...))

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 + ... = −a∆t

∆x(∂u

∂x∆x− 1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3 ∓ ...))

∂u

∂t∆t+

a∆t

∆x

∂u

∂x∆x = −1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3 + ...− a∆t

∆x(−1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3 ∓ ...))

∂u

∂t+ a

∂u

∂x= −1

2

∂2u

∂t2∆t− 1

6

∂3u

∂t3∆t2 + ...− a(−1

2

∂2u

∂x2∆x+

1

6

∂3u

∂x3∆x2 ∓ ...))

Therefore, the order of the algorithm is:

O(∆t,∆x)

Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εn+1j = εnj −

a∆t

∆x(εnj − εnj−1)

V n+1eikj∆x = V neijk∆x − a∆t

∆x(V neikj∆x − V neik(j−1)∆x)

V n+1 = V n − a∆t

∆x(V n − V ne−ik∆x)

G =| 1− a∆t

∆x(1− e−ik∆x) |

A-1

Page 11: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Convert G to trigonometric, multiply by the complex conjugate and take the square root:

G =| 1− a∆t

∆x+a∆t

∆xCos[k∆x]− ia∆t

∆xSin[k∆x] |

G = |√

1 + 2(−1 +a∆t

∆x)a∆t

∆x− 2(−1 +

a∆t

∆x)a∆t

∆xCos[k∆x]|

The derivative of the radicand is = 0 when k∆x = π, 2π. The limiting case is k∆x = π. Solve for theCourant number using G ≤ 1 at the limiting case:

G = |√

1 + 2(−1 +a∆t

∆x)a∆t

∆x− 2(−1 +

a∆t

∆x)a∆t

∆xCos[π]|

G =

√1 + 4(−1 +

a∆t

∆x)a∆t

∆x≤ 1

Therefore, the stability condition is:

0 ≤ a∆t

∆x≤ 1

A2 FTFS

Order

The algorithm is given by:

un+1j = unj −

a∆t

∆x(unj+1 − unj )

The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 + ...

unj+1 = unj +∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 + ...

Expand the algorithm and simplify:

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 + ... = unj −

a∆t

∆x(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 + ...− unj )

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 + ... = −a∆t

∆x(∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 + ...)

∂u

∂t∆t+

a∆t

∆x

∂u

∂x∆x = −1

2

∂2u

∂t2∆t2 − ...− a∆t

∆x(1

2

∂2u

∂x2∆x2 + ...)

∂u

∂t+ a

∂u

∂x= −1

2

∂2u

∂t2∆t− ...− a(

1

2

∂2u

∂x2∆x+ ...)

Therefore, the order of the algorithm is:

O(∆t,∆x)

A-2

Page 12: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εn+1j = εnj −

a∆t

∆x(εnj+1 − εnj )

V n+1eikj∆x = V neijk∆x − a∆t

∆x(V neik(j+1)∆x − V neikj∆x)

V n+1 = V n − a∆t

∆x(V neik∆x − V n)

G =| (1− a∆t

∆x(eik∆x − 1) |

Convert G to trigonometric, multiply by the complex conjugate and take the square root:

G =| 1 +a∆t

∆x− a∆t

∆xCos[k∆x] + i

a∆t

∆xSin[k∆x] |

G =|√

1 + 2a∆t

∆x(1 +

a∆t

∆x)− 2

a∆t

∆x(1 +

a∆t

∆x)Cos[k∆x] |

The derivative of the radicand is = 0 when k∆x = π, 2π. The limiting case is k∆x = π. Solve for theCourant number using G ≤ 1 at the limiting case:

G =|√

1 + 2a∆t

∆x(1 +

a∆t

∆x)− 2

a∆t

∆x(1 +

a∆t

∆x)Cos[π] |

G =|√

1 + 4a∆t

∆x(1 +

a∆t

∆x) |≤ 1

Therefore, the stability condition is:

−1 ≤ a∆t

∆x≤ 0

A3 FTCS

Order

The algorithm is given by:

un+1j = unj −

a∆t

2∆x(unj+1 − unj−1)

The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3...

unj+1 = unj +∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...

A-3

Page 13: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...

Expand the algorithm and simplify:

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3... = unj −

a∆t

2∆x(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...

− (unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...))

∂u

∂t∆t+ a∆t

∂u

∂x= −1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3...− a∆t

2∆x(1

6

∂3u

∂x3∆x3...− (−1

6

∂3u

∂x3∆x3 ± ...))

∂u

∂t+ a

∂u

∂x= −1

2

∂2u

∂t2∆t− 1

6

∂3u

∂t3∆t2...− a

2(1

6

∂3u

∂x3∆x2...− (−1

6

∂3u

∂x3∆x2 ± ...))

Therefore, the order of the algorithm is:

O(∆t,∆x2)

Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εn+1j = εnj −

a∆t

2∆x(εnj+1 − εnj−1)

V n+1eijk∆x = V neijk∆x − a∆t

2∆x(V nei(j+1)k∆x − V nei(j−1)k∆x)

V n+1 = V n − a∆t

2∆x(V neik∆x − V ne−ik∆x)

G =| 1− a∆t

2∆x(eik∆x − e−ik∆x) |

Convert G to trigonometric, multiply by the complex conjugate and take the square root:

G =| 1− ia∆t

∆xSin[k∆x] |

G =|

√1 +

(a∆t

∆x

)2

Sin[k∆x]2 |

Clearly, for any value of of Courant number 6= 0 (which is a trivial case), G will not always be ≤ 1.Therefore, stability condition is:

Unconditionally Unstable

A-4

Page 14: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

A4 Lax

Order

The algorithm is given by:

un+1j =

unj+1 + unj−1

2− a∆t

∆x

(unj+1 − unj−1

2

)

The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3...

unj+1 = unj +∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...

Expand the algorithm and simplify:

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3... =

1

2

(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...+

(unj −

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...

))− a∆t

2∆x

(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2

+1

6

∂3u

∂x3∆x3...−

(unj −

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...

))

∂u

∂t∆t+ a

∂u

∂x= −1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3...+

1

2

(1

2

∂2u

∂x2∆x2

+ ...+

(1

2

∂2u

∂x2∆x2 ∓ ...

))− a∆t

2∆x

(1

6

∂3u

∂x3∆x3...−

(−1

6

∂3u

∂x3∆x3 ± ...

))

∂u

∂t+ a

∂u

∂x= −1

2

∂2u

∂t2∆t− 1

6

∂3u

∂t3∆t2...+

1

2∆t

(1

2

∂2u

∂x2∆x2

+ ...+

(1

2

∂2u

∂x2∆x2 ∓ ...

))− a

2

(1

6

∂3u

∂x3∆x2...−

(−1

6

∂3u

∂x3∆x2 ± ...

))

Therefore, the order of the algorithm is:

O(

∆t,∆x2

∆t

)

A-5

Page 15: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εn+1j =

εnj+1 + unj−1

2− a∆t

∆x

(εnj+1 − εnj−1

2

)

V n+1eijk∆x =V nei(j+1)k∆x + V nei(j−1)k∆x

2− a∆t

∆x

(V nei(j+1)k∆x − V nei(j−1)k∆x

2

)

G =| eik∆x + e−ik∆x

2− a∆t

∆x

(eik∆x − e−ik∆x

2

)|

Convert G to trigonometric, multiply by the complex conjugate and take the square root:

G =| Cos[k∆x]− ia∆t

∆xSin[k∆x] |

G =|

√Cos[k∆x]2 +

(a∆t

∆x

)2

Sin[k∆x]2 |

The derivative of the radicand is = 0 when k∆x = π, 2π, and ± π2 . The limiting case is k∆x = ±π

2 .Solve for the Courant number using G ≤ 1 at the limiting case:

G =|

√Cos[±π

2]2 +

(a∆t

∆x

)2

Sin[±π2

]2 |

G =|

√(a∆t

∆x

)2

|

Therefore, the stability condition is:

−1 ≤ a∆t

∆x≤ 1

A5 Lax-Wendroff

Order

The algorithm is given by:

un+1j = unj −

a∆t

2∆x(unj+1 − unj−1) +

a2∆t2

2∆x2(unj+1 − 2unj + unj−1)

The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3...

unj+1 = unj +∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...

A-6

Page 16: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...

Expand the algorithm and simplify:

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3... = unj −

a∆t

2∆x(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...

− (unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...))

+a2∆t2

2∆x2(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...− 2unj + unj

− ∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...)

∂u

∂t∆t+ a∆t

∂u

∂x= −1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3...

− a∆t

2∆x(1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...− (

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...))

+a2∆t2

2∆x2(1

2

∂2u

∂x2∆x2 + ...+

1

2

∂2u

∂x2∆x2 ∓ ...)

∂u

∂t+ a

∂u

∂x= −1

2

∂2u

∂t2∆t− 1

6

∂3u

∂t3∆t2...− a

2(1

6

∂3u

∂x3∆x2...− (−1

6

∂3u

∂x3∆x2 ± ...))

+a2∆t

2(1

2

∂2u

∂x2+ ...+

1

2

∂2u

∂x2∓ ...)

∂u

∂t+ a

∂u

∂x= −1

6

∂3u

∂t3∆t2...− a

2(1

6

∂3u

∂x3∆x2...− (−1

6

∂3u

∂x3∆x2 ± ...)) +

∆t

2(a2∂

2u

∂x2− ∂2u

∂t2) + ...

Recall that utt = a2uxx:

∂u

∂t+ a

∂u

∂x= −1

6

∂3u

∂t3∆t2...− a

2(1

6

∂3u

∂x3∆x2...− (−1

6

∂3u

∂x3∆x2 ± ...)) +

∆t

2(0) + ...

Therefore, the order of the algorithm is:

O(∆t2,∆x2

)Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εn+1j = εnj −

a∆t

2∆x(εnj+1 − εnj−1) +

a2∆t2

2∆x2(εnj+1 − 2εnj + εnj−1)

V n+1eijk∆x = V neijk∆x− a∆t

2∆x(V nei(j+1)k∆x−V nei(j−1)k∆x)+

a2∆t2

2∆x2(V nei(j+1)k∆x−2V neijk∆x+V nei(j−1)k∆x)

A-7

Page 17: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

V n+1 = V n − a∆t

2∆x(V neijk∆x − V ne−ik∆x) +

a2∆t2

2∆x2(V neik∆x − 2V n + V ne−ik∆x)

G =| 1− a∆t

2∆x(eik∆x − e−ik∆x) +

a2∆t2

2∆x2(eik∆x − 2 + e−ik∆x) |

Convert G to trigonometric, multiply by the complex conjugate and take the square root:

G =| 1−(a∆t

∆x

)2

+

(a∆t

∆x

)2

Cos[k∆x]− ia∆t

∆xSin[k∆x] |

G =|

√(1−

(a∆t

∆x

)2

+

(a∆t

∆x

)2

Cos[k∆x])2 +

(a∆t

∆x

)2

Sin[k∆x]2 |

The derivative of the radicand is = 0 when k∆x = π, 2π. The limiting case is k∆x = π. Solve for theCourant number using G ≤ 1 at the limiting case:

G =|

√(1−

(a∆t

∆x

)2

+

(a∆t

∆x

)2

Cos[π])2 +

(a∆t

∆x

)2

Sin[π]2 |

G =|

√(1− 2

(a∆t

∆x

)2

)2

Therefore, the stability condition is:

−1 ≤ a∆t

∆x≤ 1

A6 Leap-Frog

Order

The algorithm is given by:

un+1j = un−1

j − a∆t

∆x(unj+1 − unj−1)

The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3...

un−1j = unj −

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3 + ...

unj+1 = unj +∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...

A-8

Page 18: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Expand the algorithm and simplify:

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3... = unj −

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3 + ...

− a∆t

∆x(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3...

− (unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 ± ...))

∂u

∂t∆t+

a∆t

∆x

∂u

∂x∆x = −1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3...− ∂u

∂t∆t+

1

2

∂2u

∂t2∆t2

− 1

6

∂3u

∂t3∆t3 + ...− a∆t

∆x(1

6

∂3u

∂x3∆x3...− (−1

6

∂3u

∂x3∆x3 ± ...))

2∂u

∂t∆t+ 2a∆t

∂u

∂x= −1

6

∂3u

∂t3∆t3...− 1

6

∂3u

∂t3∆t3 + ...− a∆t

∆x(1

6

∂3u

∂x3∆x3...− (−1

6

∂3u

∂x3∆x3 ± ...))

∂u

∂t+ a

∂u

∂x= − 1

12

∂3u

∂t3∆t2...− 1

12

∂3u

∂t3∆t2 + ...− a(

1

12

∂3u

∂x3∆x2...− (− 1

12

∂3u

∂x3∆x2 ± ...))

Therefore, the order of the algorithm is:

O(∆t2,∆x2

)Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εn+1j = εn−1

j − a∆t

∆x(εnj+1 − εnj−1)

V n+1eijk∆x = V n−1eijk∆x − a∆t

∆x(V nei(j+1)k∆x − V nei(j−1)k∆x)

V n+1 = V n−1 − a∆t

∆x(V neik∆x − V ne−ik∆x)

G2 = 1−Ga∆t

∆x(eik∆x − e−ik∆x)

Convert G to trigonometric and solve the G quadratic:

G2 + 2ia∆t

∆xGSin[k∆x]− 1 = 0

G = −ia∆t

∆xSin[k∆x]±

√1−

(a∆t

∆x

)2

Sin[k∆x]2

Rewrite G in a compact form:

A-9

Page 19: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

A =a∆t

∆xSin[k∆x]

B =√

1−A2

G = Ai±B

If B is real, the magnitude is:

G =√A2 +B2 =

√A2 + 1−A2 =

√1 = 1

Therefore, in the case that B is real, the algorithm is always marginally stable.

For the case that B is imaginary, find the acceptable range for A:

G =| A±√

1−A2 |≤ 1→ −1 ≤ A ≤ 1

Recall A is simply a∆t∆x Sin[k∆x] Therefore, the stability condition is:

−1 ≤ a∆t

∆x≤ 1

A7 Θ-Method

Order

The algorithm is given by:

un+1j + θ

a∆t

2∆x

(un+1j+1 − u

n+1j−1

)= unj − (1− θ) a∆t

2∆x

(unj+1 − unj−1

)θ ∈ [0, 1]

The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 + ...

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 + ...

unj+1 = unj +∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3 + ...

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 + ...

un+1j+1 = unj +

∂u

∂x∆x+

∂u

∂t∆t+

1

2

(∂2u

∂x2∆x2 + 2

∂2u

∂x∂t∆x∆t+

∂2u

∂t2∆t2

)+ ...

un+1j−1 = unj −

∂u

∂x∆x+

∂u

∂t∆t+

1

2

(∂2u

∂x2∆x2 − 2

∂2u

∂x∂t∆x∆t+

∂2u

∂t2∆t2

)+ ...

Expand the algorithm and simplify:

A-10

Page 20: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 + ...+ θ

a∆t

2∆x

(unj +

∂u

∂x∆x+

∂u

∂t∆t+

1

2

(∂2u

∂x2∆x2 +

2∂2u

∂x∂t∆x∆t+

∂2u

∂t2∆t2

)+ ...− (unj −

∂u

∂x∆x+

∂u

∂t∆t+

1

2

(∂2u

∂x2∆x2 − 2

∂2u

∂x∂t∆x∆t+

∂2u

∂t2∆t2

)+

...)

)= unj − (1− θ) a∆t

2∆x

(unj

+∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3 + ...− (unj −

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 + ...)

)

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 + ...+ θ

a∆t

2∆x

(2∂u

∂x∆x+ 2

∂2u

∂x∂t∆x∆t+ ...

)= −(1− θ) a∆t

2∆x

(∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3 + ...− (−∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 + ...)

)

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 + ...+ θ

a∆t

2∆x

(2∂u

∂x∆x+

2∂2u

∂x∂t∆x∆t+ ...

)= −(1− θ) a∆t

2∆x

(2∂u

∂x∆x+ 2

1

6

∂3u

∂x3∆x3 + ...)

)

∂u

∂t∆t+ θ

a∆t

2∆x

(2∂u

∂x∆x+ 2

∂2u

∂x∂t∆x∆t+ ...

)= −(1− θ) a∆t

2∆x

(2∂u

∂x∆x

+ 21

6

∂3u

∂x3∆x3 + ...

)− 1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3 − ...

∂u

∂t∆t+ a∆t

∂u

∂x= −θ a∆t

2∆x

(2∂2u

∂x∂t∆x∆t

+ ...

)− (1− θ) a∆t

2∆x

(2

1

6

∂3u

∂x3∆x3 + ...

)− 1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3 − ...

∂u

∂t+ a

∂u

∂x= −θ a

2∆x

(2∂2u

∂x∂t∆x∆t+ ...

)− (1− θ)a

2

(2

1

6

∂3u

∂x3∆x2 + ...

)− 1

2

∂2u

∂t2∆t− 1

6

∂3u

∂t3∆t2 − ...

Recall that utt = −a(ux)t. Therefore, the order of the algorithm is:

O(∆t,∆x2) for θ 6= 1

2O(∆t2,∆x2) for θ =

1

2

Note that for θ = 1 this algorithm is the implicit Forward Euler scheme and for θ = 0 this algorithm isthe FTCS scheme.

A-11

Page 21: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εn+1j + θ

a∆t

2∆x

(εn+1j+1 − ε

n+1j−1

)= εnj − (1− θ) a∆t

2∆x

(εnj+1 − εnj−1

)

V n+1eijk∆x+θa∆t

2∆x

(V n+1ei(j+1)k∆x − V n+1ei(j−1)k∆x

)= V neijk∆x−(1−θ) a∆t

2∆x

(V nei(j+1)k∆x − V nei(j−1)k∆x

)

V n+1 + θa∆t

2∆x

(V n+1eik∆x − V n+1e−ik∆x

)= V n − (1− θ) a∆t

2∆x

(V neik∆x − V ne−ik∆x

)

V n+1(1 + θa∆t

2∆x

(eik∆x − e−ik∆x

)) = V n(1− (1− θ) a∆t

2∆x

(eik∆x − e−ik∆x

))

G =|1− (1− θ) a∆t

2∆x

(eik∆x − e−ik∆x

)1 + θ a∆t

2∆x (eik∆x − e−ik∆x)|

Convert G to trigonometric, multiply by the complex conjugate and take the square root:

G =|1 + ia∆t

∆x (−1 + θ)Sin[k∆x]

1 + ia∆t∆x θSin[k∆x]

|

G =|

√√√√1 +(a∆t∆x

)2(−1 + θ)2Sin[k∆x]2

1 +(a∆t∆x

)2θ2Sin[k∆x]2

|

The derivative of the radicand is = 0 when k∆x = 2π, π2 . For k∆x = 2π G is always 1, so the limitingcase is π

2 .

G =|

√√√√1 +(a∆t∆x

)2(−1 + θ)2Sin[π2 ]2

1 +(a∆t∆x

)2θ2Sin[π2 ]2

|

G =|

√√√√1 +(a∆t∆x

)2(−1 + θ)2

1 +(a∆t∆x

)2θ2

|

Therefore, the stability condition is given by:

Unconditionally Unstable for 0 ≤ θ < 1

2Unconditionally Stable for

1

2≤ θ ≤ 1

A-12

Page 22: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

A8 High-Order 4-2

Order

The algorithm is given by:

un+1j = un−1

j − a∆t

6∆x

(unj−2 − 8unj−1 + 8unj+1 − unj+2

)The Taylor Series expansion for each term is:

un+1j = unj +

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 +

1

24

∂4u

∂t4+

1

120

∂5u

∂t5∆t5 + ...

un−1j = unj −

∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3 +

1

24

∂4u

∂t4− 1

120

∂5u

∂t5∆t5 + ...

unj−2 = unj −∂u

∂x(2∆x) +

1

2

∂2u

∂x2(2∆x)2 − 1

6

∂3u

∂x3(2∆x)3 +

1

24

∂4u

∂x4(2∆x)4 − 1

120

∂5u

∂x5)(2∆x)5 + ...

= unj − 2∂u

∂x∆x+ 2

∂2u

∂x2∆x2 − 4

3

∂3u

∂x3∆x3 +

2

3

∂4u

∂x4∆x4 − 4

15

∂5u

∂x5∆x5 + ...

unj−1 = unj −∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 +

1

24

∂4u

∂x4∆x4 − 1

120

∂5u

∂x5∆x5 + ...

unj+1 = unj +∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3 +

1

24

∂4u

∂x4∆x4 +

1

120

∂5u

∂x5∆x5 + ...

unj+2 = unj +∂u

∂x(2∆x) +

1

2

∂2u

∂x2(2∆x)2 +

1

6

∂3u

∂x3(2∆x)3 +

1

24

∂4u

∂x4(2∆x)4 +

1

120

∂5u

∂x5)(2∆x)5 + ...

= unj + 2∂u

∂x∆x+ 2

∂2u

∂x2∆x2 +

4

3

∂3u

∂x3∆x3 +

2

3

∂4u

∂x4∆x4 +

4

15

∂5u

∂x5∆x5 + ...

Expand the algorithm and simplify:

unj +∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 +

1

6

∂3u

∂t3∆t3 +

1

24

∂4u

∂t4+

1

120

∂5u

∂t5∆t5 + ...

= unj −∂u

∂t∆t+

1

2

∂2u

∂t2∆t2 − 1

6

∂3u

∂t3∆t3 +

1

24

∂4u

∂t4− 1

120

∂5u

∂t5∆t5 + ...− a∆t

6∆x

((unj − 2

∂u

∂x∆x+ 2

∂2u

∂x2∆x2

− 4

3

∂3u

∂x3∆x3 +

2

3

∂4u

∂x4∆x4 − 4

15

∂5u

∂x5∆x5 + ...

)− 8

(unj −

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 − 1

6

∂3u

∂x3∆x3 +

1

24

∂4u

∂x4∆x4

− 1

120

∂5u

∂x5∆x5 + ...

)+ 8

(unj +

∂u

∂x∆x+

1

2

∂2u

∂x2∆x2 +

1

6

∂3u

∂x3∆x3 +

1

24

∂4u

∂x4∆x4

+1

120

∂5u

∂x5∆x5 + ...

)−(unj + 2

∂u

∂x∆x+ 2

∂2u

∂x2∆x2 +

4

3

∂3u

∂x3∆x3 +

2

3

∂4u

∂x4∆x4 +

4

15

∂5u

∂x5∆x5 + ...

))

A-13

Page 23: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

2∂u

∂t∆t+

2

6

∂3u

∂t3∆t3 +

2

120

∂5u

∂t5∆t5 + ... =

a∆t

6∆x

(−4

∂u

∂x∆x− 8

3

∂3u

∂x3∆x3 − 8

15

∂5u

∂x5∆x5

+ ...+ 16∂u

∂x∆x+

8

3

∂3u

∂x3∆x3 +

2

15

∂5u

∂x5∆x5 + ...

)

2∂u

∂t∆t+

2

6

∂3u

∂t3∆t3 +

2

120

∂5u

∂t5∆t5 + ... =

−a∆t

6∆x

(12∂u

∂x∆x− 6

15

∂5u

∂x5∆x5 + ...

)

∂u

∂t+

1

6

∂3u

∂t3∆t2 +

1

120

∂5u

∂t5∆t4 + ... = −a∂u

∂x− a

15

∂5u

∂x5∆x4 + ...

∂u

∂t+ a

∂u

∂x= −1

6

∂3u

∂t3∆t2 − 1

120

∂5u

∂t5∆t4 + ...− a

15

∂5u

∂x5∆x4 + ...

Therefore, the order of the algorithm is:

O(∆t2,∆x4)

Stability

Rewrite the finite-difference equation in terms of its error, introduce Fourier transform, and simplify:

εnj = εn−1j − a∆t

6∆x

(εnj−2 − 8εnj−1 + 8εnj+1 − εnj+2

)

V n+1eijk∆x = V n−1eijk∆x − a∆t

6∆x

(V nei(j−2)k∆x − 8V nei(j−1)k∆x + 8V nei(j+1)k∆x − V nei(j+2)k∆x

)

V n+1

V n=V n−1

V n− a∆t

6∆x

(V ne−2ik∆x − 8V ne−ik∆x + 8V neik∆x − V ne2ik∆x

)

G2 = 1−G a∆t

6∆x

(V ne−2ik∆x − 8V ne−ik∆x + 8V neik∆x − V ne2ik∆x

)Solve the quadratic for G:

G→ 1

6

(−8i

a∆t

∆xSin[k∆x] + i

a∆t

∆xSin[2k∆x]±

√36− (

a∆t

∆x)2(−8Sin[k∆x] + Sin[2k∆x])2

)

Rewrite G expressions in a compact form:

α =a∆t

∆x(−8Sin[k∆x] + Sin[2k∆x])

A = α

B =√

36− α2

G→ 1

6(Ai±B)

If B is real, the magnitude of this is simply:

A-14

Page 24: Linear Advection Lab - Mishaal Aleemmishaalaleem.com/projects/IntroCFD/MAleem_LinearAdvectionLab.pdfMishaal Aleem February 4, 2015 ... The Linear Advection Lab is a MATLAB computer

G→ 1

6(A2 +B2) =

1

6(α2 + (

√36− α2)2) =

1

6(6) = 1

Therefore, in the case that B is real, the algorithm is always marginally stable.

If B is imaginary, the magnitude is:

G→ 1

6

√(Ai±B)2

Solve for α in the case that it is marginally stable, i.e. G = 1:

1

6

√(Ai±B)2 = 1→ α = 0, α = 6

The 0 case is trivial, as it implies a Courant number of 0. Solve for the α = 6 limiting k∆x value bytaking the derivative:

∂(k∆x)(−8Sin[k∆x] + Sin[2k∆x]) = 1.79748

Solve for Courant number:

6 =

∣∣∣∣a∆t

∆x

∣∣∣∣ (−8Sin[1.79748] + Sin[2(1.79748)])→ a∆t

∆x= 0.7287

Therefore, the stability condition is given by:

−0.7827 ≤ a∆t

∆x≤ 0.7827

A-15


Recommended