Lecture 22 : Model Equations I

IIT Kanpur July 201
20 followers
1 Video View·Sep 6, 2024
[Music]
hello everyone welcome back in the last
couple of classes we looked at different
discretion approaches uh especially the
spatial
discretization where we saw how to
basically use the two-sided formulation
on one SED formulation to get uh
basically approximate of an derivative
using the numerical approach okay for a
given
grade uh we also looked at the compact
schemes which basically gives you a
higher of accuracy for the same stencil
okay now it's time to use those disc
schemes to solve uh some problems okay
so of course the problem that you want
to solve is the ne stroke equations
right so these are the equations that
govern the fluid flows but NE sto
equations are complicated okay so before
we basically dive into the full FL Stoke
equations uh we need to look at uh
simple equations uh which we call as a
model equations and try to solve them
using the discr approaches because these
simple equations give you a lot of
insights about the behavior of these
numerical
schemes okay so uh let's start the class
then okay so before going there let's
say that uh we want to solve the
equations so what are the terms that we
have in the N equations so let's take
very simple one di n equations okay and
incompressible so let's simplify the N
equation as much as we can right so we
can write this uh d by DT uh plus u d by
DX okay is equal to - 1 by row DP by DX
and uh plus new d s u by D x² right and
Let's ignore any body term that may be
present right from our knowledge uh that
we gained in the last few classes we
know that this is a temporal term this
is the convection term which represents
the hyperbolicity in the equation uh
this is the diffusion term okay which
represents the ellipticity in the
equation and in different limits the
mark number and the Ros number these
equations may be more close to an
elliptic equation or an hyperbolic
equation okay and because of the
presence of this time term it's also a
parabolic equation okay so you can write
it uh maybe in a conservation
form okay that will be u s by 2 + P by
row will be new Delta U by Del x² right
now this also like uh this is only the
momentum equation you may have you must
have the mass conservation and you may
have the energy conservation also okay
uh especially in the compersive flows
okay so uh if you try to solve it you
have I mean two three variables at least
in this case you have U and P in the one
dimensional case and if it is
compressible then you'll have row also
and T also okay so uh before showing
this solving this problem which has got
two variables to solve okay we'll look
at simple problems so let's start taking
uh breaking these equations into simple
simple equations okay let's have
equation which is d by DT plus U by DX
and let's put all other terms on the
right hand side at zero right so this
equation is called the nonlinear
conenction
equation okay
why it is nonlinear so of course we have
discussed property of the equation but
one very simple way to look into uh
whether the equation is linear nonlinear
is that let's say this has got two
solution this equation got two solution
one is U1 and other is
U2 okay if you add these two solutions
they individually satisfy this equation
and if you add them up that should if
they also satisfy this equation then
it's a linear equation so let's say this
U1 has got it satisfy the equation so D1
by DT + U1 d by DX =
0 and D U2 by DT + U2 D U2 by D xal to 0
right so these are the two solutions for
this equation and if you add them up
let's say you do a plus
b okay and if that also satisfy this
equation then it's a linear otherwise
it's a nonlinear equation so if you do
that
this is Del by DT U1 +
U2 okay plus U1 d 1 by DX plus U2 D U2
by DX right so it does not satisfy right
it does not satisfy this equation so
that's why it is not a linear a
nonlinear
equation okay let's simplify it further
okay write equation which is Del by DT
and the keep the convection speed as
constant so C is a
constant okay
and if this has got two solution U1 and
U2 okay you can quickly see that this
thing will transform so this will
become c d by DX and C D2 by DX and then
you can write it uh
as c d by DX U1 plus u U2 right so when
U1 satisfies the this equation and U2
also satisfy this uh equation and the
linear combination of both the solution
also satisfy this equation then these
equations are basically the so this will
become a linear equation
right so before even looking into this
nonlinear equation we look into this
linear conenction so this is a linear
convection equation
we have also seen earlier that it
represents a wave equation okay so you
can also write it Delta U by Delta s
equal to c² Delta U by D x² all you need
to do is like you write d by dtal to
minus c d by DX and then you double
differentiate it and substitute
basically interchange the Del by DT and
D by DX term and you'll get this
equation this is a wave
equation other term that we need to
worry about in this is the diffusion
term so let's look at that also
separately okay so if you look that also
separately so how will that look
like
okay so we'll have d by DT is equal to
new Delta U by D x² I'm ignoring the
convection term so first we consider the
convection term and then we considering
the diffusion term okay what kind of
equation this is
so this is an parabolic equation so this
is parabolic in
time and elliptic in
space right so we'll look at also this
equation separately okay and we'll see
what role this new plays in solving
these equations okay and once we have uh
done that so this is linear convection
equation this is called the diffusion
equation
okay so once we are done with the uh
testing our schemes for the conviction
diffusion then we'll go something called
convection diffusion
equation simple convection diffusion
equation okay so what will that have so
first we'll have the linear part which
is d by DT plus c d by DX is equal to
new Del to U by Del
x² you can see that slowly you are going
towards our n equations that you want to
solve all right so this is linear
convection defusion equation and then
we'll go to nonlinear contion def
equation okay nonlinear CD equation
that's
also called as the bers
equation
okay so that equation will look like d
by DT plus u d by DX equal to new Del to
U by D
x² so once we are good then we see that
our numerical schemes and our discing
schemes are working fine with all these
different kind of equations we will have
confidence that now we are ready to
tackle the uh the full num equations
first in 1D then 2D and 3D okay but
there is a lot of things that we need to
learn and find out that uh it's not only
the accuracy but the stability of the
scheme okay some schemes will be stable
for certain uh problem some schemes may
not be stable and even if it is stable
whether it is conditionally stable that
means it is stable under certain
constants like The Limited delt T value
or Delta x value uh or the value of the
convection speed or it is
unconditionally stable in the sense that
regardless of what is the value of
you're using uh it is going to give you
a solution okay then lastly you have to
worry about the convergence whether the
solution is converging or not whether
the errors that you have in the
beginning because any problem that we
will start we'll have certain initial
condition okay and then finally it has
to go to the uh solution that we desire
so how f it is going to the solution
right is there any uh thing that is
stopping uh it to go to towards that
solution okay so those are the things
that we need to worry
about okay so let's start one by one so
first we'll start with the convection
equation
okay so uh this is the linear convection
equation that we have been discussing uh
remember C is a constant it's a constant
wave speed okay and if you discretize it
okay so d by DT use a forward differing
okay so this will be u n + 1 - u n by
delta T right so the we are discussing
everyting in 1D today okay so this is
your X and this is your t okay so you
have discretized it
everywhere so let's say this is I I + 1
i- one okay I + 2 i - 2 and this is n
and then you go to n +
1 okay and maybe uh one here and then it
goes to next step and then you go to
Next
Step okay so everything is known at uh
this n okay which is let's say n equal
to 1 so everything is known so you know
what is UI at one everywhere
okay so this is UI at n equal to 1 so I
will use consistently for the subscript
denotes the spal discreation and super
script denotes the temporal discreation
if it is 2D it will become let's say u i
comma J N
okay so here if you write it at uh I
this will become u i n and uh n+ 1 minus
y by delta T right and what is the order
of accuracy similar to what how we did
in
the one-sided formulation scheme okay
for the spatial that there we it was the
first order scheme similarly the order
of this will be delta
T right this is in
time and D by DX okay so you can use the
forward differencing backward
differencing Center differing whatever
you want but you'll see that depending
on what scheme you use our Solutions
uh maybe correct incorrect or Sol blow
up also okay so if you do it at I that
will
become uh youu I'm using this so This
have used the forward in time okay ft
forward defensing time and backward
difference in space okay BS okay this is
scheme is called ft BS forward in time
backward in space okay this u i n ui-
one n by Delta f X okay and this will
become order of Delta X right so if you
write approximate uh this equation d u
by
dt+ c d by DX this will become u i n + 1
- u i n by Delta t+
c u i n minus u i -1 n by Delta X Plus
order delta T Delta X this is your uh
order of accuracy so it is first order
in time and first order in space
right so you can approximate it and this
this is the equation that will become
because the value is zero on the right
hand side okay uh and you can rearrange
it here so if you put this equal to zero
okay approximation
so that will become
zero and then you can write it you can
rearrange it so this will become u i n
Plus
one uh will be u i n and then you take
on the right hand side so that will
become negative minus C delta T by Del X
okay u i n - u i -1
n okay so why I uh wrote in uh this form
okay uh because you want to go to the n
+ one so right hand side everything is
at n so you know the value at n and n uh
you have discretize your function uh at
time n at every Point okay I equal to 1
2 I equal to capital N okay and you want
to see what happens to
n+1 right and how do you go to n+1 so
this n+1 the distance is delta T okay we
are going step by step you might want to
go to a maximum time let's say TX may be
very different T Max maybe let's say 100
seconds but delta T may very very small
it may be 0.01 second okay because uh we
will see okay why we cannot jump so big
so here very very important thing that
you will note is this number this is
called Quant number c delta T by delx
okay and we'll write this number uh
using special symbol which is Lambda
okay minus Lambda u i nus UI -1
n okay
and this number has got uh very big
significance in
cfd uh so regardless of what kind of
problem you're solving using rans
approach Lees DNS whatever problem is
solving you need to always take care of
this number which is the Quant number
it's also called the CFL
number I mean very crudely if you see
what it represents so C delta T So C is
the convection speed and delta T is your
time so this unit will be meter per
second into second some meter okay and
Delta X is basically your grid distance
that also is meter so basically it says
that how much uh uh the information is
traveling okay uh with your convection
speed okay and whether that distance
that is traveling so the distance is
traveling is C delta T right for a given
delta T at a convection C right and
Delta X is basically your grid distance
so let's say this is your Delta
X okay and your C delta T would be let's
say I say that my C delta T is
this so if the C delta T is greater than
Delta X that means your information has
basically jumped over the grid okay so
it is not smaller than your grid size so
you can see that the information
propagation is not proper in this
particular case so that's why the
solution will blow up in most cases okay
unless we
uh we go to the implicit scheme which I
will introduce later okay but typically
if you are just using a explicit
approach like we are doing here okay and
uh we see that my C delta T is greater
than Delta X then uh the information
propagation is not proper okay we you
are jumping over the the grids and the
solution will likely to be plow up okay
so let's uh try solving this equation so
you can uh basically write a very simple
code okay uh so before we solve we need
some initial condition and some bonding
condition okay that is for whether
you're solving analytically or
numerically those information is
required so in this particular case we
start with a very simple uh jump
condition okay or you can say that this
is a square wave okay so my initial
condition is U = to 2 okay between 0 5.5
to 1 okay so the blue l line here uh
basically shows your initial condition
so it is one everywhere okay and then it
is two between .5 and one okay so this
is my initial
condition and I want to see the
propagation of this wave okay due to the
linear convection okay that is our
purpose so if we have a linear
convection equation d by t + C D by DX
equal to
Z and our initial condition is given
okay u x comma 0 is basically our Square
wave which is uh basically it's two uh
if it is 0.5 to 1 or it is one okay for
all
other so this is my initial condition so
this is the wave that we want to study
what happens to this wave as it conver
okay under the constant convection speed
of C we also need to set up the bond
condition because you as you have
discussed that at this end and this
end okay we need the bonding condition
you can use a periodic bonding condition
for example where it is basically
circulating or in uh here what you're
doing you're using this value as one
okay so it goes there and it becomes uh
because it starts from one and goes to
two so we will propagate in a way that
our total distance of the convection is
lesser than this distance okay else we
have to use a periodic bonding condition
what periodic does is basically if let's
say the wave forms like this and then it
will start the same thing same distance
from there okay so that is a periodic
Point condition we'll have discussion on
periodic points uh
later okay so let's say if I set that my
convection speed as c equal
to.5 right my convection to my wave is
convecting at the speed of 0.5 and we
want to see what happens as 0.5 second
okay this is let's say meter per second
and this is5 second so what will happen
our convection speed is positive C is a
positive number so this W will travel on
the right side right and what is the
distance that will travel that will
become CT so this is05 into .5 that is
basically
0.25 right so it will travel 25
distance okay which is what you're
seeing and your final condition would be
basically going from here to here and
you can see that it maintains the shape
there is no change in the shape so this
is at final time T = to.5 second and
this is
your T = to 0 second okay in the
beginning right uh so there is no
diffusion here the reason that it
maintains the shape okay so this
basically it'll be overlapping
here so it maintains the shape uh so I
have shown you the initial condition and
the final condition let's see how what
are the intermediate conditions and what
are the schemes that you're using what
are the parameters that you're using for
the solution so you can actually go back
and quickly write a simple matlb code
okay for example this what you see here
is uh this is my initial condition we
have defined our wave and this is the
same expression this is a pseudo code
for solving this equation right this is
u n Okay C delta T by DX and DT and DX
you can fix so uh let's say you know
what is your x max
okay let's say you take the x max as two
so your problem is like
this this is zero 0.5 1 and 2 so your x
max is 2 and your T Max let's say you
want to go to up to.5 second right so
this is your let's say 2 m.5 second and
you can fix your convection speed let's
say you fix the convection 0.5
m/s right so you want to see that under
the uh linear convection what is
happening this for different parameters
of for example you can change your delta
T which is DT here you can change your
Delta X okay and you can see how the
things are changing you can also change
your convection speed and see what is
happening so this is a simple pseudo
code you can go back and write and as
you can see here this is a backward
defening I'm doing I minus IUS one okay
this is very simple code to write okay
please go back and write it and I'm
showing you some solution okay so here
here you can see I've taken this
convection speed as 0.5 uh your grid
size is
0.002 okay DX and your time is
0.33 so uh your uh time disc delta T is
much smaller than the Delta X and if you
calculate the Lambda which will
basically C delta T by Delta X so the
value comes to be around
825
okay and I'm using this forward in time
and backward in space scheme that we
have discussed and this is how the
solution behaves the so this curve that
you see this one is your time equal to Z
right and because we are using a very
small time step remember the delta T is
0.33 so I'm plotting it every like 50
time steps
okay no so every 30 so this is dtal to
0.33 and multiply by 30 that will give
you
0.1 okay so I'm not jump uh this is not
like every time step but every 30 time
step I'm showing the plot right you can
see that uh and the grid size as you can
see it's very very fine your this is 0.2
so if your x max is equal to
2 so I'm using NX = to
1000001 right it's a very fine grid okay
so uh you can see that now it is
propagating and there are certain
effects that you can see okay if you
look at very closely so you had very
sharp corner here okay in the beginning
but as it went on the right you can see
that the Shar P has slightly become more
diffused right so despite having no
diffusion in the scheme so there's no
new term okay there's no new Delta by
delx square term still you have having
some uh diffusion you can see at these
Corners
also that means our scheme itself has
got some certain diffusion okay that is
what is called the diffusion okay and we
have to basically estimate what is the
numerical diffusion in your equation
that's a very very important parameter
especially if you are going for a high
high equ simulation okay let's say Al
and DNS if you're using a very
dissipative scheme very diffusing with
scheme then it's likely that you will
not get the the very accurate solution
okay the things will be very very
diffused especially let's say if you
have socks or something then what will
happen that you'll have a very uh
diffused sock okay instead of a Sharp
discontinuity you have the discontinuity
over a very uh long distance right so
which you don't
want okay so this is how the solution
will look like okay now let's change
some parameters okay and we what we do
we basically make the M very Co okay so
we have x max equal
to uh 2 so we take NX is equal to I
think uh 51 okay only 51 grid points
okay
so uh then if you do that okay uh you
will
see that now also it is marching on the
right okay this is your t equal to0 this
is your tal to
.1
23 4 and. 5
right but you can see that uh you have
it does not maintain that sharp shape
that you have you would expect that your
solution would look like something like
this like we saw in the earlier slide
okay there's no diffusion so it should
basically maintain the shape like this
but you can see that it is getting
highly diffused as you basically uh
decrease the grid size you can see that
the
sharp uh Corners are gone completely
okay it it is no longer looking like a
square wave but it is rather looking
like a sign Wave It's a continuous
function right so why did it happen
because we used a very Co mess okay
remember this Lambda which is the Quran
number is still very very small
okay so uh the course mes gives you uh
the solution uh which is very very
diffused and that is why the GD
Independence test is necessary that
means your grid is not your solution is
not changing as you refine the grid okay
if you get a course mess it's likely
that you'll get a solution the solution
may converge also but it will not be
accurate okay that's the learning from
this part
what is happening here so here what we
have done we have uh basically increased
the convection speed so now my C is
equal to 1 and kept my DX and DT as it
was uh in the earlier slide
okay this slide okay so it was 825 that
time the Lambda was 825 now we just uh
double the convection speed so my Lambda
has become 2 into that value okay
whatever it was so now it has become
1.65 so my Quant number exceeded 1 that
means my C delta T is now greater than
Delta X I'm jumping over the Cs right
when we did that you can see quickly
that our solution blew up okay it is uh
so you you can see these lines basically
it is going towards Infinity it is very
very large value okay and since I've
used the limit in the X and Y Direction
you do not see it here but it is all
everywhere okay and uh the uh the thing
that you desire that is going to convect
on the right side that is not
happening okay uh so if you are
increasing your convection speed you
have to accordingly uh reduce your delta
T so that your C delta T is smaller than
Delta X and that is that is what we have
done here so earlier my delta T was
033 okay we have reduced it to 02 and it
is just equal to 1 okay and then you can
see that uh we are getting the solution
at this is at different times okay and
this is zero and this is marching
towards one so this uh wave that you see
basically this is your initial
solution okay this is initial solution
and then it is marching towards the
right
okay at the convection speed which is
equal to one here let's do some more
experiment here what we did we Chang the
scheme okay so we change it from Ft BS
to ftcs so forward in time and Center in
space that means your equation become
Del DT plus c d by D X = to 0 and this
is u n + 1 - u n by Delta t+ c u i + 1 N
- u i - 1 n
by Delta X
okay and what is the order of accuracy
of this this is delta T and Delta x
square remember this is a central
defensing scheme we approximating it by
Central defens scheme which is the
second order accurate so you expect that
your solution will become better because
this is a second order scheme right this
is equal to zero okay you can ignore
this part so this is what we are solving
and if you rewrite it this will become u
n + 1 will become U y n minus C delta T
by Delta
x 2 Delta X actually okay this will be 2
Delta x u i + 1 N - u i - 1 n and you
know the value of at n everywhere and
you just do that and you solve this you
can see that you have got lot of
oscillations near the discontinuity here
both on the left side and the right hand
side okay so despite being more accurate
uh this scheme the central scheme is not
stable right and why it is happening you
can think of a very physical reason
okay so let's say so this is your grid
and your convection is happening on the
uh convection is positive so information
is happening from both left and right
okay so this direction is called your up
wind from where the information is
coming let's say you are at this place
okay you are at this
place okay and uh the right one is
called the
downwind okay so when you want to
calculate your gradient you are taking
the information from both this is I this
is I + 1 and this is IUS one so you're
taking the information from both the
sides okay but your wave is traveling
from the left side okay so you don't
have the information on the right side
but you're still taking the information
from the right side to calculate a
gradient and that is why it basically
blows up okay this is ftcs this is not c
equal to5 only okay
okay so that it blows up because you
taking the information from the down end
also where not traveled yet this is
basically Cal to -.5 and but you're
using this ftps only forward in time
backward in space like we have been
using earlier for cqal 2.5 and you can
see that still the solution is blowing
okay this is ftps not the centrally
finishing this is the backward in space
why it is blowing the reason for that is
now the C is negative so your
information is tabling from right to
left okay so when it is traving from
right to left this is your up
wind and this is a
downwind so you need to basically uh
take the information uh which is on this
direction okay so earlier we are using
so in ftvs what do you do you do d by DX
is equal to
UI UI minus u i -1 by Delta X so if this
is my I this is my I -1 and this is my I
+ 1 right so you were taking the
information in this direction right you
are taking using making use of IUS one
and I so if you're changing the
convection speed the information tble
from right to left you have to still OB
the opend so in that case you have to
use this
ftfs that means the forward uh uh in
space so that will become UI + 1 minus
UI by Delta X so this is your this is
your ft BS and this is your
ftfs why you have to do that because we
have to honor the winding okay the the
direction of the travel of your
convection okay so once you do that so
we just change that negative convection
is speed but we using this ftfs forward
in time and forward in space and you can
see that now it is traveling on the left
side okay so this is your zero solution
okay and then it is troubling on the
left side because the convection speed
is negative so to honor the negative
contion speed we had to change our
scheme so what we learned here is
basically uh
our solution but basically whether
you're are getting the correct solution
or not depends on the choice of your
scheme depends on your the parameters
that you choose uh your grid size your
time step size and uh uh whether that
will be stable or not that will be
determined by another parameter which is
the Quant number you will see that as
you go to the implicit schemes uh the
Quant number uh may not be very
important because uh uh you can uh
basically use a very high Quant number
in that so there are other consideration
that we need to think about okay so in
the next class we'll discuss about the
the diffusion equation and the
conviction diffusion equation okay thank
you very much
[Music]
[Music]
[Music]
