Você está na página 1de 7

A TRANSIENT MANUFACTURED SOLUTION FOR THE NONDIMENSIONAL, COMPRESSIBLE NAVIERSTOKES EQUATIONS WITH A POWER LAW VISCOSITY

RHYS ULERICH

Abstract. A time-varying manufactured solution is presented for the nondimensional, compressible Navier Stokes equations under the assumption of a constant Prandtl number, Newtonian perfect gas obeying a power law viscosity. The chosen nondimensionalization employs a reference density, length, velocity, and temperature. The solution form includes waveforms with adjustable phase osets and mixed partial derivatives to bolster code coverage. Temperature, rather than pressure, is selected to have a simple analytic form to aid verifying codes having temperature-based boundary conditions. Suggested verication tests for isothermal channel and at plate codes are provided. A C++ implementation of the manufactured solution and the forcing it requires is provided. Tests are included to ensure the implementation matches the solution form to within acceptable oating point loss.

1. Mathematical model Under common assumptions the nondimensional NavierStokes equations may take the form = u + Q t 1 1 u = (u u) + Qu p + 2 t Re Ma Ma2 e = eu pu q + u + Qe t Re aided by the auxiliary relations p = ( 1) e Ma2 = T

uu 2

T = =

p 2 3

= u + uT + ( u) I

q=

1 T RePr ( 1)

where the nondimensional quantities Re = 0 u0 l0 0 Ma = u0 a0 Pr = 0 Cp 0 = Cp Cv

are the constant Reynolds number, Mach number, and Prandtl number, and ratio of specic heats, respectively. The uids nondimensional dynamic viscosity follows a power law in temperature with exponent . The uids bulk viscosity is a constant multiple of the dynamic viscosity. Setting = 0 is equivalent to Stokes hypothesis that the bulk viscosity is zero. Here e denotes the specic total energy and that later we will refer to the components of u as the scalars u, v , and w. The arbitrary forcing terms Q , Qu , and Qe will be used to obtain the desired manufactured solution.
1

2. Manufactured solution For all {, u, v, w, T } we select analytical solutions of the form (x, y, z, t) =a0
1 + ax cos bx 2xL x +cx

cos f0 t+g0 cos fx t+gx

(2)

1 1 + axy cos bxy 2xL x +cxy cos dxy 2yLy +exy cos fxy t+gxy 1 1 + axz cos bxz 2xL x +cxz cos dxz 2zLz +exz cos fxz t+gxz 1 + ay cos by 2yL y +cy

cos fy t+gy

1 1 + ayz cos byz 2yL y +cyz cos dyz 2zLz +eyz cos fyz t+gyz 1 + az cos bz 2zL z +cz

cos fz t+gz

