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
verifica*on
 Physical
Process

 (real
world
observables)
 Simula*on
 Expe r (vali iments
 da) on)
 Conceptual
Model
 Computerized
Code
 • 
Verifica)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
different
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
specific
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
 defini*on
from
Roache.3
 Verifica*on
 • 
In
the
end.
the
code
defines
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
defini*on.
 .
verifica*on
is
the
process
of
finding
code
mistakes.
we
are
not
concerned
with
verifica*on
of
calcula*ons.
2000
posted
in
the
handouts)
 • 
Paraphrasing:
“In
a
verified
code.


 .
language
consistency
(offline
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
 specific
heat
decreases.
   Galilean
transla*ons

invariant
to
fixed
velocity
transla*ons.
   Rota*ons
and
reflec*ons
about
a
fixed
axis
in
space
or
*me.4
 Verifica*on
 •  In
the
end
we
are
really
talking
about
finding
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):
find
an
exact
mathema*cal
solu*on
to
the
problem
 of
interest.  Method
of
Manufactured
Solu)ons
(MMS):
To
overcome
difficul*es
of
MES.5
 Verifica*on
 3.  
Comparison
tests:

Use
an
established
code
and
compare
the
new
code
for
a
defined
 “test
case”

a
code
is
considered
acceptable
if
it
reproduces
results
within
a
 maximum
acceptable
difference.
 •  Difference
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:
finding
a
code!
Making
sure
the
results
 are
general.

This
method
is
completely
capable
of
code
verifica*on
but
has
 drawbacks:
1)
exact
solu*ons
may
be
complex
and
difficult
to
compare
with
(example
 infinite
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
different
Δ’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
difficul*es
of
MES.6
 Method
of
Manufacture
Solu*ons
 6. t ) = A + sin ( x + Bt ) will
this
sa*sfy
our
PDE?

 .
 •  Difference
between
MMS
and
MES
for
a
general
problem:
Du=g
   In
MES
we
pick
g
find
u
   In
MMS
we
pick
u
find
g
 •  •  differen*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
modified
version
of
our
equa*on

 •  •  Q(x.
we
get
a
different
source
term
 Let’s
look
at
a
specific
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
different
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
difference
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
differen*able
to
the
desired
level
(e..  Solu*ons
should
be
general
enough
to
exercise
the
desired
terms.
they
should
make
sense
and
be
 differen*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
differen*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..  Differen*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
differences
(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
off
our
diffusion
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/off
with
our
solu*on
choice.
one
find
a
solu*on
 that
turns
it
off
without
removing
the
diffusion
term
(hard
to
do
everywhere
 simultaneously).
 •  What
can
we
find
with
MMS?
 •  Bugs
 •  Order
of
accuracy
errors.
   e.
   What
about
turning
off
the
convec*on
term?

Two
ways.

One
possibility
is
to
increase
α •  All
of
these
ideas
can
change
Q

auto
differen*a*on
is
ideal
if
possible.
typographical
errors.
   Found
all
errors
(21
cases
one
placebo)
effec*ng
order‐of‐accuracy
   Some
bugs
couldn’t
be
detected
(ones
not
effec*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
defined)
 •  ..