# Book on numerical solution of PDEs

I would like to learn how to solve partial differential equations (first and second order, e.g. Poisson, etc...) numerically with finite differences. Which book can be recommended if one want it to learn at the level of a physicist and not a mathematician? Of course I know that the topic is not trivial, but I would like to learn how to solve concrete problems in fluid dynamics without studying mathematics for three years first. In other words: it shouldn't be too trivial, but not too demanding either.

To put an example: Given an initial 2D velocity stream field $$u(x,y,t=0), v(x,y, t=0)$$ I would like to solve numerically for $$u(x,y,t)$$, $$v(x,y,t)$$ by empoing the vorticity equation for an incompressible fluid:

$$\zeta(x, y, t) = \vec \nabla \times \vec v(x, y, t)$$

$$\frac{\partial \zeta}{\partial t} + u(x,y) \cdot \frac{\partial \zeta}{\partial x} + v(x,y) \cdot \frac{\partial \zeta}{\partial y} = 0$$

This is the simplest equation in fluid dynamics. Regardless of whether it is realistic in nature or not, I would like to be able to solve such a model problem.

EDIT:

Originally I didn't want to put the original problem here, but here it is:

The problem in particular was:

As an exercise there were given four Rankine vortices of radius R=1 (1...4) at positions (0, 0), (-2,0), (2,0), (0,1). Vorticities for 2, 3, 4 are given as 1, 1, -3. The question was how to choose vorticity of a fifth vortex at (0, -4) so that vortex 1 is not moving. Considering all vortices as rather solid objects and by focusing on their centers the simple answer is of course -12 due to 1/r behavior outside R.

But then we had some discussion about how to interpret the exercise and came to the conclusion, that it is more complex: by viewing the velocity field all vortices (including 1) are not only moving around but also become severely distorted as time passes. The big question then was not how to draw the initial field (see image) but how this initial field develops with time.

Assuming conservation of vorticity the equation above must be fulfilled together with the condition, that the velocity field is free of divergence. I was wondering, how such problem can be formulated in terms of finite differences and finally is solved.

• What is your background? Which applications you're most interested in? Anyway, your question sounds a lot like that question I'd never want to listen to Commented Dec 7, 2023 at 16:11
• Want to do it in C? Numerical Recipes in C: amazon.com/Numerical-Recipes-Scientific-Computing-Second/dp/…
– hft
Commented Dec 7, 2023 at 19:14
• Looks like there is a newer edition for C++: amazon.com/…
– hft
Commented Dec 7, 2023 at 19:15
– hft
Commented Dec 7, 2023 at 19:16
• with infinite domain, it's not that easy to use finite difference methods, or grid-based methods Commented Dec 8, 2023 at 0:12

Michael Zingale has written a rather extensive open-source textbook on numerically solving PDEs, albeit with an astrophysical context (which shouldn't really matter, the methods are largely the same), which is available on his github page.

The first few chapters are relatively light on maths (mostly PDE classification, finite difference background, numerical errors), but the text as a whole largely requires familiarity with Linear Algebra and PDEs.

Chapter 3 is where Finite Volume Methods (FVM) are introduced to distinguish it from Finite Difference (FDM). It is in Chapter 5 that really begins the mathy-programming of improvements of FVM over FDM and how to convert PDEs into FVM algorithms. Euler's equations, which are a 0-viscosity limit of Navier-Stokes equation) are covered in Chapter 7 while their numeric implementation are in Chapter 8.

It makes frequent reference to his Python implementation of hydrodynamics code, called pyro2, though it's not really a tutorial on using it (which exists in github repo for pyro2).

If you just want to get hands-on and actually solve problems, then try this book freely available online.

Finite Difference Computing with Partial Differential Equations
Hans Petter Langtangen

There are so many excellent books on finite difference methods for ordinary and partial differential equations that writing yet another one requires a different view on the topic. The present book is not so concerned with the traditional academic presentation of the topic, but is focused at teaching the practitioner how to obtain reliable computations involving finite difference methods.

It covers some common schemes for implementing finite differences, boundary conditions, error analysis, and some pitfalls you can encounter. There are several example problems. The code is in Python, and some of the text is dedicated to implementing Python, but the lessons on finite differences can of course easily be applied elsewhere.

However, to touch on your subject matter, I don't believe it is common to handle many fluid dynamics problems with finite differences. One reason is that conservation laws can be very difficult to implement with high precision, so you have to devise increasingly complicated methods to enforce that conservation. But things like the convection-diffusion equation can be solved with finite differences just fine.

• Just to ask: "I don't believe it is common to handle many fluid dynamics problems with finite differences." What approaches are used instead? Commented Dec 8, 2023 at 8:27
• @MichaelW Finite Volume and Finite Element are the two more common approaches. Each has their advantages/disadvantages, so it usually depends on scenario design and/or your advisor's experience. Commented Dec 8, 2023 at 13:09
• You could look at vortex methods, if you're mainly interested in this kind of problem Commented Dec 8, 2023 at 14:45