http://www.nd.edu/~gtryggva/cfd-course/! Advection! Grétar Tryggvason! Spring! The Euler equations for D flow:! where! Define! Ideal Gas:! ρ ρu ρu + ρu + p = x ( / ) ρe ρu E + p ρ E = e + u / H = h + u /; h = e + p/ρ p = ρrt; e = e( T ); c v = de /dt h = h( T); c p = dh /dt R = c p c v ; = c p /c v ; p = ( )ρe ρ ρu ρu + ρu + p = x ( / ) ρe ρu E + p ρ p = ( )ρe c = p/ρ Expanding the derivative and rearranging the equations! ρ u ρ ρ u + u /ρ u p ρc x = + A or! x = u p The Characteristics for the Euler Equations are found by finding the eigenvalues for A T! det(a T λi) = Find! det(a T λi) = or:! or! (( ) c ) = ( u λ) u λ ( u λ) = λ = u (( u λ) c ) = u λ = ±c λ = u ± c u λ det ρ u λ ρc = /ρ u λ Therefore! λ = u c; λ = u + c; λ 3 = u The Rankine-Hugoniot conditions! For a hyperbolic system! + F x = The speed of a discontinuity (shock) is found by moving to a frame where a shock moving with speed s is stationary!! s x + F x = Integrating across the shock yields! [ ] = [ F] s f
For the Euler equations:! ρ ρu ρu + ρu + p = x ( / ) ρe ρu E + p ρ The Rankine-Hugoniot conditions are:! s( ρ L ρ R ) = (( ρu) L ( ρu) R ) s( ( ρu) L ( ρu) R ) = (( ρu + p) ρu + p L ( ) R ) s( ( ρe ) L ρe ) = (( ρu(e + p/ρ) ) L ρu(e + p/ρ) ) ( ) R ( ) R The Shock-Tube Problem! Exact Solution! The shock tube problem! u L,, ρ L! u R,, ρ R! Density! L! 5! 3!! R! Pressure! Expansion Fan! Contact! Shock! Expansion Fan! Contact! Shock!! 3!! given:!, ρ L, u L,, ρ R, u R α = +! 3!! given:!, ρ L, u L,, ρ R, u R c L = ρ L c R = ρ R Consider the case > :!!Shock separates R and!!contact discontinuity separates and 3!!Expansion fan separates 3 and L! The Rankine-Hugoniot conditions give a nonlinear P = p relation for the pressure ump across the shock! P = p L ( ) ( c R / c L )(P ) ( + ( + ) ( P ) ) which can be solved by iteration! /( )
The speed of the shock is! + ( +)P s shock = u R + c R /! 3!! x shock = x + s shock t The speed of the contact is! s contact = u 3 = u = u L + c L P p R x contact = x + s contact t The left hand side of the fan moves with speed! s fl = c L x fl = x + s fl t The right hand side of the fan moves with speed! s fr = u c L x fr = x + s fr t Left uniform state! given:!, ρ L, u L, c L = ρ L! 3!! In the expansion fan ()! + (s x) ρ = ρ c L α t u = u L + s x + t + (s x) p = p c L α t Behind the contact (3)! p 3 = p u 3 = u ρ 3 = ρ L P p R / Behind the contact (3)! p 3 = p u 3 = u ρ 3 = ρ L P p R /! 3!! Behind the shock ()! ρ = + αp α + P ρ R p = P u = u L + c L P p R α = + Right uniform state! given:!, ρ R, u R c R = ρ R The speed of sound is given by! c = p ρ The Mach number is defined as the ratio of the local velocity over the speed of sound! Ma = u c Ma < subsonic! Ma > supersonic! Test case:! Shocktube problem of G.A. Sod, JCP 7:, 97! = 5 ; ρ L =.; u L = = ; ρ R =.5; u R = t final =.5 x =.5 Subsonic case!.... x 3 5 velocity 3 5 3.... t=.5! Velocity! Pressure! Density! Mach number 3 5 Mach Number!.... 3 5 5 3 5 5 velocity x pressure 3 5.9..7..5..3.. Mach number 3 5 3 5 3 5
Test case:! Pressure! Shocktube problem of G.A. Sod, JCP 7:, 97! = 5 ; ρ L =.; u L = = ; ρ R =.; u R = t final =.5 x =.5 Supersonic case! Velocity! Mach Number! Density! Solve using second order Lax-Wendroff! For the fluid-dynamic system of equations (Euler equations):! ρ ρu ρu + ρu + p = x ( / ) ρe ρu E + p ρ where! E = e + u / ; Add the artificial viscosity to RHS:! = αh x ρ u u x x u p = ( ) ρe * f + Solutions of the D Euler equation using Lax-Wendroff! ( ).5 Δt n n ( F ) =.5 f n n + f + ( ) n f + = f n Δt h F * * + F F' = F αh ρ u h F + With an artificial viscosity term added to the corrector step! u u x x Test case:! Effect of α! Shocktube problem of G.A. Sod, JCP 7:, 97! = 5 ; ρ L =.; u L = = ; ρ R =.5; u R = Final time:.5!.... nx=; α =.5.... nx=; α =.5 α =. α =.5 α =.5 x pressure α =.5 α =. α =.5 α =.5............
nx=; nx=; nx=5; time=.5 x pressure.... Effect of resolution! α =.5........ Outline of L-W program! for istep=:! for i=:nx,p(i)=..; for i=:nx-!!!%prediction step! rh(i)=..! ruh(i)=..! reh(i)=..! for i=:nx,ph(i)=..; for i=:nx-!!!%correction step! r(i)=..! ru(i)=..! re(i)=..! for i=:nx,u(i)=ru(i)/r(i); for i=:nx-!!!%artificial viscosity! ru(i)=..! re(i)=..! time=time+dt,istep! nx=9; artvisc=.5;! hold off! %gg=.;p_left=;p_right=;r_left=;r_right=.;! gg=.;p_left=;p_right=;r_left=;r_right=.5;! xl=.;h=xl/(nx-);time=;! r=zeros(,nx);ru=zeros(,nx);re=zeros(,nx);p=zeros(,nx);! rh=zeros(,nx);ruh=zeros(,nx);reh=zeros(,nx);ph=zeros(,nx);! for i=:nx,r(i)=r_right;ru(i)=.;re(i)=p_right/(gg-); for i=:nx/; r(i)=r_left; re(i)=p_left/(gg-); rh=r;ruh=ru;reh=re;ph=p;! dt=.5*h/sqrt(.*max([7+p_right/r_right,7+p_left/r_left]) )! for istep=:! for i=:nx,p(i)=(gg-)*(re(i)-.5*(ru(i)*ru(i)/r(i))); for i=:nx-!!%prediction step! rh(i)=.5*(r(i)+r(i+))-(.5*dt/h)*(ru(i+)-ru(i));! ruh(i)=.5*(ru(i)+ru(i+))-(.5*dt/h)*((ru(i+)^/r(i+))+p(i+)-(ru(i)^/r(i))-p(i));! reh(i)=.5*(re(i)+re(i+))-...!!(.5*dt/h)*((re(i+)*ru(i+)/r(i+))+(ru(i+)*p(i+)/r(i+))...!!! -(re(i)* ru(i) /r(i))- (ru(i) *p(i) /r(i)));! for i=:nx,ph(i)=(gg-)*(reh(i)-.5*(ruh(i)*ruh(i)/rh(i))); for i=:nx-!!%correction step! r(i)=r(i)-(dt/h)*(ruh(i)-ruh(i-));! ru(i)=ru(i)-(dt/h)*((ruh(i)^/rh(i))-(ruh(i-)^/rh(i-))+ph(i)-ph(i-));! re(i)=re(i)-(dt/h)*((reh(i)*ruh(i)/rh(i))-(reh(i-)*ruh(i-)/rh(i-))+...!!(ruh(i)*ph(i)/rh(i))-(ruh(i-)*ph(i-)/rh(i-)));! for i=:nx,u(i)=ru(i)/r(i); Flux Vector Splitting! for i=:nx-!!%artificial viscosity! ru(i)=ru(i)+artvisc*(.5*dt/h)*( (r(i)+r(i+))*(u(i+)-u(i))*abs(u(i+)-u(i))...! -(r(i)+r(i-))*(u(i)-u(i-))*abs(u(i)-u(i-)) );! re(i)=re(i)+artvisc*(.5*dt/h)*...! ( (u(i+)+u(i))*(r(i)+r(i+))*(u(i+)-u(i))*abs(u(i+)-u(i))...! -(u(i)+u(i-))*(r(i)+r(i-))*(u(i)-u(i-))*abs(u(i)-u(i-)) );! time=time+dt,istep! plot(p,'b','linewidth',),title('pressure'); pause! if(time >.5)break, For upwind schemes, it is necessary to determine the upstream direction. For systems with many characteristics running both left and right, there is not one upstream direction! Upwind Scheme - Revisited! Generalized Upwind Scheme (for both U > and U < )! Define! f f UΔt n n ( f f ), h U > UΔt n n ( f f ), h U < n+ n = f n+ n = f + U + = ( U + U ), U = ( U U ) The two cases can be combined into a single expression:! [ ] n f + = f n Δt h U + ( f n f n ) + U ( f n + f n )
A system of hyperbolic equations! For a system of equations there are generally waves running in both directions. To apply upwinding, the fluxes must be decomposed into left and right running waves! + F x = can be written in the form! + [ A] x = ; The system is hyperbolic if! Steger-Warming (979)! [ A] = F [ T ] [ A] [ T] = [ λ]; [ T ] = T q T q N F = [ A]f = T The matrix of eigenvalues Hence! [ A] = A + [ ][ λ] [ T] f [ λ] [ λ] = [ λ + ] + [ λ ] [ ] + [ A ] = [ T ][ λ + ] T is divided into two matrices! [ ] T [ ] + [ T] λ [ ] ( ) Define! F = F + + F F + = [ A + ]f, F = [ A ]f Conservation law becomes! + F + x + F x = Example: -D Hyperbolic Equation! Leading to! v t w t + c f c f x = v x w x = f = v w ; F = c w v ; v = ; w = x [ A] = F = c [ T ] = q T = c T λ + q c ; [ ] = c [ A + ] = [ T ] [ λ + ][ T] ; [ A ] = [ T] [ λ ][ T ] F + = [ A + ]f; F = [ A ]f Leading to:! F + = cv c w ; F = cv c w v + cw v cw c [ λ ] = Solve using first order upwinding with flux splitting! For a nonlinear system of equations such as the Euler equations, there is some arbitrariness in how the system is split!
Here we solve the one-dimensional Euler equation using the van Leer vector flux splitting! Van Leer! F + = ρ (u + c) c ( )u + c ( )u + c ( ) F = ρ (u c) c ( )u c c ( )u ( ) van Leer vector flux splitting! ρu ρu + p = ρ ρu(e + p c ρ ) (u + c) For example, the mass flux:! ρ c (u + c) ρ (u c) c ( )u + c ( )u + c ( ) ρ (u c) c ( ) = ρ c = ρ c u + uc + c u + uc c ( )u c c ( )u ( ) uc = ρu Steger-Warming! F + = ρ Several other splitting schemes are possible, such as:! ( )u + c ( )u + (u + c) ( )u 3 + (u + c)3 + 3 (u + c)c ( ) F = ρ (u c) u c (u c) + 3 c F + = ρ (u + c) c Rewrite the flux terms in terms of Mach number:! ( )u + c ( )u + c ( ) = ρc u c + c + u c c + u c = ρc ( M + ) c + M c + M + F + x + F - x = ρ ρu + ρc ρe x ( M + c ) + M + x ρc ( M c ) + M = c + M c M + F+ x + F- x = Solve by! f n+ = f n Δt h F + + F - Where! ( ) n Δt ( ) n - - h F + F F + = ρc ( M + c ) + M ; F = ρc ( M c ) + M c + M c M
for istep=:maxstep for i=:nx,c(i)=sqrt( gg*(gg-)*(re(i)-.5*(ru(i)^/r(i)))/r(i) );end for i=:nx,u(i)=ru(i)/r(i);end; for i=:nx,m(i)=u(i)/c(i);end for i=:nx- %upwind rn(i)=r(i)-(dt/h)*(... (.5*r(i)*c(i)*(m(i)+)^) - (.5*r(i-)*c(i-)*(m(i-)+)^)+... (-.5*r(i+)*c(i+)*(m(i+)-)^) - (-.5*r(i)*c(i)*(m(i)-)^) ); run(i)=ru(i)-(dt/h)*(... (.5*r(i)*c(i) *(m(i)+)^) *(( +.5*(gg-)*m(i)) **c(i) /gg) -... (.5*r(i-)*c(i-)*(m(i-)+)^)*(( +.5*(gg-)*m(i-))**c(i-)/gg) +... (-.5*r(i+)*c(i+)*(m(i+)-)^)*((-+.5*(gg-)*m(i+))**c(i+)/gg) -... (-.5*r(i)*c(i) *(m(i)-)^) *((-+.5*(gg-)*m(i)) **c(i) /gg) ); ren(i)=re(i)-(dt/h)*(... (.5*r(i)*c(i) *(m(i)+)^) *((+.5*(gg-)*m(i))^ **c(i)^ /(gg^-)) -... (.5*r(i-)*c(i-)*(m(i-)+)^)*((+.5*(gg-)*m(i-))^**c(i-)^/(gg^-)) +... (-.5*r(i+)*c(i+)*(m(i+)-)^)*((-.5*(gg-)*m(i+))^**c(i+)^/(gg^-)) -... (-.5*r(i)*c(i) *(m(i)-)^) *((-.5*(gg-)*m(i))^ **c(i)^ /(gg^-)) ); end Effect of resolution! Shocktube problem of G.A. = 5 ; ρ L =.; u L = Sod, JCP 7:, 97! = ; ρ R =.5; u R = x Pressure nx=; maxstep=3! nx=5; maxstep=! Final time:.5! Density... nx=; maxstep=3! nx=; maxstep=!. nx=5; maxstep=! nx=5; maxstep=5! Summary! Numerical solutions of the onedimensional Euler equations! Upwind/flux splitting! Lax-Wendroff/artificial viscosity!