where a, b, c, d, e, f , and g are constant coecient collections indexed by and one or more directions. To aid in providing reusable, physically realizable coecients for Cartesian domains of arbitrary size, domain extents Lx , Ly , Lz have been introduced. Partial derivatives t , x , y , z , xx , xy , xz , yy , yz , and zz may be computed directly from the chosen solutions. Though they increase the solutions complexity signicantly, mixed partial spatial derivatives are included to improve code coverage. Each term has an adjustable amplitude, frequency, and phase for all spatial dimensions. Cosines were chosen so all terms can be turned o by employing zero coecients. It is suggested that users gradually turn on the more complicated features of the solution (i.e. use non-zero coecients) after ensuring simpler usage has been successful. The Python-based computer algebra system SymPy (http://sympy.org) can both compute the derivatives and output C code for computing these values at some x, y , z , and t:
1 #! / u s r / b i n / env python

# Using sympy , c o n s t r u c t a d e s i r e d a n a l y t i c a l s o l u t i o n f o r some q u a n t i t y \ p h i . # Compute t h e a n a l y t i c a l d e r i v a t i v e s o f \ p h i and o u t p u t them as C code . This # l o g i c w i l l be used t o compute t h e manufactured s o l u t i o n s rho , u , v , w, and T.
6 from sympy import

# Coordinates v a r ( x y z t , r e a l=True )
11 # S o l u t i o n

v a r ( a 0

16

pa ra me t er s used i n a x a xy a xz b x b xy b xz c x c xy c xz d xy d xz e xy e xz f 0 f x f xy f xz g 0 g x g xy g xz

t h e form o f t h e a n a l y t i c a l s o l u t i o n a y a yz a z b y b yz b z c y c yz c z d yz e yz f y f yz f z g y g yz g z , r e a l=True ) tokens

21 v a r ( t w o p i i n v L x

# E x p l i c i t l y kee p (2 p i / L) terms t o g e t h e r as i n d i v i s i b l e twopi invLy t w o p i i n v L z , r e a l=True )

# Form t h e a n a l y t i c a l s o l u t i o n and i t s d e r i v a t i v e s phi = ( a 0 cos ( f 26 + a x c o s ( b x t w o p i i n v L x x + c x ) cos ( f + a x y c o s ( b xy t w o p i i n v L x x + c x y ) c o s ( d xy t w o p i i n v L y y + e x y ) c o s ( f + a x z c o s ( b xz t w o p i i n v L x x + c x z ) c o s ( d xz t w o p i i n v L z z + e x z ) c o s ( f + a y c o s ( b y t w o p i i n v L y y + c y ) cos ( f + a y z c o s ( b yz t w o p i i n v L y y + c y z ) c o s ( d yz t w o p i i n v L z z + e y z ) c o s ( f 31 + a z cos ( b z twopi invLz z + c z ) cos ( f ) p h i t = phi . d i f f ( t ) phi x = phi . d i f f ( x ) phi y = phi . d i f f ( y ) 36 p h i z = phi . d i f f ( z ) phi xx = phi x . d i f f (x) phi xy = phi x . d i f f (y) phi xz = phi x . d i f f ( z ) 2

0 t x t xy t xz t y t yz t z t

+ + + + + + +

g g g g g g g

0 ) x ) xy ) xz ) y ) yz ) z )

phi yy = phi y . d i f f (y)


41 p h i y z = p h i y . d i f f ( z )

phi zz = phi z . d i f f ( z ) # Save t h e s e r e s u l t s t o f i l e s s o l n . c and s o l n . h as C code from sympy . u t i l i t i e s . c o d e g e n import c o d e g e n 46 c o d e g e n ( ( ( phi , phi ), ( phi t , phi t ) , ( phi x , phi x ) , ( phi xx , phi xx ) , 51 ( phi xy , phi xy ) , ( phi xz , phi xz ) , ( phi y , phi y ) , ( phi yy , phi yy ) , ( phi yz , phi yz ) , 56 ( phi z , phi z ) , ( phi zz , phi zz ) , ), C , s o l n , h e a d e r=F a l s e , t o f i l e s =True )

