• No se han encontrado resultados

VALORES EMPRESARIALES

5.5 CONTENIDO DE LAS SESIONES DE COACHING

A primary concern for any numerical method is whether it is stable: will it blow up? Happily the semi-Lagrangian approach is “unconditionally stable”: no matter how big ∆t is, we can never blow up. It’s easy to see why: wherever the particle starting point ends up, we interpolate from old values of q to get the new values for q. Lin- ear/bilinear/trilinear interpolation always produces values that lie between the values we’re interpolating from: we can’t create larger or smaller values of q than were already present in the previous time step. So q stays bounded. This is really very attractive: we can select the time step based purely on the accuracy vs. speed trade-off curve. If we want to run at real-time rates regardless of the accuracy of the simulation, we can pick ∆t equal to the frame time for example.

In practice, the method can produce some strange results if we are too aggressive with the time step size. It has been suggested[FF01] that an appropriate strategy is to limit ∆t so that the furthest a particle trajectory is traced is five grid cell widths:

∆t ≤ 5∆x umax

(3.10) where umaxis an estimate of the maximum velocity in the fluid. This could be as simple as the maximum velocity

currently stored on the grid. A more robust estimate takes into account velocities that might be induced due to acceleration g from gravity (or other body forces like buoyancy) over the time step. In that case

umax= max(|un|) + ∆t |g| (3.11)

and after manipulating inequality (3.10) we can approximate this as: umax = max(|un|) +

p

5∆x g (3.12)

This has the advantage of always being positive, even when the initial velocities are zero, so we avoid a divide-by- zero in inequality (3.10).

3.2. TIME STEP SIZE 23

3.2.1 The CFL Condition

Before leaving the subject of time step sizes for advection, I can’t resist setting the record straight on a pet peeve of mine. The “CFL condition” is one of most abused terms in physics-based animation, and to try to make things clearer, I’ll explain it fully here. This section can be safely skipped if you’re not interested in some more technical aspects of numerical analysis.

The CFL condition, named for applied mathematicians R. Courant, K. Friedrichs and H. Lewy, is a simple and very intuitive necessary condition for convergence.2 Convergence means that if you repeat a simulation with smaller and smaller ∆t and ∆x, in the limit going to zero, then your numerical solutions approch the exact solution.3

The solution of a time dependent partial differential equation, such as the advection equation, at a particular point in space ~x? and time t? depends on some or all of the initial conditions. That is, it may be possible that the value of the intial conditions at one point can be changed without changing the value of the solution at ~x? and t?, whereas if you modify the initial conditions at other points the value of the solution there will change. In the case of the constant-velocity advection equation, the value q(~x?, t?) is exactly q(~x?− t?~u, 0), so it only depends on a single

point in the initial conditions. For other PDE’s, such as the heat equation ∂q/∂t = ∇ · ∇q, each point of the solution depends on all points in the initial conditions. The “domain of dependence” for a point is the set of points that have an effect on the value of the solution at that point.

Each point of a numerical solution also has a domain of dependence: again, the set of locations in the initial condi- tions that have an effect on the value of the solution at that point. It should be intuitively obvious that the numerical domain of dependence, in the limit, must contain the true domain of dependence if we want to get the correct answer. This is, in fact, the CFL condition: convergence is only possible in general if, in the limit as ∆x → 0 and ∆t → 0, the numerical domain of dependence for each point contains the true domain of dependence.

For semi-Lagrangian methods, the CFL condition is automatically satisfied: in the limit, the particle trajectories we trace converge to the true ones, so we interpolate from the correct grid cells and get the correct dependence. So talking about the CFL condition in the context of semi-Lagrangian methods is pretty much vacuous: there isn’t one! That said, for standard explicit finite difference methods for the advection equation, where the new value of a grid point qn+1i is calculated from a few of the old values at neighbouring grid points, i.e. from points only C∆x away for a small integer constant C, there is a meaningful CFL condition. In particular, the true solution is going at speed |~u|, so the speed at which numerical information is transmitted, i.e. C∆x/∆t, must be at least as fast. That is:

C∆x

∆t ≥ |~u| (3.13)

which turns into a condition on the time step:

∆t ≤ C∆x

|~u| (3.14)

Now, here’s where most of the confusion arises. This is often the same, up to a small constant factor, as the maximum stable time step for the method. (There are of course exceptions: the first method in this chapter was unstable no matter how small the time step, and it is possible to devise explicit methods which are stable no matter how large

2It is not three downs and 110 yards. 3

As an aside, this is a sticky point for the three dimensional incompressible Navier-Stokes equations, as at the time of this writing nobody has managed to prove that they do in fact have a unique solution for all time. It has already been proven in two dimensions, but a million dollar prize has been offered from the Clay Institute for the first person to finish the proof in three dimensions.

24 CHAPTER 3. ADVECTION ALGORITHMS the time step is—though of course they give the wrong answer unless the CFL condition is satisfied!) Because the two are often about the same, people got the notion that somehow the CFL condition is always the same as the requirement for stability, when it is has nothing at all to do with it, or even that it’s always the condition (3.14) regardless of the numerical method you’re using. Thus you may see written that the time step we talked about earlier, inequality (3.10), is five times the CFL condition—when that doesn’t make any sense whatsoever!

So, now you know. Spread the word. Don’t abuse the CFL condition when you really mean stability condition or accuracy condition.