Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: PDEPE boundary conditions ul equals ur Date: Wed, 12 Feb 2014 07:40:12 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 76 Message-ID: <ldf8gs$670$1@newscl01ah.mathworks.com> References: <ld2jgp$mc3$1@newscl01ah.mathworks.com> <lda5ge$d2i$1@newscl01ah.mathworks.com> <ldac66$hmn$1@newscl01ah.mathworks.com> <ldae5v$n3l$1@newscl01ah.mathworks.com> <ldatuc$68u$1@newscl01ah.mathworks.com> <ldcj6o$8e$1@newscl01ah.mathworks.com> <lddhlo$ono$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: rubyext-04-ls.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1392190812 6368 172.20.102.180 (12 Feb 2014 07:40:12 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Wed, 12 Feb 2014 07:40:12 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 3799640 Xref: news.mathworks.com comp.soft-sys.matlab:809127 "Tran Trung Luu" wrote in message <lddhlo$ono$1@newscl01ah.mathworks.com>... > "Torsten" wrote in message <ldcj6o$8e$1@newscl01ah.mathworks.com>... > > "Tran Trung Luu" wrote in message <ldatuc$68u$1@newscl01ah.mathworks.com>... > > > "Torsten" wrote in message <ldae5v$n3l$1@newscl01ah.mathworks.com>... > > > > "Tran Trung Luu" wrote in message <ldac66$hmn$1@newscl01ah.mathworks.com>... > > > > > > Why do you want to solve the equation numerically ? > > > > > > If A is constant, the analytical solution is pretty clear. > > > > > > > > > > > > Best wishes > > > > > > Torsten. > > > > > > > > > > Thank you Torsten for your message. > > > > > > > > > > Yes, you are right. However, for simplicity I did not put it clearly. Actually A is A(t) but this A(t) is numerically defined along all t thus I would not call it a function, I call it a constant. > > > > > > > > > > Since the boundary is not set right thus if there is no solution for this with pdepe, I am thinking of writing my own solver to solve this particular problem because I will have more control than pdepe. In that case, I am considering Crank Nilcoson's algorithm. Could you please comment on this or advise me what should be the best way? > > > > > > > > > > Thanks a lot and have a nice day, > > > > > Trung > > > > > > > > > > PS: I tried to use the ode45 for t plus finite difference method to do derivative in x. But the results seem to contain a lot of numerical errors so I am not satisfied. > > > > > > > > Even if A=A(t), I'd not solve the original PDE. > > > > Make your initial condition u0(x) periodic over the real line with period (xr-xl). > > > > Calculate the quantity > > > > integral_{t'=0}^{t'=t} A(t') dt'. > > > > If I'm not mistaken, the solution of your problem is then given by > > > > u(x,t) = u0(x-integral_{t'=0}^{t'=t} A(t') dt') > > > > > > > > Best wishes > > > > Torsten. > > > > > > Dear Torsten, > > > Actually our problem is more complicated than this thus I tried to simplify it just to get the main point of the boundary. > > > Nevertheless, I implemented your analytical solution and it works perfectly. I compared the solution from pdepe and this analytical one and they are almost identical. Many thanks for this. I should have look more carefully to see if we can get an analytical solution first, even for this particular case. > > > Regarding the boundary, I would like to see how the boudaries behave when u(x,t) reaching them with the conditions we have. What is clear in the analytical solution you suggested is that u(x,t) will just go out and be missing. This is also confirmed in the pdepe results. > > > I guess that this is what it is. > > > Thank you again Torsten, I will look further into details. At the moment, things are good. > > > > > > Best wishes, > > > Trung > > > > Your pde just moves the initial function u0 (periodically continued) to the left and to the right on the x-axis with "velocity" A(t). That's why the analytical solution is just a translation of the initial profile on the x-axis. > > > > Best wishes > > Torsten. > > Dear Torsten, > > Thanks a lot for your great help. > However, I am still interested in implementing the boundary conditions here (to make ul == ur at all time t). If you could please suggest any idea so that I can give it a try, that would be nice. > > Have a nice day, > Trung pdepe is not suited to solve your partial differential equation (PDE) - not only because you want to impose periodic boundary condition. The main reason is that pdepe is suited to solve parabolic/elliptic PDEs (roughly speaking, PDEs with a second order derivative) - your PDE is hyperbolic in nature. So you will have to discretize your PDE and solve the resulting system of ODEs by ODE45, e.g.. Start with a first-order discretization scheme. It introduces much artificial diffusion, but second-order schemes are quite compliciated. So for the PDE du/dt = A(t)*du/dx, with periodic boundary condition, a discretization would be for the case A(t) > 0: du_(i)/dt = A(t)*(u_(i+1)-u_(i))/(x_(i+1)-x_(i)) (1<=i<=n-1) du_(n)/dt =A(t)*(u_(2)-u_(n))/(x_(2)-x_(1)) and for the case A(t) < 0: du_(1)/dt = A(t)*(u_(n-1)-u_(1))/(x_(n)-x_(n-1)) du_(i)/dt = A(t)*(u_(i)-u_(i-1))/(x_(i)-x_(i-1)) (2<=i<=n) where xl=x1<x2<...<xn=xr is a grid on the interval [xl,xr]. But try to stick to the analytical solution (in which I found a little error, by the way: the correct solution is given by u(x,t) = u0(x + integral_{t'=0}^{t'=t} A(t') dt') where u0 is the initial condition periodically continued over the real line). Best wishes Torsten.