|
[Sponsors] |
June 30, 2015, 16:20 |
Periodic B.C for right moving square wave
|
#1 |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
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 |
|
July 2, 2015, 10:17 |
|
#2 |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Can someone please confirm if the periodic B.C is properly implemented?
Thanks in advance - Mihir |
|
July 2, 2015, 11:36 |
|
#3 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
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... |
|
July 2, 2015, 11:52 |
|
#4 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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) |
||
July 2, 2015, 11:58 |
|
#5 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
Quote:
a t=0 uold MUST be known for any i as it corresponds to an initial condition for the Cauchy problem... |
||
July 2, 2015, 12:02 |
|
#6 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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 |
||
July 2, 2015, 12:06 |
|
#7 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
Quote:
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 |
||
July 2, 2015, 12:23 |
|
#8 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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 |
||
July 2, 2015, 12:36 |
|
#9 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
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 |
|
July 3, 2015, 12:41 |
|
#10 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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 |
||
July 3, 2015, 12:43 |
|
#11 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
FTCS is unconditionally unstable on the linear advection equation......
|
|
July 3, 2015, 12:51 |
|
#12 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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? |
||
July 3, 2015, 12:55 |
|
#13 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
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 |
|
July 3, 2015, 13:13 |
|
#14 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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. |
||
July 3, 2015, 13:23 |
|
#15 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
||
July 3, 2015, 13:28 |
|
#16 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
|
||
January 6, 2016, 09:53 |
|
#17 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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) |
||
January 6, 2016, 12:51 |
|
#18 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
Quote:
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 |
||
January 6, 2016, 13:32 |
|
#19 | |
Member
Mihir Makwana
Join Date: May 2015
Posts: 79
Rep Power: 11 |
Quote:
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 ??? |
||
January 6, 2016, 16:50 |
|
#20 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
Quote:
yes, correct |
||
|
|
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 |