3. Forcing terms The solutions given in 2 may be plugged into the model from 1 and solved for the forcing terms Q , Qu , and Qe . However, solving for these complete terms entirely within the context of a computer algebra system causes an unwieldy explosion of terms. As the fully expanded forcing terms are too large to be usable in any meaningful way, they are not shown. Instead, starting from the solution and its the analytic derivatives, we use basic calculus followed by algebraic operations performed in oating point to obtain the necessary forcing at runtime. The errors arising in this process behave like standard oating point truncation issues. Many of the computations are independent of the constitutive relations used and could be employed for other manufactured solutions. Computing the forcing terms looks as follows:
t h a t we a r e g i v e n # rho , r h o t , r h o x , r h o x x , r h o x y , r h o x z , r h o y , r h o y y , r h o y z , r h o z , r h o z z # u, u t, u x, u xx , u xy , u xz , u y, u yy , u yz , u z, u zz # v, v t , v x, v xx , v xy , v xz , v y, v yy , v yz , v z, v zz # w, w t, w x, w xx , w xy , w xz , w y, w yy , w yz , w z, w zz 6 # T, T t, T x, T xx , T xy , T xz , T y, T yy , T yz , T z, T zz # and t h e c o e f f i c i e n t s # alpha , b e t a , gamma, Ma, Pr , Re # compute t h e s o u r c e terms # Q rho , Q rhou , Q rhov , Q rhow , Q rhoe 11 # n e c e s s a r y t o f o r c e t h e s o l u t i o n rho , u , v , w, and T. # Computations stemming from t h e c o n s t i t u t i v e r e l a t i o n s h i p s e = T / gamma / (gamma 1 ) + Ma Ma ( u u + vv + ww ) / 2 e x = T x / gamma / (gamma 1 ) + Ma Ma ( u u x + v v x + w w x ) e y = T y / gamma / (gamma 1 ) + Ma Ma ( u u y + v v y + w w y ) e z = T z / gamma / (gamma 1 ) + Ma Ma ( u u z + v v z + w w z ) e t = T t / gamma / (gamma 1 ) + Ma Ma ( u u t + v v t + w w t ) p = ( rho T ) / gamma p x = ( r h o x T + r h o T x ) / gamma p y = ( r h o y T + r h o T y ) / gamma p z = ( r h o z T + r h o T z ) / gamma mu = pow (T, b e t a ) mu x = b e t a pow (T, b e t a 1 ) T x mu y = b e t a pow (T, b e t a 1 ) T y mu z = b e t a pow (T, b e t a 1 ) T z lambda = ( 3 a l p h a 2 ) mu / 3 # lambda i s a Python keyword lambda x = ( 3 a l p h a 2 ) mu x / 3 # S t r a n g e o r d e r o f o p e r a t i o n s a l l o w s . . . lambda y = ( 3 a l p h a 2 ) mu y / 3 # . . . a r b i t r a r y p r e c i s i o n l i b r a r y t o . . . lambda z = ( 3 a l p h a 2 ) mu z / 3 # . . . h a n d l e ( al pha 2/3) f a c t o r c o r r e c t l y qx = 1 / Re / Pr / (gamma 1 ) mu T x qy = 1 / Re / Pr / (gamma 1 ) mu T y qz = 1 / Re / Pr / (gamma 1 ) mu T z qx x = 1 / Re / Pr / (gamma 1 ) ( mu x T x + mu T xx ) qy y = 1 / Re / Pr / (gamma 1 ) ( mu y T y + mu T yy ) qz z = 1 / Re / Pr / (gamma 1 ) ( mu z T z + mu T zz ) # Computations stemming from t h e c o m p r e s s i b l e , Newtonian f l u i d model rhou = rho u rhov = rho v 3
1 # Assuming

16

21

26

31

36

41 rhow

rhoe rhou rhov rhow 46 r h o u rhov rhow rhoe

x y z t t t t

= = = = = = = = =

rh o rho rho rho rho rho rho rho rho

x y z t t t t

w e

u v w u v w e

+ + + + + + +

rho rho rho rho rho rho rho u) v) w) v) v) w) w) w) w) e) e) e)

+ + + + + + + + + + + +

u v w u v w e

x y z t t t t u u u u v v u v w u v w x y z x y z x y z x y z u) v) w) v) v) w) w) w) w) e) e) e) + + + + + + + + + + + + ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho u u u u v v u v w u v w u v w v v w w w w e e e x) y) z) x) y) z) x) y) z) x) y) z)

51 r h o u u x = ( r h o x

rhouv rhouw rhouv rhovv 56 rh ovw rhouw rhovw rhoww rhoue 61 r h o v e rhowe tauxx tauyy 66 t a u z z tauxy tauxz tauyz

y z x y z x y z x y z = = = = = =

= = = = = = = = = = = mu mu mu mu mu mu

( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho

y z x y z x y z x y z x y z y z z

u u u u v v u v w u v w

( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho ( rho

(u (v (w (u (u (v

+ + + + + +

u v w v w w

x ) + lambda y ) + lambda z ) + lambda x) x) y) + + + + + + x) x) x) x) y) y) u u v v w w + + + + + + x ) xx ) y ) yy ) z ) zz ) mu mu mu mu mu mu

(u x + v y + w z) (u x + v y + w z) (u x + v y + w z)

