CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Periodic B.C for right moving square wave

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 30, 2015, 16:20
Default Periodic B.C for right moving square wave
  #1
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
I am solving a 1D Advection equation :

du/dt + c*du/dx = 0 ;

c is constant and greater than 0 ( i.e a right moving wave )



At time , t = 0 , i.e Initial condition is a square wave



I took ' c ' such that the wave completes one full revolution (loop) of the domain.


I used FOU for advcetion term and forward euler for time integration :

u_new(i,1) = u_old(i,1) - (c*del_t/del_x)*(u_old(i,1)- u_old(i-1,1))

where i : grid point

where del_t is obtained by CFL.




for periodic B.C , I do the following



for i=imax:-1:1 % imax is max. grid points

if i == 1

u_new(i,1) = u_new(imax,1); % periodic b.c

elseif i== 2

u_new(i,1) = u_old(i,1) - (c*del_t/del_x)*(u_old(i,1) -
u_old(imax,1)); % since u(1,1) = u(imax,1);

else
u_new(i,1) = u_old(i,1) - (c*del_t/del_x)*(u_old(i,1) - u_old(i-1,1));

end

end




so whenever i = 1 appears , I replace it with imax .


Is the implementation of PERIODIC B.C correct?

Thanks in advance

- Mihir
mihirmakwana6 is offline   Reply With Quote

Old   July 2, 2015, 10:17
Default
  #2
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Can someone please confirm if the periodic B.C is properly implemented?


Thanks in advance

- Mihir
mihirmakwana6 is offline   Reply With Quote

Old   July 2, 2015, 11:36
Default
  #3
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
assuming the periodicity is posed at nodes i=1 and i=N, for c>0 you do the cycle for i =2 to N computing unew(i) from the FTUS.
At the end, you simply set unew(1)=unew(N) ando go again in the time integration.
Nothing else to do...
FMDenaro is offline   Reply With Quote

Old   July 2, 2015, 11:52
Default
  #4
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
assuming the periodicity is posed at nodes i=1 and i=N, for c>0 you do the cycle for i =2 to N computing unew(i) from the FTUS.
At the end, you simply set unew(1)=unew(N) ando go again in the time integration.
Nothing else to do...
thankyou for the reply.

for the FOU scheme

Sir, if you consider the equation for i = 2 , it will have a term u_old(1,1) .

so are you saying that I should NOT change it to u_old(N,1)
mihirmakwana6 is offline   Reply With Quote

Old   July 2, 2015, 11:58
Default
  #5
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by mihirmakwana6 View Post
thankyou for the reply.

for the FOU scheme

Sir, if you consider the equation for i = 2 , it will have a term u_old(1,1) .

so are you saying that I should NOT change it to u_old(N,1)

a t=0 uold MUST be known for any i as it corresponds to an initial condition for the Cauchy problem...
FMDenaro is offline   Reply With Quote

Old   July 2, 2015, 12:02
Default
  #6
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
a t=0 uold MUST be known for any i as it corresponds to an initial condition for the Cauchy problem...
sir, I have defined uold @ t = 0 for every i

I just wanted to ask that since we have the periodic condition
u(1) = u(N)

so is it required to change uold(1) to uold(N) in the equation for 2nd grid point
mihirmakwana6 is offline   Reply With Quote

Old   July 2, 2015, 12:06
Default
  #7
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by mihirmakwana6 View Post
sir, I have defined uold @ t = 0 for every i

I just wanted to ask that since we have the periodic condition
u(1) = u(N)

so is it required to change uold(1) to uold(N) in the equation for 2nd grid point


here an example of coding

uold(1:N) = initial condition f(x,0)
For t= ... to ...
for i=2 to N
unew(i)= .... FTUS ...
end
unew(1)=unew(N)
uold(1:N)=unew(1:N)
end
FMDenaro is offline   Reply With Quote

Old   July 2, 2015, 12:23
Default
  #8
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
here an example of coding

uold(1:N) = initial condition f(x,0)
For t= ... to ...
for i=2 to N
unew(i)= .... FTUS ...
end
unew(1)=unew(N)
uold(1:N)=unew(1:N)
end
1) sir, I did the same thing as yours. But I thought that since b.c are periodic hence I need to change the equation for i = 2 using an if statement

uold(1:N) = initial condition f(x,0)
For t= ... to ...
for i=2 to N
if i==2
unew(i) = uold(2)-(c*dt/dx)*(uold(2)-uold(N))
else
unew(i) = uold(i)-(c*dt/dx)*(uold(i)-uold(i-1))
end
end
unew(1)=unew(N)
uold(1:N)=unew(1:N)
end

I did this way and I find slight variation in the profile as compared to what you suggested

2) if I use FTCS ( i.e CDS scheme)

that for i = N , I get

unew(N) = uold(N)-(c*dt/dx/2)*(uold(N+1)-uold(N-1))

now , I don't have the point N+1 on the grid ... so what to do
mihirmakwana6 is offline   Reply With Quote

Old   July 2, 2015, 12:36
Default
  #9
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
you don't need any IF ....

periodicity is a BC.s, not an initial condition, therefore you have f(1)=f(N) but also f(2)=f(N+1), f(3)=f(N+2) and so on
FMDenaro is offline   Reply With Quote

Old   July 3, 2015, 12:41
Default
  #10
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
you don't need any IF ....

periodicity is a BC.s, not an initial condition, therefore you have f(1)=f(N) but also f(2)=f(N+1), f(3)=f(N+2) and so on
ok.

I am getting the results for FOU and CDS

Sir, now I am trying to implement MUSCL scheme

