2
$\begingroup$

I am beginner in MATLAB and similar. I sow and discussed with my professors doing simulations some times: they wrote down a lot of calculus, most of them using Crank-Nicolson Method and so implement them on MATLAB.

Until now, I could not imagine that MATLAB has pdepe. Today I've learned about pdepe and try to code a PDE that my professor coded with Crank-Nicolson. The result was absolutely the same and I had less calculus.

I am thinking about the difference between the two methods. In fact, I'd like to know when is not so good use pdepe (once I thought this is marvelous, very easy...!). What can be the benefits of other methods on simple researchs?

Many thanks in advance.

$\endgroup$
  • 1
    $\begingroup$ Well, so your question is basically why people write their own code while there is pdepe class in MATLAB available right? There could be a lot of reasons for that. For example, maybe pdepe doesn't scale well when the size of the system goes up and people use to write their own code to make it more efficient/accurate. I mean as long as I don't see your professor's code based on Crank-Nicolson, it's a bit difficult to say why, but there must be reason that you could easily ask your professor. Regarding your question: How good is pdepe? Good with what sense? Speed? Accuracy? Scaling? $\endgroup$ – Alone Programmer Jan 16 at 23:19
  • $\begingroup$ @AloneProgrammer, right. Many thanks for your answer! Maybe I could try ask just one more time on these terms: In generally, pdepe is a good choice or most of time researches have to wrti their codes? $\endgroup$ – Na'omi Jan 16 at 23:29
4
$\begingroup$

Crank-Nicolson is a very good classical approach for parabolic PDE like the heat transfer PDE to which it was originally applied. It is relatively easy to understand and implement so it is often presented in basic courses on numerical methods for PDE. pdepe is also very well-suited to this class of PDE (the second "p" in pdepe stands for parabolic). It has many advantages over a basic implementation of Crank-Nicolson including accuracy AND performance. However the algorithms in pdepe are not easy to understand and even more challenging to implement.

That being said, pdepe is not well suited to PDE that involve convection such as those modeling fluid flow. These PDE are classified as hyperbolic and there is a huge collection of literature on numerical approaches to solve these. You can find many excellent solvers coded in MATLAB and other languages for this class of PDE.

The bottom line is this: If your objective is to understand the different algorithms for numerical solutions to PDE, by all means code your own solver. But if your objective is to simply solve PDE as part or your research, I strongly suggest you look for a solver coded by specialists in this area.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Many thanks, Mr. Greene! $\endgroup$ – Na'omi Jan 17 at 16:18
  • $\begingroup$ Please, could you give me some more details if is not much work...? I thank you so much. 1) The convection term is $\partial u/\partial x$, isn't? In which is it related with hyperbolity...? 2) Could you tell me a solver for hyperbolic equation? $\endgroup$ – Na'omi Jan 18 at 22:50
  • 1
    $\begingroup$ Shampine has a solver for hyperbolic PDE that runs in matlab. Go to this page: faculty.smu.edu/shampine/current.html and look for the heading "Hyperbolic PDEs". There are links there to the matlab code and a paper describing the solver. $\endgroup$ – Bill Greene Jan 19 at 11:52
  • $\begingroup$ Thank you so much! $\endgroup$ – Na'omi Jan 19 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.