13.07.2015 Views

Contents

Contents

Contents

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AMATH 581 ( c○J. N. Kutz) 52The remaining step is to inverse transform in x and y to get back to the solutionψ(x, y).There is one mathematical difficulty which must be addressed. The streamfunctionequation with periodic boundary conditions does not have a uniquesolution. Thus if ψ 0 (x, y, t) isasolution,soisψ 0 (x, y, t) +c where c is anarbitrary constant. When solving this problem with FFTs, the FFTwillarbitrarilyadd a constant to the solution. Fundamentally, we are onlyinterestedin derivatives of the streamfunction. Therefore, this constant is inconsequential.When solving with direct methods for Ax = b, thenonuniquenessgivesasingular matrix A. ThussolvingwithGaussianelimination,LUdecompositionor iterative methods is problematic. But since the arbitray constant does notmatter, we can simply pin the streamfunction to some prescribed value on ourcomputational domain. This will fix the constant c and give a unique solutionto Ax = b. For instance, we could impose the following constraint conditionψ(−L, −L, t) =0. Suchaconditionpinsthevalueofψ(x, y, t) atthelefthandcorner of the computational domain and fixes c.MATLAB commandsThe commands for executing the Fast Fourier Transform and its inverseareasfollows• fft(x): Forward Fourier transform a vector x.• ifft(x): Inverse Fourier transform a vector x.2.5 Comparison of solution techniques for Ax=b: rules ofthumbThe practical implementation of the mathematical tools available in MATLABis crucial. This lecture will focus on the use of some of the more sophisticatedroutines in MATLAB which are cornerstones to scientific computing. Includedin this section will be a discussion of the Fast Fourier Transform routines (fft, ifft,fftshift, ifftshift, fft2, ifft2), sparse matrix construction (spdiag, spy), and highend iterative techniques for solving Ax = b (bicgstab, gmres). These routinesshould be studied carefully since they are the building blocks of any seriousscientific computing code.Fast Fourier Transform: FFT, IFFT, FFTSHIFT, IFFTSHIFT2The Fast Fourier Transform will be the first subject discussed. Its implementationis straightforward. Given a function which has been discretized with 2 npoints and represented by a vector x, theFFTisfoundwiththecommandfft(x). Asidefromtransformingthefunction,thealgorithmassociated with theFFT does three major things: it shifts the data so that x ∈ [0,L] → [−L, 0]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!