I used the equation (4.20) with minmod slope limiter given by equation (4.28) & (4.29)
from the following link

http://www.mpia.de/homes/dullemon/le...vection_II.pdf


Is the formula correct
mihirmakwana6 is offline   Reply With Quote

Old   July 3, 2015, 12:43
Default
  #11
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
FTCS is unconditionally unstable on the linear advection equation......
FMDenaro is offline   Reply With Quote

Old   July 3, 2015, 12:51
Default
  #12
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
FTCS is unconditionally unstable on the linear advection equation......
Sir, yes .

Ideally the wave should just get advected without any change in the shape , however that does not happen with CDS ( FTCS ) and FOU ( FTUS ) .

CDS scheme is unstable , and results in oscillations.
FOU scheme does give the solution but the square waves gets smooth as it gets advected

I just compared the trend of my solutions with that given on the site
https://en.wikipedia.org/wiki/MUSCL_scheme

So, now I am trying to use MUSCL scheme as it can handle the jump as in the square wave.

I reffered to the site

http://www.mpia.de/homes/dullemon/le...vection_II.pdf

I used the equation (4.20) with minmod slope limiter given by equation (4.28) & (4.29)

So are these equations correct?
mihirmakwana6 is offline   Reply With Quote

Old   July 3, 2015, 12:55
Default
  #13
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Check the FTUS, it must provide the exact solution at courant number=1.

MUSCL is quite good but you can find some more accurate method in the book of LeVeque on FV for hyperbolic equations
FMDenaro is offline   Reply With Quote

Old   July 3, 2015, 13:13
Default
  #14
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
Check the FTUS, it must provide the exact solution at courant number=1.

MUSCL is quite good but you can find some more accurate method in the book of LeVeque on FV for hyperbolic equations
I substituted courant number=1 for FTUS and yes it gives exact solution.

Sir I actually want to implement MUSCL and the book by leveque does not give much insight into it.

So, I referred the site mentioned above. Just wanted to jnow whether the eqautions are right or not.
mihirmakwana6 is offline   Reply With Quote

Old   July 3, 2015, 13:23
Default
  #15
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
have also a look here

http://weberknecht.uni-muenster.de/n...vol_script.pdf
FMDenaro is offline   Reply With Quote

Old   July 3, 2015, 13:28
Default
  #16
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
ok. thankyou for the help.
mihirmakwana6 is offline   Reply With Quote

Old   January 6, 2016, 09:53
Default
  #17
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
here an example of coding

uold(1:N) = initial condition f(x,0)
For t= ... to ...
for i=2 to N
unew(i)= .... FTUS ...
end
unew(1)=unew(N)
uold(1:N)=unew(1:N)
end
sir, say you have 5 cells in 1D with 5 points at the cell centres.

They are named as 1,2,3,4,5

i.e i am using FINITE VOLUME method

then, does the above coding example hold true for periodic B.C. i.e solving from i = 2 to i = 5 and then at the end saying that

unew(1)=unew(5)
mihirmakwana6 is offline   Reply With Quote

Old   January 6, 2016, 12:51
Default
  #18
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by mihirmakwana6 View Post
sir, say you have 5 cells in 1D with 5 points at the cell centres.

They are named as 1,2,3,4,5

i.e i am using FINITE VOLUME method

then, does the above coding example hold true for periodic B.C. i.e solving from i = 2 to i = 5 and then at the end saying that

unew(1)=unew(5)

yes, you can use such setting in general and if you have higher order schemes that use more nodes you can set unew(0)=unew(N-1) and so on
FMDenaro is offline   Reply With Quote

Old   January 6, 2016, 13:32
Default
  #19
Member
 
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11
mihirmakwana6 is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
yes, you can use such setting in general and if you have higher order schemes that use more nodes you can set unew(0)=unew(N-1) and so on
Sir, so say now i have 20 grid points i = 1 to 20 ( & thus 20 C.V ) ..

Now say i use fifth order upwind scheme for node 20 ( last node ).
if the flow is from right to left then i will need 3 nodes upstream (this depends on the upwind scheme) of the node 20.
then can i say that

u(21) = u(2)
u(22) = u(3)
u(23) = u(4)

similarly for node 2 with flow from left to right the 3 upstream nodes will be

u(1) --- i know its value
u(0) = u(19)
u(-1) = u(18)


is this correct ???
mihirmakwana6 is offline   Reply With Quote

Old   January 6, 2016, 16:50
Default
  #20
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by mihirmakwana6 View Post
Sir, so say now i have 20 grid points i = 1 to 20 ( & thus 20 C.V ) ..

Now say i use fifth order upwind scheme for node 20 ( last node ).
if the flow is from right to left then i will need 3 nodes upstream (this depends on the upwind scheme) of the node 20.
then can i say that

u(21) = u(2)
u(22) = u(3)
u(23) = u(4)

similarly for node 2 with flow from left to right the 3 upstream nodes will be

u(1) --- i know its value
u(0) = u(19)
u(-1) = u(18)


is this correct ???

yes, correct
FMDenaro is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linear wave force on a cylinder Pumbam CFX 1 July 16, 2017 03:01
problem about a periodic moving wall itsqi7 FLUENT 6 January 31, 2013 16:54
proper boundary condition for making a moving shock wave immortality OpenFOAM Running, Solving & CFD 0 December 8, 2012 15:36
[Other] How to set up a dynamic mesh for a piston moving through a tube of variable diameter? karkar OpenFOAM Meshing & Mesh Conversion 0 July 4, 2012 07:54
Moving mesh, change the B.C Gilsub FLUENT 0 June 28, 2004 22:21


All times are GMT -4. The time now is 08:12.