You are on page 1of 11

# 1

Computa*onal Fluid Dynamics: Lecture 19  (ME EN 6720/ CH EN 6355)

Department of Mechanical Engineering  University of Utah  Spring 2012

Prof. Rob Stoll

2  Numerical code veriﬁca*on  Physical Process   (real world observables)  Simula*on  Expe r (vali iments  da) on)  Conceptual Model  Computerized Code  •  Veriﬁca)on: we want to answer the ques*on‐  ‐  Does our numerical code represent our model properly?  or equivalently  ‐  Am I solving my equa*ons correctly?  •  Note this is diﬀerent than valida)on which asks the ques*on: “Am I solving the right  equa*ons?”  •  Valida)on involves comparison with the real world through experimental data or well  established theories.  .

i. that the accuracy of the code for a speciﬁc problem is of a par*cular level but  instead that the code for a given set of BC’s has the proper order of accuracy and  need only be done once for a par*cular code (and repeated whenever changes to the  code structure are made).e. 1998 (see Salari and Knupp.  Here we will use the  deﬁni*on from Roache.3  Veriﬁca*on  •  In the end. the code deﬁnes precisely what  equa*ons and boundary condi*ons are solved and convincingly  demonstrates that they are correctly solved by showing that the order‐of‐ accuracy is correct and that as Δ0 the code produces the exact solu*on of  the equa*ons.”  •  Note that by this deﬁni*on.  . veriﬁca*on is the process of ﬁnding code mistakes. we are not concerned with veriﬁca*on of calcula*ons. 2000 posted in the handouts)  •  Paraphrasing: “In a veriﬁed code.

. language consistency (oﬄine tes*ng)  •  Dynamic mistakes: while running the code.  Trend tes)ng:  Run the code with a variety of input parameters and then check trends  using expert judgment.  Symmetry tests:  Check the code solu*on for known symmetries.  2.    •  Example: heat conduc*on problem where steady‐state *me decreases as the  speciﬁc heat decreases.    Galilean transla*ons  invariant to ﬁxed velocity transla*ons.    Rota*ons and reﬂec*ons about a ﬁxed axis in space or *me.4  Veriﬁca*on  •  In the end we are really talking about ﬁnding code mistakes:  •  Two basic types:  •  Sta*c mistakes: compile *me errors.    •  Example: Navier‐Stokes equa*ons for homogeneous periodic condi*ons are  symmetric with respect to:    Transla*ons  the equa*ons are invariant to *me or space shihs. usually manifests  through order‐of‐ accuracy and consistency errors  •  We have a few basic approaches we can use to do dynamic tes*ng  1.  Doesn’t require  exact solu*on to be known.

Method of Exact Solu)ons (MES): ﬁnd an exact mathema*cal solu*on to the problem  of interest.  Method of Manufactured Solu)ons (MMS): To overcome diﬃcul*es of MES.5  Veriﬁca*on  3.   Comparison tests:  Use an established code and compare the new code for a deﬁned  “test case”  a code is considered acceptable if it reproduces results within a  maximum acceptable diﬀerence.  •  Diﬀerence between MMS and MES for a general problem: Du=g  .  2) exact  solu*ons may not exist (example 3D N‐S equa*ons)! 3) exact solu*ons which are  available may not be general.g.  Problem: ﬁnding a code! Making sure the results  are general.  This method is completely capable of code veriﬁca*on but has  drawbacks: 1) exact solu*ons may be complex and diﬃcult to compare with (example  inﬁnite series solu*ons for 2D heat conduc*on problem in homework 2). knowing if the “correct” code is really correct!  4.  5. we will  make up our own solu*ons then test for consistency and order‐of‐accuracy. compare code results to this solu*on for a variety of diﬀerent Δ’s (e.  homework 1).

in MMS we pick our solu*on 1st (possibly even before we know our  equa*ons!)  MMS Example: 1‐D Burger’s Equa*on  !u !u !2 u +u = " 2 what do we have in this equation? !t !x !x •  •  u(x.e. t and our equa*on must balance  What if we pick a solu*on of:  u ( x.  Method of Manufactured Solu)ons (MMS): To overcome diﬃcul*es of MES.6  Method of Manufacture Solu*ons  6. t ) = A + sin ( x + Bt ) will this sa*sfy our PDE?   .  •  Diﬀerence between MMS and MES for a general problem: Du=g    In MES we pick g ﬁnd u    In MMS we pick u ﬁnd g  •  •  diﬀeren*al  operator  solu*on  Source term (BCs etc.)  i. we will  make up our own solu*ons then test for consistency and order‐of‐accuracy.t)  u is a func*on of x.

