Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using PDE Toolbox to solve 2D advection equation

679 views
Skip to first unread message

Nanna

unread,
Mar 13, 2013, 6:54:06 AM3/13/13
to
Hi all,
I've been looking into the PDE Toolbox for teaching purposes. I've trawled through the Matlab Newsgroup but haven't been able to find a clear answer to this:
I'm trying to find a simple way to use the toolbox to solve the advection equation in 2D:
dT/dt=u*dT/dx+v*dT/dy
where u and v are the (x,y)-components of a velocity field. There is no diffusion in the system so it's a first order problem. I have my own solution using finite differences, but I would really like to use the PDE Toolbox for comparison because of the finite element approach. All the examples I have found have been second order PDEs - does any one have a suggestion how to proceed? Preferably in a way that is suitable for demonstration to 2nd year physics students.
Best,
Nanna

Alan_Weiss

unread,
Mar 13, 2013, 8:04:48 AM3/13/13
to
I don't know how to map your problem into the form required by PDE Toolbox:
http://www.mathworks.com/help/pde/ug/types-of-pde-problems-you-can-solve.html

Sorry.

Alan Weiss
MATLAB mathematical toolbox documentation

Nanna

unread,
Mar 13, 2013, 9:08:06 AM3/13/13
to
Hi Alan,
That was the conclusion I reached too. I just thought that I might have overlooked something since the linear advection equation is a lot simpler than most of the other functions the toolbox can handle.
Thanks anyway.

Torsten

unread,
Mar 13, 2013, 9:18:06 AM3/13/13
to
"Nanna" wrote in message <khplse$pcj$1...@newscl01ah.mathworks.com>...
AFAIK, there is no MATLAB tool to solve this kind of PDE.

Use CLAWPACK available under
http://depts.washington.edu/clawpack/
It is especially designed to solve hyperbolic PDEs in one, two and three space dimensions.

Or, if u and v are constant and the boundary conditions are simple,
it might even be possible to get an analytic solution for your problem above.

Best wishes
Torsten.

Bill Greene

unread,
Mar 13, 2013, 11:56:09 AM3/13/13
to
"Nanna" wrote in message <khplse$pcj$1...@newscl01ah.mathworks.com>...
Hi,

Yes, as others have pointed out, the algorithms in PDE Toolbox are not designed
to solve this type of hyperbolic equation in the most general case. That doesn't
mean, though, that it can't solve it for some interesting cases!

I assume that u and v in your equation are a prescribed velocity field?
To get this into a form that is acceptable to PDE Toolbox, you would
write the RHS term as
f = -xVelocity*ux - yVelocity*uy;
PDE Toolbox uses the variable names ux and uy to mean du/dx and du/dy.
I changed the names of your velocity field because "u" is also reserved in
PDE Toolbox to mean the dependent variable. You would also define
c=a=0 and d=1.

As you probably already know from your FD solution, you have to be careful
in how you set your boundary conditions. Typically, you would want to
set a Dirichlet condition on the "inflow" boundaries and a Neumann condition
on the "outflow" boundaries.

You can then solve the equation either in the pdetool GUI or by calling the
parabolic(...) function.

Finally, note that the capability to define the PDE coefficients in time-dependent
PDE in terms of ux and uy (or u) is available only in MATLAB R2012b and newer versions.

Regards,

Bill

Nanna

unread,
Mar 14, 2013, 12:01:13 PM3/14/13
to
Hi Torsten,
Thanks for your suggestion. At a glance the CLAWPACK looks a bit more complicated than what I'm aiming for but I'll have a closer look to see how easy it is to work with.
Cheers,
Nanna

"Torsten" wrote in message <khpuae$l5v$1...@newscl01ah.mathworks.com>...

Nanna

unread,
Mar 14, 2013, 12:06:07 PM3/14/13
to
Hi Bill,
Thanks for your message. Just to clarify: In order to get the advection equation into a form that the PDE Toolbox can work with I need to define f as
f=-(x_vel*ux+y_vel*uy)
(using your notation) and then solve the equation
u_t = f
I guess that might work. Thanks a lot - I'll give it a try!
Cheers,
Nanna

"Bill Greene" wrote in message <khq7ip$nue$1...@newscl01ah.mathworks.com>...

canz

unread,
Oct 21, 2016, 12:32:08 PM10/21/16
to
"Nanna" wrote in message <khplse$pcj$1...@newscl01ah.mathworks.com>...
I know this question is 3 years old, but I am searching for the same answer on the internet and couldn't find an answer. There's not much discussion on this matter either. I decided to put my comment here, and I hope people with a similar problem can find it useful.

There's a matlab document page on how to write your equation into matlab pde toolbox format.
https://www.mathworks.com/help/pde/ug/c-coefficient-for-systems-for-specifycoefficients.html
It is very helpful.

All you need to do is specify your problem in the divergence form. For your problem, you need a character array for 'c'
c = char('0', 'nu1*y-nu2*x', '-nu1*y+nu2*x', '0');
where nu1 is v in your notation, and nu2 is u in your notation.

Then use solvepde function to solve the problem.

FEATool Multiphysics and Matlab CFD Toolbox

unread,
Feb 25, 2017, 8:50:07 AM2/25/17
to
The FEATool Multiphysics toolbox allows you to set up and solve any general PDE based problem, including the advection equation. For your problem you would need to use the convection and diffusion physics mode and using a zero diffusion coefficient. Also you would need to use some form of artificial stabilization such as stremline diffusion which is also pre-defined.

Please visit https://www.featool.com/ for more information.
0 new messages