# PDEs -- problems solving them numerically

#### Vrbic

Hello,
I have a problem with a solution of PDEs. I understand it is impossible to find my problem but some hint how to look at such problem would be very useful. I have to say it is my first encounter with a numerical solution of PDEs, so be patient with my description.

I have a code (in Fortran but I think it isn't important) for the solution of 5 tied up first order non-linear partial differential equations. I solve hydrodynamical equations (dependent on time) for some compact object. It works for some boundary and initial conditions but if I "rescale it" and I change (decrease) initial mass, i.e. I change all initial function and also the size of step (not a number of steps, but IT is probably important), the results with increasing time aren't smooth. I mean, the code works perfectly from the beginning but after some time most points of all function look very good, but few, let's say 5%, starts to look like noise.

All dif. eqs. are expected as difference eqs. and solved step by step. My idea is that the problem is in numerical differentiation. It is done by definition: F'(x)=(F(x+h)-F(x))/h. I tried to change to "two" steps and "five" steps algorithm of differentiation but it was worse. Even for the condition if it works.
If anyone have some points, hints or where starts to find a problem. Please let me know.

Thank you all.

Related Programming and Computer Science News on Phys.org

#### jedishrfu

Mentor
When doing any kind of numerical integration, you have to choose the ODE/PDE solver appropriately. Some solvers are good when the solution is monotonically increasing (ie Euler and its alternatives) whereas some are good when the solution is periodic as in orbital motion.

What often happens is small amounts of error are introduced over time causing the system to gain energy or small amounts of error decrease over time appearing a energy loss by the system. You choice of ODE/PDE solver must mitigate that in order to work for longer intervals.

• Klystron

#### Vrbic

When doing any kind of numerical integration, you have to choose the ODE/PDE solver appropriately. Some solvers are good when the solution is monotonically increasing (ie Euler and its alternatives) whereas some are good when the solution is periodic as in orbital motion.

What often happens is small amounts of error are introduced over time causing the system to gain energy or small amounts of error decrease over time appearing a energy loss by the system. You choice of ODE/PDE solver must mitigate that in order to work for longer intervals.
Yes, understand.

This problem was already solved (but not for all condition I want), I would like to use this result and extend. So, I use the same method (probably something like Euler's method). The resulting functions are not strictly monotonic but not chaotic or periodic (mostly one extreme or inflex point). It is true that problems appear in the very sudden change or inflex point...seems to me.

Is there any procedure how to "cure" such regions if I expect that? Is that problem in the very trivial definition of differentiation or in the accuracy of functions who make up the differentiation?

#### jedishrfu

Mentor
I think your only choice is finer steps and/or go Runge Kutta RK4 as it often works much better than other methods.

https://en.wikipedia.org/wiki/Runge–Kutta_methods

Here's some commentary about their limitations:

https://farside.ph.utexas.edu/teaching/329/lectures/node40.html

which basically are they are easier to implement in code but run slower than the fancier methods and can suffer from accuracy over time due to the infamous truncation error.

And a slideshow on the various methods placed here for others interested in this topic (with MATLAB):

You could research your problem online and see if others have solved it using a difference ODE solver.

#### Vrbic

I think your only choice is finer steps and/or go Runge Kutta RK4 as it often works much better than other methods.

https://en.wikipedia.org/wiki/Runge–Kutta_methods

Here's some commentary about their limitations:

https://farside.ph.utexas.edu/teaching/329/lectures/node40.html

which basically are they are easier to implement in code but run slower than the fancier methods and can suffer from accuracy over time due to the infamous truncation error.

And a slideshow on the various methods placed here for others interested in this topic (with MATLAB):

You could research your problem online and see if others have solved it using a difference ODE solver.
Thank you, but my problem is PDEs. I know Runge-Kutta but only for ODEs. Is it possible to adjust it to solving PDEs?

#### jedishrfu

Mentor
• Vrbic

#### Svein

My reference books divide the PDEs into three classes: Hyperbolic, parabolic and elliptic. The tools for solving are then discussed separately (sorry, I am no expert on this so I cannot go into details).

• Vrbic

"PDEs -- problems solving them numerically"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving