# How to solve my PDE's in Matlab?

I need to solve a set of 5 PDEs for functions $u(x,t)$.

I looked up the Matlab function pdepe. It looked perfect for my case, until I read the line:

$f(x,t,u,\partial u/\partial x)$ is a flux term and $s(x,t,u,\partial u/\partial x)$ is a source term. The flux term must depend on $\partial u/\partial x$.

In my problem for 4/5 of my equations $f(x,t,u,\partial u/\partial x)$ doesn't depend on $\partial u/\partial x$, and in 1/5 of my equations $f(x,t,u,\partial u/\partial x)=0$. In my equations, there's no second derivative of $u$ with respect to $x$.

• Does this mean i can't use pdepe in order to obtain a solution for my problem?

Oddly enough, in the link for the pdepe function, that line I mentioned before:

...The flux term must depend on $\partial u/\partial x$.

does not appear there. also, I would expect that since having $f(x,t,u,\partial u/\partial x)$ that does not depend on $\partial u/\partial x$ is just a special case, it wouldn't in any way prevent me from obtaining a solution.

• So all in all, I want to know if I can use pdepe even if $f(x,t,u,\partial u/\partial x)$ does not depend on $\partial u/\partial x$?
• If not, what would happen if I try to solve it anyways? and what other method I can use to solve my set of PDEs?

My equations look like this:

Let us use the form of matlab:

c(x,t,u,∂u/∂x)∂u/∂t=(x^−m)*∂/∂x((x^m)*f(x,t,u,∂u/∂x))+s(x,t,u,∂u/∂x).

(u is a vector with 5 components, as I have 5 equations)

I have m=0 in all of my equations.

eq. 1: c=1, f=0, s=A(u)

eq. 2: c=1, f=-u(2).*B(u(4)), s=C(u)

eq. 3: c=1, f=-u(3).*B(u(5)), s=C(u)

eq. 4: c=1./B(u(4)), f=-u(4), s=D(u)

eq. 5: c=1./B(u(5)), f=-u(5), s=E(u)


Where A,B,C,D,E are some functions of u=[u(1);u(2);u(3);u(4);u(5)] but not of x,t,du/dx

it's important to note that for a 1st order ODE it can always be chosen that f=0, so that all of the terms can go into s (and in that case, obviously f does not depend on du/dx). here i just chose a convinient way to represent my equations.

• If you can't get that Matlab function working, you can always solve the PDEs doing a simple finite difference based algorithm (if you're working on simple domains) You'd have to work out the math and algorithms for your particular PDEs, though. – spektr Mar 14 '16 at 18:23
• i didn't actually try getting it working yet, because i didn't wanna write the whole code knowing in advance it might not work after seeing that dreadful line "The flux term must depend on ∂u/∂x.". i came here to find out if any1 knows if it might still work if f(x,t,u,∂u/∂x) does not depend on ∂u/∂x. also, is there any other function like pdepe in matlab that is designed to solve pdes? – TensoR Mar 14 '16 at 18:45
• What is your PDE system? – nicoguaro Mar 14 '16 at 18:52
• i really don't wanna write a code from scratch that solves the pde's. (by the way how do i put line spaces on these sub comments?) – TensoR Mar 14 '16 at 18:53
• i've added the form of my equations to my initial post. – TensoR Mar 14 '16 at 19:03

The short answer is that the pdepe function does not strictly require that the flux term be a function of $\partial u/\partial x$ or that the pde even contain a flux term.

However, pdepe is designed to work best for this case. The"pe" in the function name stands for parabolic-elliptic; this is the class of PDE it was designed for. Based on your description, your system of PDE is likely hyperbolic. How well pdepe will work in your case depends on the specific equations and boundary conditions.

The numerical solution of hyperbolic PDEs can be quite challenging. Many books and papers have been written on this topic. However, many of the basic numerical techniques for solving hyperbolic PDEs rely on adding some "artificial diffusion" to the equations. In 1D this amounts to adding a small flux term that does depend on $\partial u/\partial x$. You can achieve the same effect by doing this manually in pdepe. The downside of this approach is that some experimentation is required to determine the right amount of artificial diffusion; too much and the solution may be overly smeared out, too little and the solution will show some undesirable oscillations.

If you want to know more, you might take a look at this classic text by Strikwerda: http://www.amazon.com/Difference-Schemes-Partial-Differential-Equations/dp/0898715679

Core MATLAB doesn't have a function designed specifically for hyperbolic PDEs. But Shampine, one of the authors of pdepe, has written such a function for MATLAB and it can be downloaded here:

http://faculty.smu.edu/shampine/current.html (See the section titled Hyperbolic PDEs)

• i've added the general form of my equations to my initial post. based on that, do you think i should still use pdepe ( without adding any extra terms to my equations ) or try and use the function in the link you gave here? – TensoR Mar 14 '16 at 19:13
• It is really impossible to say anything definitive based on such a vague description of your PDE system. As @nicoguaro already asked, you should show your equations, boundary conditions, and initial conditions. But, as a guess, I expect you will need to add some artificial diffusion to solve your system with pdepe. – Bill Greene Mar 14 '16 at 21:17
• i updated my initial post to a more specific form of the equations. but for the purpose of providing an answer, does it really matter which function of u each of the terms A,B,C,D,E are? isn't all that matters is that they are analytic continuous functions and that do not depends on x,t,du/dx. i just don't wanna go into unnecessary details. the boundary/initial conditions i cant provide yet because i dont have them yet. this set of equations describe a physical system (not just some mathematical problem) so i would have to think and try different kinds of initial/boundary conditions. – TensoR Mar 14 '16 at 21:54
• as i said in the previous comment, this is a physical problem, so adding additional terms that might provide a more accurate solution would seem unnatrual to me, but i could be wrong. so, given that, which of the 2 options is better for me? – TensoR Mar 14 '16 at 21:59
• also, will a program like Mathematica will have an easier time solving those PDEs? and if you think it's really necessary for me to write explicitly all of my equations, i will do so (if thats the case, can you point me as to how i write the equations in a form that is easy to read like i've seen in other threads, for example here : scicomp.stackexchange.com/questions/1836/… ) – TensoR Mar 14 '16 at 22:49