Paper 3A3 The Equaios of Fluid Flow ad Their Numerical Soluio Hadou Iroducio A grea ma fluid flow problems are ow solved b use of Compuaioal Fluid Damics (CFD) packages. Oe of he major obsacles o he good use of he resulig umerical soluios is how o evaluae heir accurac, which i ur meas udersadig he assumpios ad limiaios of he mehods used. The ol real wa of doig his is o use he udersadig of he basic priciples of fluid flow as covered i he res of papers 3A-4, ogeher wih a udersadig of he geeral limiaios of umerical mehods, which we will ouch o i his par of he course. I he few lecures available here here is ime ol o cosider a ver brief iroducio o he equaios ad he mehods used o solve hem. A more exesive course, based mail o coursework, is available i he 4A module i he fourh ear. Oulie of Course Some umerical basics. The equaios of moio. Phsical ierpreaio ad heir formulaio as differeial equaios or corol volume (iegral) equaios. The problem of urbulece. Hierarch of levels of simplificaio. 3 Numerical approximaios. Order of accurac. Poi sabili aalsis. Classificaio as hperbolic, ellipic ad parabolic equaios. 4 Example of a parabolic equaio he soluio of he D boudar laer equaios. A simple urbulece model. 5 Example of a ellipic equaio he soluio of he D compressible poeial flow equaio. 6 Example of a hperbolic equaio he soluio of he D Euler equaios. There ma ol be ime o cover of 4, 5 & 6. Books There are ma books o CFD; mos of hem are far oo deailed for his course. The oe perhaps mos suiable bu sill far oo deailed is: Compuaioal Fluid Damics The Basics wih Applicaios b J D Aderso Jr. McGraw-Hill 995 Oher Ifo 5 lecures, example paper, plus (opioal) DPO sessio (Thur Wk 9, -). This sessio replaces oe of he 6 scheduled lecures. There will be o lecure o Thu 8 h March (Wk 8). There are a umber of compuer demosraios/matlab exercises associaed wih his course. Occasioall, I will give ou he odd MATLAB scrip for ou o pla wih. This will be doe b dowloadig from websie:- hp://www.eg.cam.ac.uk/~ph
Some Numerical Basics Before examiig echiques for he parial differeial equaios applicable o fluid flow, i is worh examiig some simple ordiar differeial cases problems ha we ca solve b oher (aalic) meas so ha we ca check he resuls. Problem Solve d subjec o he boudar codiios:- for which he soluio is, of course, + Ω = () d = = Ω ( ) ( ) ( ) si = Ω. Fiie Differece Scheme The aural wa o represe a fucio of ime umericall is o divide ime io discree seps each of legh, ad o keep rack of he values of a he ed of each ime ierval. Deoe he value of a = b (=,,,...). A umerical esimae of he derivaive of a ime ca be foud b cosiderig he slope of he lie joiig successive pois. d + = + Oe ca hik of his as approximaig he fucio over he ierval b a simple fucio (i his case a sraigh lie) ad usig his approximaio as a meas of esimaig he derivaive. To esimae he value of he secod derivaive (which is relaed o curvaure) a a give ime, sraigh lie approximaios o i each ierval are o good eough. The ex level of complexi would be o ake a local quadraic fi o. A quadraic passig hrough cosecuive pois ca be show o be approx = α( ) + β( ) + γ where + + + α = β = This has d + + approx = α = The origial differeial equaio has ow become a differece equaio. (A fiie differece approx) d + Ω = γ = + + + Ω = +
Algorihm The differece equaio ca be recas as ( ) + = Ω () To solve his eeds wo iiial codiios ad. Whe hese are kow, ad all d succeedig values ca be geeraed i ur. The iiial codiios are ( ) which become = ad = Ω i.e. = ad ( ) = Ω The figure shows he case of Ω= ad =.. The circles are geeraed from he differece equaio, while he solid lie is he aalic, exac soluio. I is difficul o see he error. = Ω We have followed his procedure for a rivial equaio. I applies wihou modificaio o much more complicaed equaios which ca o be solved aalicall. Turig he differeial equaio io a differece oe is jus as eas for complicaed equaios. E.g. d Check + e si = + + ( ) + = e si + + e si = The ver saisfacor agreeme obaied i he above figure is far from he whole sor. Le us examie he soluios of he differece equaio i more deail. Pu = λ λ ( Ω ) λ + = 3
Ω Ω i.e. λ = ± iω 4 Ω Ω ad λ = ±Ω 4 leadig o a geeral soluio = Aλ + Bλ whe Ω < whe Ω > Case (a) Ω < Noe ha for each of he λ's Ω Ω Re( λ) + Im( λ) = +Ω 4 i Sice he have modulus oe, he firs roo ca be wrie λ = e α i ad he secod is λ = e α. Applig he boudar codiios gives A+ B = ad iα iα Ae + Be = Ω iα iα ( ) Ω = e e iα iα e e Now for small values of Ω, α ( λ ) A = B = = e iα Ω e Ω si α siα = iα givig si = Im Ω which meas α Ω. The form for he soluio o he differece equaio becomes si Ω = si Ω agreeig wih he exac soluio of he differeial equaio. As Ω ges larger, is sill periodic, bu he ampliude of oscillaio is o loger ui ad he period is differe o Ω. The figure shows Ω = ad =.5 4
Case (b) Ω > We fid i his case (exercise) ha λ > ad λ <. The geeral soluio = Aλ + Bλ as. The figure shows he case Ω = ad =.. Aalsis (i) If Ω, i.e. π, he clearl Ω ad d + d + + + are good approximaios ad he soluio of he differece equaio is close o he soluio of he differeial equaio. 5
If is comparable wih π Ω, he d + ad d + + is pure ficio. Clearl has o be chose o be much smaller ha he wavelegh (or ime over which we have sigifica variaio) of he soluio. I his case, we kow Ω. I mos cases we do o. + (ii) This raises he geeral quesio of jus how accurae is he soluio. The wa o assess i is b Talor's heorem. 3 3 d d d ( + ) = ( ) + + + +... (a)! 3! 3 Thus ad 3 3 d d d ( ) = ( ) + +... (b)! 3! 3 ( + ) 3 ( ) d d d = + + +...! 3! 3 ( + ) 4 ( ) + ( ) d d = + +... (c) 4! 4 The approximaio for d + d ad ha for + + is he accurae o firs order i he imesep, is secod order accurae. All of he erms egleced o he righ had side of hese equaios are referred o as he rucaio error. A glace a equaios (a) ad (b) above shows ha sice he erms o he righ had side of (b) alerae i sig, while hose of (a) all have he same sig, he if we add or subrac (a) ad (b) ol alerae erms will survive. This meas ha, if we use a combiaio which has smmer abou he ceral poi (as i case (c) above), he rucaio error will be a leas secod order. Such smmeric expressios are referred o as ceral differeces. 6
We sared wih polomial fis o a fucio i order o creae approximaios o derivaives. Talor series expasios, like (a) ad (b) above, ca also be used o do his. We ca make he idea skeched above ha he size of has o be small i compariso wih he scale over which he soluio o he differeial equaio varies more precise b hikig of he properies of he soluios obaied o he differeial ad he differece equaios. i The soluio o he differeial equaio is of he form e Ω givig iω ( + u( +) e ) iω = = e u( ) iω e The correspodig soluio o he differece equaio is of he form λ Ω Ω λ = + iω 4 This meas ha u + Ω λ i Ω = = + Ω u 4 For small, u( +) u ( ) i 3 Ω ( Ω ) ( ) Ω = e = + iω i +...! 3! + 3 3 u Ω Ω = λ = + iω + i +... u 8 The sharp-eed amogs ou will ask abou he boudar codiios ha we applied a =. The approximaio for he derivaive a he origi was ol firs order accurae, bu his did o seem o be refleced i he accurac of he soluio here. The aswer o his is ha we were luck! I geeral, a firs order accurae boudar codiio will lead o a firs order accurae soluio. I his case, however, he rucaio error i he derivaive a =, was of he form ( ) ( ) 3 d d d = + + + 3! 3!... ad i jus happeed ha d = (iii) Someimes he properies of he differece equaio bear o relaioship o hose of he differeial equaio. For example, he umber of idepede soluios of he differece equaio is ofe o he same as he umber of idepede soluios of he differeial equaio. Someimes he differece equaio is usable o maer how small. A good example of his pe of behaviour appears o he examples paper. See quesio. Everhig ha has bee said abou he soluio of ode s here applies also o PDE s. As he course progresses, we shall see ha ode s are, i fac, relaivel beig! 7
Simple Hea Coducio Equaio. Le us cosider a similar exercise for he scalar diffusio equaio (e.g. hea coducio equaio i a bar, wih he emperaures of he eds held cosa). u u = ν x u = u L = wih he boudar codiios ( ) ( ) A ime =, he iiial value of u is give b (,) u x x L for < x< L = x L for < x< L L This ime we discreise space ad ime ad deoe our approximaio o u a x= i x, = If we use a cered differece represeaio for a oe-sided represeaio for u, we have: + ui ui ui+ ui + ui = ν x u x Usig he Talor series expasios above, his meas + u 3 i ui u u u = + + + 3 i,! 3! i, i, u 4 i+ ui + ui u x u = + + 4! 4 x x i, x i, So ha he rucaio error is ow O(, x ) ad secod order accurae i space). N.B. NOT i = or N x (3) ad u... = + O( ) u... = + O( x ) x (or our approximaio is firs order accurae i ime ( + ) + ν ui = ui + u i ui + ui x for < i< Nx Jus as for he ode, we ca solve equaio () for u i + ad ierae forward i ime. i.e. if we kow u i for all i (i.e. i Nx a some ime =, his equaio is solved for each value of i i ur o geerae u i + for all i (< i< Nx ). We ca also fid values for u i + for i = ad i = N x usig he boudar codiios. 8
Figure shows he umerical soluio for wo choices of imesep give b ν (i) =.49 x 5 4.5 4 3.5 3.5.5.5...3.4.5.6.7.8.9 (ii) ν x =.5 6 5 4 3...3.4.5.6.7.8.9 ν We will show i a laer lecure ha he heoreical limi for sabili is = x.5 9
The followig MATLAB (or OCTAVE) m file produced hese plos. x=; for i=:x x(i) = (i-)*./(x-); if i < x/ u(i) = *x(i); else u(i) = *(.-x(i)); ed ed hold o; plo(x,u,'r','liewih',.5); al =.49; = ; plo=; for =: for i=:x- u(i) = u(i)+al*(u(i+)-*u(i)+u(i-)); ed u() = ; u(x) = ; if rem(,plo)== plo(x,u,'b','liewih',.5); ed u = u; ed hold off;