# Rice CAAM 471 - Lecture Notes (32 pages)

Previewing pages 1, 2, 15, 16, 31, 32 of 32 page document
View Full Document

## Lecture Notes

Previewing pages 1, 2, 15, 16, 31, 32 of actual document.

View Full Document
View Full Document

## Lecture Notes

42 views

Pages:
32
School:
Rice University
Course:
Caam 471 - Intro to Linear/integer Prog.
##### Intro to Linear/integer Prog. Documents
• 22 pages

• 14 pages

• 13 pages

• 32 pages

• 21 pages

• 29 pages

• 21 pages

• 35 pages

• 15 pages

• 19 pages

• 30 pages

• 7 pages

• 26 pages

• 30 pages

Unformatted text preview:

Lecture 22 MA471 Fall 2003 Advection Equation Recall the 2D advection equation C C C x y a a 0 t x y We will use a Runge Kutta time integrator and spectral representation in space Periodic Data Let s assume we are given N values of a function f at N data points on the unit interval For instance N 8 on a unit interval 0 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 Discrete Fourier Transform We can seek a trigonometric interpolation of a function f as a linear combination of N even trigonometric functions If x k N 2 k N 2 1 Such that f x j If x j k N 2 k N 2 1 j where x j N f eik 2p x k f eik 2p x j for j 1 N k Transform The interpolation formula defines a linear system for the unknown fhat coefficients fj k N 2 k N 2 1 f 1 k N j N f eik 2p x j for j 1 N k f e j j 1 ik 2p x j N N for k 1 2 2 Or f ifft f f fft f Code for the DFT Code for Inverse DFT Fast Fourier Transform See handout Spectral Derivative We can differentiate the interpolant by If x k N 2 k N 2 1 k N 2 f ei 2pkx k dIf ik 2p x x ik 2p f k e dx k N 2 1 Detail We note that the derivative of the k N 2 mode iN2 2p x e fN 2 is technically iN 2p x iN 2 2p e fN 2 2 However as we show on the next slide this mode has turning points at all the data points Real Component of N 2 Mode i e the slope of the k N 2 mode is zero at all the 8 points Modified Derivative Formula So we can create an alternative symmetric derivative formula k N 2 1 dIf 1 ik 2p x x ik 2p f k e dx 2p k N 2 1 Spectral Differentiation Scheme 1 Use an fft to compute f for k N 1 N 2 1 0 1 N k 2 2 2 2 Differentiate in spectral space i e compute N N i 2p k f k for k 1 1 2 2 g k N 0 for k 2 cont 3 Then k N 2 dIf ikx x g k e dx k N 2 1 4 Summary a fft transform data to compute coefficients b scale Fourier coefficients c inverse fft ifft scaled coefficients Final Twist Matlab stores the coefficients from the fast Fourier transform in a slightly odd order f 0 f 1 f N f N f 2 1 2 N 1 2 f N 2 2 f 1 The derivative matrix will now be a matrix with diagonal entries N N N i 2p 0 1 1 0 1 2 1 2 2 2 Spectral Differentiation Code Typo See corrected Code on webpage 1 DFT data 2 Scale Fourier coefficients 3 IFT scaled coefficients Two Dimensional Fourier Transform We can now construct a Fourier expansion in two variables for a function of two variables If x y k N 2 j N 2 f eij 2p x eik 2p y k N 2 1 j N 2 1 jk The 2D inverse discrete transform and discrete transform are f nm k N 2 j N 2 k N 2 1 j N 2 1 f 1 jk N2 n N m N f n 1 m 1 nm e f jk eij 2p xn eik 2p ym for n m 1 N ij 2p xn ik 2p ym e N N for j k 1 2 2 Advection Equation Recall the 2D advection equation C C C x y a a 0 t x y We will use a Runge Kutta time integrator and spectral representation in space Runge Kutta Time Integrator We will now discuss a particularly simple Runge Kutta time integrator introduced by Jameson Schmidt Turkel The idea is each time step is divided into s substeps which taken together approximate the update to s th order Side note Jameson Schmidt Turkel Runge Kutta Integrator Taylor s theorem tell s us that 2 s s dt d dt 2 d dt d C t dt 1 C t 1 dt 2 dt s dt dt s 1 d s 1C t for some t t t dt s 1 s 1 dt We will compute an approximate update as 2 s s dt d dt 2 d dt d C t dt 1 C t dt 2 dt 1 s dt JST Runge Kutta The numerical scheme will look like 2 s s dt d dt 2 d dt d C t dt 1 C t 1 dt 2 dt s dt 2 s 2 s dt d dt d dt d n n 1 C 1 C 1 dt 2 dt s dt We then factorize the polynomial derivative term Factorized Scheme 2 s 2 s dt d dt d dt d n n 1 C 1 C 1 dt 2 dt s dt n dt d dt d dt d dt dC n n n 1 n n C C C C C s dt s 1 dt s 2 dt 1 dt Set C C n for k s 1 1 dt dC n C C k dt end Cn 1 C JST Advection Equation We now use the PDE definition Set C C n for k s 1 1 dt dC C Cn k dt end C C C a x a y 0 t x y Cn 1 C Set C C n for k s 1 1 dt x C C y C C a a k x y end n Cn 1 C Now Use Spectral Representation time step now consists of s substages ach stage involves Fourier transforming the ctilde using a fast Fourier transform fft Scaling the coefficients to differentiate in Fourier space Transforming the derivatives back to physical values at the nodes by inverse fast Fourier transform ifft Finally updating ctilde according to the advection equation t the end we update the concentration Set c c for k s 1 1 c fft c d x D x c d y D y c ifft d d x ifft d x dy y dt x x c j c j a j d j a yj d yj for j 1 N k end c c Matlab Implementation First set up the nodes and the differentiation scalings 24 Compute dt 26 Initiate concentration 28 29 compute advection vector 32 45 full RungeKutta time step 35 fft ctilde 37 x and ydifferentiation in Fourier space 40 41 transform back to physical values of derivatives 43 Update ctilde C C C x y a a 0 t x y C t 0 x y e a x sin 2p x cos 2p x 2 200 x 75 y …

View Full Document

Unlocking...