mu x ( u x + mu ( u xx tauyy y = ( mu y ( v y + mu ( v yy tauzz z = ( mu z ( w z 76 + mu ( w zz
71 t a u x x x = (

+ + + + + +

lambda x ( u x lambda ( u xx lambda y ( u x lambda ( u xy lambda z ( u x lambda ( u xz (u (u (u (u (v (v xy yy xz zz yz zz + + + + + + v v w w w w xx ) xy ) xx ) xz ) yy ) yz )

+ + + + + +

v v v v v v

y xy y yy y yz

+ + + + + +

w w w w w w

z ) xz ) ) z ) yz ) ) z ) zz ) )

tauxy tauxy tauxz 81 t a u x z tauyz tauyz

x y x z y z

= = = = = =

mu mu mu mu mu mu

x y x z y z

(u (u (u (u (v (v

y y z z z z

+ + + + + +

v v w w w w

pu x = p x u + p u x
86 pv y = p y v + p v y

pw z = utauxx vtauxy wtauxz 91 u t a u x y vtauyy wtauyz utauxz vtauyz 96 w t a u z z

p x x x y y y z z z

z = = = = = = = = =

u v w u v w u v w

w x x x y y y z z z

p w tauxx tauxy tauxz tauxy tauyy tauyz tauxz tauyz tauzz

z + + + + + + + + +

u v w u v w u v w

tauxx tauxy tauxz tauxy tauyy tauyz tauxz tauyz tauzz

x x x y y y z z z

Q rho = r h o t + r h o u x + r h o v y + r h o w z Q rhou = ( r h o u t + r h o u u x + r h o u v y + rhouw z + p x / (Ma Ma) 101 ( 1 / Re ) ( t a u x x x + t a u x y y + t a u x z Q rhov = ( r h o v t + r h o u v x + r h o v v y + r h o v w z + p y / (Ma Ma) ( 1 / Re ) ( t a u x y x + t a u y y y + t a u y z Q rhow = ( r h o w t + rhouw x + rhovw y + rhoww z 106 + p z / (Ma Ma) ( 1 / Re ) ( t a u x z x + t a u y z y + t a u z z Q rhoe = ( r h o e t + r h o u e x + r h o v e y + r h o w e z + pu x + pv y + pw z + q x x + q y y + q z (Ma Ma / Re ) ( utauxx x + vtauxy 111 + utauxy y + vtauyy + utauxz z + vtauyz

z) )

z) )

z) ) z x + wtauxz x y + wtauyz y z + wtauzz z ) )

4. Suggested coefficients for isothermal channels and flat plates Employing the manufactured solution requires xing the more than two hundred coecients appearing in equations (1) and (2). Selecting usable values is not dicult but it can be time consuming. We therefore present reasonable coecient choices for testing channel and at plate codes. In both geometries the streamwise, wall-normal, and spanwise directions are labeled x, y , and z respectively. Both x and z are periodic while y {0, Ly } is not. Transient tests should likely take place within the duration 0 t 1/10 nondimensional time units as the time phase osets (e.g. gT yz ) have been chosen for appreciable transients to occur throughout this time window. For isothermal channel ow code verication we recommend testing using 1 by = buy = bvy = bwy = bT y = 2 and the coecients given in Table 1. With these choices the manufactured solution satises isothermal, no-slip conditions at y = 0, Ly . For isothermal at plate code verication we recommend testing using 1 4 and the coecients given in Table 1. With these choices the manufactured solution satises an isothermal, no-slip condition at y = 0. by = buy = bvy = bwy = bT y = 5. Reference Implementation A templated, precision-agnostic C++ implementation for evaluating the manufactured solution and its associated forcing is included. Also included is a high precision test case which ensures the implementation computes exactly what is described in this documentation. The test can do so because it executes the same Python source les used to generate this document. One can ensure the implementation les match this documentation by comparing against the following MD5 checksums: 862eedb4f095ac3e7a772f39e74fa953 soln.py 436b0690a11dd4e0ae596eb0fab9aa50 forcing.py a3a5e76fc6338e3784aa5a5f34990486 nsctpl_rholut_fwd.hpp 7114fc79c9424e39f248f5a67a8090f9 nsctpl_rholut.hpp More details on the implementation and tests can be found in the solutions README: How to review this manufactured solution: 1) Assuming you have make, md5sum, g++, pdflatex, Python, SymPy, and SWIG installed, you can build the PDF documentation, a test program called check, and a Python module by running make. 2) Review the generated writeup.pdf to familiarize yourself with the solution. 3) Run check and review the relative errors shown to convince yourself the C++ code in nsctpl_rholut_fwd.hpp and nsctpl_rholut.hpp correctly implements the manufactured solution and the associated manufactured forcing as presented in writeup.pdf. Results are shown for float, double, and long double computations. How to use this manufactured solution in your C++ flow solver: 1) Use nsctpl_rholut_fwd.hpp and nsctpl_rholut.hpp in your code by #include-ing them. See the top of nsctpl_rholut_fwd.hpp for some #include prerequisites and check.cpp for how you might instantiate and use the provided classes. 2) At time zero, initialize your codes state to contain the exact manufactured solution.
5

3) At each time step, add the appropriate manufactured forcing to each equation within your flow solver. 4) After advancing for some time, compare the approximate state fields your flow solver has computed with the exact solution. Documentation: README: This file writeup.tex: Discussion of the model and the manufactured solution soln.py: Generates C code for the solution and its derivatives Included by writeup.tex forcing.py: Step-by-step details of computing the necessary forcing Included by writeup.tex Reference Implementation: Makefile: A GNU Makefile for building the LaTeX documentation, C++ implementation and tests, and a Python module. C++ header file with forward declarations for the manufactured solution. Code written to allow #include-ing from some other file, possibly within an anonymous namespace. C++ header file containing templated implementation details for nsctpl_rholut.hpp based upon output of running soln.py. Similar #include-related comments apply. SWIG (http://www.swig.org/) declarations for building a Python module named nsctpl_rholut exposing the C++ implementation. Python distutils script used to build nsctpl_rholut module. See Makefile for more build-related details. A Mayavi- and matplotlib-based script to visualize the effect of making different coefficient choices.

nsctpl_rholut_fwd.hpp:

nsctpl_rholut.hpp:

nsctpl_rholut.i:

setup.py:

vizcoeffs.py:

Tests: test.py: Using Sympy, computes high precision results for a particular set of solution coefficients using soln.py and forcing.py. Results saved into test.hpp and employed in check.cpp. Very simple driver used to ensure nsctpl_rholut.hpp compiles at several different precisions and behaves sanely. Checks that ensure C++ implementation matches writeup.tex/soln.py/forcing.py to acceptable tolerance.

check.cpp:

cuy = /2 =0 = 2 /3 = 1 .4 Ma = 1.15 Pr = 0.7 Re = 100 Lx = 4 Ly = 2 Lz = 4/3 fuy = 1 guy = /4 1/20 auyz = 41/257 buyz = 2 cuyz = /2 duyz = 2 euyz = /2 fuyz = 2 guyz = /4 + 1/20

fwxy = 3 gwxy = /4 awy = 7/373 bwy = see 4 cwy = /2 fwy = 1 gwy = /4 1/20 awyz = 13/389 bwyz = 2 cwyz = /2 dwyz = 2 ewyz = /2

a0 = 1 axy = 1/11 bxy = 3 dxy = 3 fxy = 3 gxy = /4 ay = 1/7 by = see 4 fy = 1 gy = /4 1/20 ayz = 1/31 byz = 2 dyz = 2 fyz = 2 gyz = /4 + 1/20

avxy = 3/337 bvxy = 3 cvxy = /2 dvxy = 3 evxy = /2 fvxy = 3 gvxy = /4 avy = 2/127 bvy = see 4 cvy = /2 fvy = 1 gvy = /4 1/20 avyz = 5/347 bvyz = 2 cvyz = /2 dvyz = 2 evyz = /2

fwyz = 2 gwyz = /4 + 1/20

aT 0 = 1 aT xy = 1/17 bT xy = 3 cT xy = /2 dT xy = 3 eT xy = /2 fT xy = 3 gT xy = /4 aT y = 1/13 bT y = see 4 cT y = /2 fT y = 1 gT y = /4 1/20 aT yz = 1/37 bT yz = 2 cT yz = /2 dT yz = 2

auxy = 37/251 buxy = 3 cuxy = /2 duxy = 3 euxy = /2 fuxy = 3 guxy = /4 auy = 1 buy = see 4

fvyz = 2 gvyz = /4 + 1/20

awxy = 11/409 bwxy = 3 cwxy = /2 dwxy = 3 ewxy = /2

eT yz = /2 fT yz = 2 gT yz = /4 + 1/20

Table 1. Coecient recommendations from section 4. Unlisted coecients should be set to zero.

Você também pode gostar