Beruflich Dokumente
Kultur Dokumente
where
hi
are
the
values
of
the
func4on
at
the
points
of
the
numerical
grid.
Discre4za4on
grid
• For
convenience,
in
the
descrip4on
of
the
method,
we
will
use
a
uniform
1D
grid
with
spacing
Δx.
we
will
refer
to
the
points
of
the
grid
as
xi.
we
obtain
Backward
scheme
• From
the
second
one:
we
obtain
Central
scheme
• Subtrac4ng
the
second
Taylor
expansion
from
the
first:
-‐
=
Accuracy
• The
terms
that
are
deleted
from
the
right
hand
sides
in
the
finite
difference
approxima4on
are
called
the
trunca'on
errors;
they
measure
the
accuracy
of
the
approxima4on
and
determine
the
rate
at
which
the
error
decreases
as
the
spacing
between
points
is
reduced.
In
par4cular,
the
first
truncated
term
is
usually
the
principal
source
of
error.
• Higher
order
of
approxima4ons
of
the
first
deriva4ve
can
be
obtained
by
using
more
points
to
eliminate
more
of
the
trunca4on
error
in
the
Taylor
expansions.
Second-‐order
deriva4ves
• Let
consider
again
the
Taylor
expansions:
+
=
Second-‐order
deriva4ves
• An
alterna4ve
deriva4on
(the
second
deriva0ve
is
the
deriva0ve
of
the
deriva0ve):
Example
• Diffusion
equa4on
with
variable
coefficient
f:
Example
• Diffusion
equa4on
with
variable
coefficient
f:
Matlab
Code
with
the
finite
difference
scheme
the
first
term
on
the
right
hand
side
can
be
approximated
by:
In
the
code:
expl_term_x(2:nx-1,:) = ( ( f(2:nx-1,:) + f(3:nx,:) ).* h_temp(3:nx,:) ...
- ( f(1:nx-2,:) + 2.0 * f(2:nx-1,:) + f(3:nx,:) ) .* h_temp(2:nx-1,:) ...
+ ( f(1:nx-2,:) + f(2:nx-1,:) ).* h_temp(1:nx-2,:) ) / ( 2.0 * delta_x^2);
Unsteady
problems
• When
considering
unsteady
problems,
we
have
to
consider
also
a
discre'za'on
in
'me
of
the
equa4on.
The
main
difference
between
the
space
and
4me
coordinate
lies
in
the
direc4on
of
influence:
whereas
the
solu4on
in
one
points
in
space
loca4on
may
influence
the
solu4on
anywhere
else,
the
solu4on
at
a
given
instant
will
affect
only
the
solu4on
in
future.
• To
be
faithful
to
this
fact,
essen4ally
all
solu4on
methods
advance
in
4me
in
a
step-‐by-‐step
or
“marching”
manner.
Nota4on
• As
we
have
done
for
the
spa4al
discre4za4on,
we
introduce
a
nota4on
for
the
solu4on
corresponding
to
a
par4cular
4me
step:
is
the
solu4on
in
the
point
xi
at
the
4me
step
tn.
Finite
differences
in
4me
• To
approximate
the
4me
deriva4ve
we
use
again
a
Taylor
series
expansion
of
h
in
the
vicinity
of
the
solu4on
at
4me
tn:
Diffusion
equa4on
• When
we
subs4tute
this
approxima4on
for
the
4me
deriva4ve
in
the
1D
costant
coefficient
diffusion
equa4on
we
obtain,
at
the
point
x=xi:
Explicit
scheme
• When
the
right
hand
side
is
evaluated
using
the
values
at
the
ini4al
4me
tn,
we
have
Implicit
scheme
• When
the
right
hand
side
is
evaluated
using
the
values
at
the
final
4me
tn+1,
we
have
Cranck-‐Nicolson
• When
the
right
hand
side
is
evaluated
using
an
average
between
the
values
at
the
ini4al
4me
tn
and
the
values
at
the
final
4me
tn+1
we
have
Accuracy
• As
we
have
done
for
the
discre4za4on
schemes
in
space,
it
is
possible
to
study
the
accuracy
of
the
discre4za4on
in
4me
with
the
implicit,
explicit
and
Cranck-‐Nicolson
schemes.
• When
we
advance
in
4me
the
solu4on,
we
are
integra4ng
the
equa4on.
We
integrate
the
deriva4ve
with
respect
to
the
4me
to
obtain
the
solu4on
at
the
new
4me
step.
This
analogy
with
the
integral
help
us
to
give
a
geometric
interpreta4on
of
the
3
schemes
and
their
accuracy.
Accuracy
Explicit
Implicit
C-‐N
Explicit Implicit
Explicit
Implicit
2D
vs
1D
• To
solve
the
2D
equa4on,
in
the
MATLAB
code
it
is
applied
an
alterna0ng
direc0on
implicit
(ADI)
scheme.
The
main
idea
of
the
ADI
method
is
to
proceed
in
two
stages,
trea4ng
only
one
deriva4ve
at
each
stage.
First
a
half-‐step
is
taken
implicitly
in
the
direc4on
x
and
explicitly
in
the
direc4on
y
followed
by
a
half-‐step
is
taken
implicitly
in
the
direc4on
y
and
explicitly
in
the
direc4on
x.
In
this
way
we
introduce
an
error
in
the
solu4on,
but
generally
the
order
of
the
error
is
smaller
than
the
other
errors
of
the
numerical
scheme.
El Mayor Cucupah original forms
n= 100