Lecture 21 : Compact Schemes II

IIT Kanpur July 201
20 followers
Sep 6, 2024
[Music]
[Music]
hello everyone welcome
back uh in the last class uh we looked
at the the compact schemes and we saw
that uh for a given stencil uh the
compact scheme gives you better accuracy
compared to the regular schemes for
example Central defensing and we derived
the compact scheme for the threo stensil
and that was the fourth order Equity
scheme compared to the second order equ
scheme that you see in central finishing
and we also noted uh that uh for certain
derivatives the compact scheme give you
better results better approximation of
the derivative compared to the central
differencing scheme of course like we
have this one-sided formulation you can
also have the one-sided formulation for
compact scheme so the approach Remains
the Same you write your the left hand
side in terms of the implicit points
your five I primes 5 IUS one primes 5 I
+ 1 one primes and the right hand side
are explicit points where you have the
functions available basically create a
matrix do the Matrix inversion and solve
it uh to get your the value of all the
derivatives at the same time okay not
sequentially but all the derivatives uh
in a grid will be calculated at the same
time okay that is why it is called the
compact scheme so so today we'll see
that uh we can basically increase the
stensil size and we can basically get uh
more High compact schemes okay this is
also consistent with the the the thought
that we have in the last class that uh
recall that we have discussed that if
you want to get the N derivative you
need n plus one exential point and at
least n tell Series right so for example
if you want to get the first order
derivative you need at least two stencil
point and uh at least one t expansion
right but we also said that you can uh
basically uh make use of bigger stencil
and compare more derivative terms in
your t expension uh and get more High
Rec system so what we're doing in the
compact scheme is that we are
comparing uh the higher order
derivatives in the T Series on the left
and right hand side and we are Computing
the coefficients so for the same penil
we are getting uh basically more
accuracy right by comparing the homs for
example for the compact four uh scheme
which is the three-point stanil system
we compared the first derivative and the
third derivative on the left hand side
and right hand side and we got the value
of Alpha and a okay so uh we can
increase the exential size apply more
higher order derivatives and get uh more
accurate schemes so for example today we
are going to look at the compact 6
scheme okay so this is the 6,000 compact
scheme so in this particular case uh you
can have a grid so this is your grid
okay use a black color this is I I + 1 i
- 1 I + 2 and I -2
right so what we going to do we are
going to use all these five points to
compute our derivatives at these three
points okay so you can use the Five
Points also I mean in the derivative on
the left side also but that will create
a pentagonal system and that will become
even more expensive to compute right so
what we going to do on the left hand
side keep only the I -1 I and I + 1 on
right hand side we can use the five
point stensil so that will become
Alpha 5 i - 1 Prime + 5 I prime + Alpha
5 I + 1 Prime will be now we'll have two
unknowns so when we say a this is 5 I +
1 - 5 i - 1 by 2 H and this uh you can
quickly recognize by I'm using two and
then you have B 5 I + 2 - 5 i - 2
by 4H right because uh when you are
using this i-1 and I + 1 the distance
between uh among these is 2 H and this
is basically 4
so that will Anyway come out so you can
uh use it like this and uh then uh what
you need to do you need to use the T
expansion for all these points I + 1 i -
one I + 2 i- 2 I I prime i - one and Pi
Prime I + 1 okay and then you have to
compare the coefficients on both hand
side of Pi I prime Pi I Tri Prime and 5
fifth Prime okay which is basically d f
by DX
i d Q5 by DX q i and D 55 by d x i by at
I okay so if you compare this you'll get
three equations okay one correspond to
this another to this to this and you
have three unknowns which are alpha A
and B
okay and uh you can make the
computations and you will get the value
which is basically 1X 3 4 by 9 and 1 by
9 right so this you can see that is
quickly becomes very uh tedious to make
the hand calculation but you can use
Mathematica or any uh symbolic software
or even the math lab to get these values
so you just write these three equations
compare the left hand side and right
hand side and you'll get this three
values you can basically write a code in
mat lab also okay uh it's it's very easy
okay the other thing that I want to tell
you is that you can have a trivial uh
thing which is the explicit system so
set Alpha equal to Z right if you set
Alpha equal to Z these terms Will D
vanish and then you can use your regular
General disc approach okay and uh you
can compare your uh basically right now
need one A and B so you can compare your
the first derivative and the third
derivative okay and then you'll get
this uh for a = to 4x3 and Bal to- 1 by
3 so this is your explicit fourth order
scheme and this this is your impessive 6
compact schem so you can see that using
the same stanil i - 2 i-1 I I + 1 and I
+2 you can get a high accurate
scheme uh let's say you want even more
accuracy so what you can do you can
consider this I + 3 and IUS 3 as well
okay and then your equations will change
like plus C 5 I + 3 - 5 i - 3 by 6 h
okay and then you have to compare this
uh Del 75 by DX 5 okay at I okay so you
have four unknowns now A B C and Alpha
and you have four equations pertaining
to all these four things and you can get
this values of alpha a b and c right and
you have the a. comp scheme right
similarly you can keep on increasing
stensil sides and you can have the 10th
order competive scheme 12th order
competive scheme right so uh this is how
you can increase your order of accuracy
but remember it comes at a cost if you
increase the stensil size the the
competition cost increases right so
typically in the computations you I mean
the fourth order and the sixth order
comput schemes are very very popular
okay uh one thing that I've not
discussed here that uh compact schemes
by itself uh despite being accurate uh
they are not table so you need to have a
filter okay they are called compact
filters so we'll probably discuss these
compact filters at a later point but for
now I want to leave you with a thought
that uh for a given uh stencil you can
increase the order of accuracy by making
the system implicit okay and these
schemes are called the uh the compact
schemes so uh this is just a comparison
this is three these two are three point
stals and these are fiveo stals okay and
these are the coefficients that you have
got for Alpha A and B okay we have
discussed earlier and you can see this
is the the trailing age error for the
cd2 you have this H square and for the
compact you have H4 right so this this
is the second order accurate system and
this is the fourth system but exential
Point Remains the Same the number of
points in the exential remain the same
and if you compare the CD4 and compact 6
they both you uh require Five Point
stencil okay okay uh but the order of
accuracy in the CD4 is uh 4 and for the
compact it is six right so that's why
compact schemes are more
accurate okay and U some finishing
thought that the compact schemes provide
better accuracy than the expit schemes
on the same stencil but are
computationally more expensive uh the
reason for that is uh it that lead to a
banded system and which needs to be
inverted or solved using a TDM solver
tal Matrix solver or some some you might
have read about the thos algorithms okay
basically you use the forward
substitution and backward substitution
and calculate it
okay these uh schemes are not very uh
good with gpus for example right so gpus
require your system to be uh highly
Parable but these systems are not highly
Parable so you need basically special
techniques although there are some uh sh
bu DDM Sol bu already implemented in the
ca labion Nidia but generally these are
uh not as good compared to let's say
other schemes which are not implicit
okay precisely because you have a matrix
here which needs to be inverted and it's
a very costly Affair let's say if your
grid size is very very large your Matrix
size will be very very large and
inverting that Matrix is not that easy
okay and the last thing is that at the
boundary so let's say uh this is your
boundary Point okay 1 to n and you want
to calculate this uh the compact scheme
at two okay these are the bond Val are
known but you want to get the value at
two right so you have only two points 1
and three available so right there's
nothing on the left here and nothing on
the right here so maximum that you can
use is basically compact 4
here okay even if you might be using
compact 8 or compact C at the other
points at point two you can maximum use
your compact four schemes
right and uh the other way to do it is
basically use the one-sided stencil that
means like you want to calculate the
value at two but use the points at 2 3
and 4 for example or basically maybe 2 3
4 and 1 okay so that will give you uh uh
one-sided uh I mean you need to use the
one-sided formulation for the compact
scheme
but practically speaking um even if you
use a Fed compactor scheme or you lower
the order near the boundary uh it does
not make much of a difference so uh more
more practical way is that as you come
towards the boundary from your internal
points you decrease the order okay so
you might want to use the fourth order
here sixth order here another places you
can might want to use the 8 scheme
okay doce the out of the scheme or use
the one-sided compact scheme I've not
discussed the one-sided compact scheme
derivation but you can do it like we
have been doing uh for the two-sided
scheme okay only thing is that the
Symmetry argument that you have been
making uh to reduce the number of
coefficients will not be applicable when
you use the uh one-sided scheme okay so
this finishes our discussion on the
compact scheme uh one last thing I want
to touch upon uh in terms of
discretization is the non-informed
discretization so very often your grid
will not be uniform for example let's
say if you want to calculate some
something on a flat plate okay so you
will have the bond layer which is
developing okay like this and you want
to capture the events very close to the
wall uh in the bond deer very very well
and outside anyway you know that uh the
flow is not that vertical uh you might
use the iser equation also even the B
equation will be fine but here there are
a lot of things which is happening uh
your boundary your velocity is changing
very quickly
okay so all these things are happening
here right so uh in order to uh capture
this Behavior well what you need to do
you need to make very fine mes close to
the bond layer so this is called the
bonday missing right and then as you go
up basically you can uh reduce the
number of points right this is a very
common approach in cfd so this is called
the bonday maching right so you have one
deer machine so you have very close
points near the wall and as you go away
from the wall uh the points basically uh
become uh course
right so uh in order
to handle this kind of situation let's
say if you're going to use the finite
difference formulation so this Delta X
is different from let's say this Delta X
okay so you have one on this distance
and another let's say here okay and
that's the ratio between the two is
called the stretching ratio so you can
call it if this is I and this is I + 1
and this is IUS one right so you can
call this as a Delta x i and this is
your Delta x i + 1 and similarly Delta x
i i + 2 will be different Delta x i + 3
will be different
right so Delta x i is = to x i - x i - 1
and Delta x i + 1 is will be x i + 1 - x
i okay and the task is to find this
gradient at I point I so how do we do
that okay we will use our good old old
approach that we had is so you have f i
+ 1 the Tor R approach so remember this
I I +
1 and IUS one okay so this is Delta x i
+ 1 and this is Delta x i
okay so you will have fi plus Delta x i
+ 1 fime I plus Delta x i + 1 sare by
factorial 2 F Prime I Delta x i + 1 Q
factorial 3 fi triple prime and so on so
forth fi minus one will be fi minus
Delta x i right here is I + 1 but here
it is Delta x
i okay- fi prime plus Delta X i² by
factorial 2 f i
primeus Delta x i + 1 CU by factorial 3
f i Tri Prime
okay this is your 1 and this is your 2
so do 1 - 2
that will be fi + 1 - fi -1 this will be
cancel will be equal to Delta x i + 1 +
Delta x
i right f i Prime and earlier when we
had uniform M this used to get cancelled
but this time it will not get cancelled
and this will become Delta x i + 1
s - Delta X
i² by 2
f i double Prime and then we'll have
other terms right so you rearrange it
take f i Prime will become fi + 1 - fi -
1 by Delta x i + 1 Delta x
i okay minus so this is a square - b
square and this is A + B so that will
become a minus B that's minus Delta x i
- I + 1- Delta x
i by 2 fi Prime plus other terms and
this Delta x i + 1 and Delta x i the
summation of these two so this is Delta
x i + 1 is equal to x i + 1 - x i and
Delta x i is
basically uh x i - x i - 1 if you add
these two that will become x i + 1 - x i
- 1 right so this will become fi + 1 - f
i - 1 by x i + 1
- x i - 1 and minus Delta x i + 1 -
Delta x i by 2 fi Prime and plus other
terms right so you can
uh calculate the derivative like uh this
but you can quickly notice that here you
have used the central defening approach
you consider this uh I +1 and i1 S1 both
but despite that our the the first the
accuracy is here goes as Delta X or H
right if you like that so that means it
is first order
accurate so despite using 3o stencil and
the two sided formulation uh we um got
the scheme which is the first order of
crate so because of the non-uniform mass
uh these terms do not cancel out okay
and that's why your order of requency
goes down so you this is a very uh
common thing you'll be hearing that when
you use a non-uniform mess uh your order
frequeny goes down compared to when you
use a uniform M right but sometimes you
don't have a choice as I told you that
uh uh let's say near the bond layer you
have to use stretching okay because the
things are changing very very fast and
Away uh from the bond layer the things
uh the events are not that interesting
so you're not that interested in that so
if you use uniform m in the entire thing
your G SI will be very very huge because
the minimum grid size that you require
near the bond layer is very very small
right and you don't want to use the same
grid size away from the B dealer also
okay so despite of the fact that uh your
Ry goes down you need to basically use
the uh the non-uniform mess right so uh
this is the same thing is on here
okay so uh now one question comes that
the compact scheme that we have derived
is for the uniform M so how do we use
the nonuniform m i mean compact for the
nonuniform M okay or even for let's say
for messes which are not very uh uh
nicely aligned for example if you want
to do uh flow over an arrow file right
so this is your arror file your mes will
look like this
okay like this okay and then you have M
will some look something like this right
the center one is your arrow file
okay so can we use uh basically our
compact scheme or whatever fining
difference that we have this that we
have discussed can we use on these kind
of systems right but because all of the
things that we have discussed basically
for the uniform mes okay on a cartisian
system let's say XY or X Y and G okay
where things are uh changing very
smoothly and uniform
right but we can use those formulation
all those ideas on a nonuniform mes or
even mess like this by doing something
called curv linear
transformation okay that means B
basically even if your things are
changing uh very rapidly uh right you
can con basically convert it into a
uniform
mes okay uh by using a Jacobian right so
from this mes which is changing
basically uh rapidly and this is your
uniform mess so this is your non-uniform
mess and this is your uniform
M so between that you can use a
transformation you'll get a Jacobian
which basically Maps uh each grid point
to the grid point in the uniform mess
but uh the advantage that you can use
all derivations and the compact schemes
on this uniform M uh calculate the
metric GD metric jacobians do the
calculation uniform M and do the back
transformation and get back to your non
uniform M right so you can use your hyro
schemes by doing this
transformation similarly if you have a
uh complicated grid like this not very
complicated but uh a grid which is
closed okay uh like in a cur system we
can use the transformation and use the
same ideas that we discussed for the
discreation okay so we'll be discussing
the cinear transformation uh in the
later classes so for uh today uh we will
finish with the thought that uh uh we
can approximate a function derivative
using a numerical approach and you have
many different ways of getting ration
you can have the central defensing or
the compact scheme or the one-sided
formulation and uh uh they all all
approximate uh the derivative in a
different way and you have different uh
orders of accuracy for those schemes and
we have seen some examples where we saw
that how the compact schemes are doing
better than the regular schemes right uh
but we need to discuss about the
stability issues also that we'll be
discussing in the next classes so first
we'll start with the model equations
like the convection equation diffusion
equation and conenction diffusion
equation and solve very very simple
problems on that okay using the disc as
appro that we have discussed okay after
that we'll go to the stability and uh
the accuracy consistency uh robustness
and all those kind of things how do you
know that the solution is going to
converge or not so all these things we
are going to discuss okay and then we'll
also look at the uh the Cur linear
transformation uh at a later point of
time so with that uh we'll finish the uh
discussion today I'll see you in the
next class thank you
[Music]
[Music]
[Music]