7  Method of Manufacture Solu*ons  •  Instead we will get a solu*on to a modiﬁed version of our equa*on   •  •  Q(x. we get a diﬀerent source term  Let’s look at a speciﬁc example: pick u(x.)  !u # = 2 x 3t % !t % !u % = 3x 2 t 2 % !x \$ !u 5 4 % u = 3x t !x % % !2 u 2 " 2 = " 6 xt % !x & Subs*tu*ng these into our PDE and  solving for Q   Q ( x.t) depends on our manufactured solu*on  •  If we pick a diﬀerent solu*on (say u(x.t)=x3t2  For 1‐D Burger’s equa*on (term by term) we get:  !u !u !2u + u " ! 2 = Q ( x. t ) !t !x !x Source term (BCs etc.t)=x2e-t). t ) = 2 x 3t + 3x 5t 4 ! " 6 xt 2 .

etc.  •  It is important to note that none of these guidelines require physical realism!  \$ n uin+1 " uin"1 ' uin+1 " 2uin + uin"1 = u + !t & ui "# + Q) 2 2 ( !x ) ( !x ) % ( n i MMS Source term  .) these should follow similar rules.. α or.  range of t’s and over en*re domain)  4. central diﬀerence in space  u n +1 i •  For an implicit scheme (Ax=b) we add Q to b.  3.8  Method of Manufacture Solu*ons  •  What do we do with this in our discre*zed version of the equa*on?  •  Example: Explicit Euler.  The solu*on should be smooth and diﬀeren*able to the desired level (e..  Solu*ons should be general enough to exercise the desired terms. they should make sense and be  diﬀeren*able.  The solu*on should be valid during the en*re *me of desired simula*on (i. trigonometric func*ons)  2.g.g.  For example in Burger’s equa*on if  ! !u !u !  α is not a constant (               ) our combina*on of  α and       should be diﬀeren*able. thermal  conduc*vity.  polynomials.  •  General guidelines for picking manufactured solu)ons:  1.e.  !x !x !x •  Note that we can also construct func*onal constants to test those (e. exponen*als..  Diﬀeren*able operators should make sense.

t ) = L3 xt •  Neumann condi*ons: gradient based BCs  !u = constant " we evaluate our constant from our solution !x and enforce it at the boundaries •  What about no‐slip?  This is the same as the above cases but because of the  way that no‐slip is usually implemented in numerical codes it is many *mes  easier to simply pick a manufactured solu*on that matches the no‐slip  condi*on (in general this isn’t a bad policy).  .9  Method of Manufacture Solu*ons  •  What about boundary condi)ons?  •  Short answer  evaluate the solu*on at the boundaries  •  3 basic types:  •  Dirichlet: constant value condi*ons  evaluate our solu*on at points  where this BC is needed  For example:   u ( x. t ) = 2 x 3t 2 at x = Lx ! u ( Lx .

g.  ln(ε)  Error between exact and  manufactured at one resolu*on  P => slope  ln(Δ)  This was used in homework #1 and is discussed in more detail in lecture 5.  .10  Method of Manufacture Solu*ons  •  How do we use our exact solu)on?  •  Solu*on from numerical code  Chosen manufactured solu*on  Calculate diﬀerences (errors) i.e. CDS) we know that ε = CΔP+H... ε = f(Δ)-fexact •  For a given scheme (e.O.T.  so our solu*on should scale as P.

g. choosing a linear solu*on will turn oﬀ our diﬀusion terms. algorithmic implementa*on errors  •  Salari and Knupp (2000) Sandia Na*onal Lab report give a blind study.11  Method of Manufacture Solu*ons  More on func)on selec)on  •  We can turn terms on/oﬀ with our solu*on choice. one ﬁnd a solu*on  that turns it oﬀ without removing the diﬀusion term (hard to do everywhere  simultaneously).  •  What can we ﬁnd with MMS?  •  Bugs  •  Order of accuracy errors.    e.    What about turning oﬀ the convec*on term?  Two ways.  One possibility is to increase α •  All of these ideas can change Q  auto diﬀeren*a*on is ideal if possible. typographical errors.    Found all errors (21 cases one placebo) eﬀec*ng order‐of‐accuracy    Some bugs couldn’t be detected (ones not eﬀec*ng order‐of‐accuracy)  •  MMS doesn’t work for:    Stochas*c methods    Flux or slope limiter schemes (variable order‐of‐accuracy schemes)    Pre‐processing or post‐processing errors    Time stepping errors (order‐of‐accuracy isn’t well deﬁned)  •  ..