• Aucun résultat trouvé

Other schemes

Dans le document Numerical Sound Synthesis (Page 158-162)

The 1D wave equation

6.3 Other schemes

Given that scheme (6.34) is exact for λ=1, there is not practical interest in exploring more elaborate schemes for the 1D wave equation. On the other hand, few systems permit such an exact solution, and the 1D wave equation is thus quite singular in this regard and not at all representative of any other system of interest in musical acoustics. For this reason, some more complex finite difference constructions are briefly described in this section. For much more on finite difference constructions for the 1D wave equation, see, e.g., [365, 259, 260, 98, 40].

6.3.1 A stencil width of five scheme

An explicit generalization of scheme (6.34) employs a wider stencil-centered approximation to the spatial derivative term:

δt tu=γ2+(1α)μ) δxxu (6.56) This scheme involves a free parameterα, and reduces to scheme (6.34) whenα=1; it is nominally second-order accurate in both space and time, which is immediately evident since all operators are centered. Notice the use of the operatorα+(1α)μ, which is an approximation to the identity operation, as discussed at the end of Section 5.2.2. The form above may be expanded into the following recursion:

unl+1=(2+λ2(1−3α))unl +λ2(2α−1)

unl−1+unl+1 +λ2

2 (1α)

unl+2+unl−2

unl1 This scheme makes use of points two grid spacings removed from the update point, and thus has a stencil width of five. See Figure 6.20(a) for a representation of the stencil or “footprint”

corresponding to this scheme.

The characteristic equation for scheme (6.56) is easily obtained, again through the insertion of a test solution of the formunl =znej lβh:

z+

−2+4λ2

1−2(1−α)sin2(βh/2)

sin2(βh/2)

+z1=0

The condition that the roots of the characteristic equation be of unit magnitude is thus, from (2.15), that

0≤λ2

1−2(1−α)sin2(βh/2)

sin2(βh/2)≤1

for all values ofβ. In order to approach the analysis of this apparently unwieldy expression, note that what is really needed is to find the maximum and minimum values of a polynomial over an interval. Writing p=sin2(βh/2), and noting that 0p≤1, the conditions above may be written as

pmin[0,1]F (p)≥0 and λ2≤ 1

maxp∈[0,1]F (p) where F (p)=p(1−2(1−α)p) (6.57) The left-hand inequality is satisfied for

α≥1/2 (6.58)

(a) (b)

k h

Update Point n + 1

n n − 1

l − 2 l − 1 l l + 1 l + 2

k h

l − 2 l − 1 l l + 1 l + 2 n + 1

n n − 1

Update Point

Figure 6.20 Computational stencil of (a) scheme (6.56), and (b) scheme (6.60).

150 THE 1D WAVE EQUATION

Given the above restriction onα, the right-hand inequality yields a rather complex bound onλ, which is dependent on the chosen value ofα:

λ

⎧⎪

⎪⎩

√8(1−α), 1

2 ≤α≤ 3

√ 4

1/(2α−1), α >3 4

(6.59)

See Problem 6.10.

One problem with the use of such a scheme is that because the stencil or footprint is now wider, it will be necessary to set an additional boundary condition when the scheme is restricted to a finite domain, such asUN. It is clear that updatingun+1l at grid points of indexl=0 andl=1 requires access to values outside the domain interior, but the wave equation itself allows only a single boundary condition at the endpoint of the domain. This extra numerical boundary condition must thus be set very carefully — this is a general problem with numerical methods of high accuracy which do not operate locally. Energetic analysis for this scheme is also possible, and leads to the same stability conditions above, as well as to proper settings for the numerical boundary conditions;

because this scheme is of academic interest only, such analysis will be not be presented here. Energy analysis of wider stencil schemes will, however, be dealt with at a later stage, in the case of the ideal bar, in Section 7.1.4. The choice of the parameterαhas a rather large influence on the numerical phase and group velocities (and thus on the tuning of mode frequencies). See Figure 6.21(a).

6.3.2 A compact implicit scheme

A generalization of scheme (6.34) of an entirely different character is the following:

+(1θ )μ) δt tu=γ2δxxu (6.60) This scheme also involves a free parameter, θ, and reduces to scheme (6.34) whenθ =1, and is again nominally second-order accurate in both space and time. Variants of this scheme have indeed been used for sound synthesis [74] from models of vibrating strings, and xylophone bars [77], though the version presented here is slightly different from that used in the references above (see Problem 6.11). The symbol θ has been chosen to indicate the relationship with so-called

0 0.5 1

1.3

1.3 1.1

1 0.9 0.8 1.1

1 0.9

0.8 0.9

1 1.1 1.3

0.8 0.9

1 1.3 1.1 0.8

1.5 2

0.8 0.9 1 1.1 1.2

0 0.5 1 1.5 2

ƒ ƒ

ƒ

ƒ

0.6 0.8 1 1.2 1.4

0 0.5 1 1.5 2

0.8 0.9 1 1.1 1.2

0 0.5 1 1.5 2

0.8 1 1.2 1.4 1.6

× 104 × 104

× 104 × 104

(a) (b)

vφ γ

vg

γ vg

γ vφ

γ

Figure 6.21 Numerical phase and group velocity for (a) scheme (6.56) and (b) scheme (6.60), under various choices of the free parametersαandθ, respectively, as indicated.

“θ-schemes,” and fractional time-step methods used for simulating first-order equations, particularly in fluid dynamics applications [393].

The following recursion results:

θ un+1l +1−θ 2

un+1l+1 +un+1l1 =

λ2+1−θ unl+1+unl−1

+2(θ−λ2)unlθ un−1l +θ−1

2

un−1l+1 +un−1l−1

In this case, the values of the grid function at the update time stepn+1, written on the left side of the above recursion, are coupled; this is the first instance in this book of a so-called implicit finite difference scheme. It is not possible to solve the above recursion without the use of linear system solution techniques, which are usually more costly than explicit updating. In order to better understand the implementation of such a scheme, matrix representations of difference operators as discussed in Section 5.2.7 are essential. Assuming the column vectorun to contain the values of the grid functionunl, then the scheme may be written as

un+1=A−1Bunun−1 with A=θI+(1θ )M B=γ2k2Dxx+2A

where it is assumed that if the grid function is limited to a finite set of values, boundary con-ditions (to be discussed shortly) will be incorporated into the above matrices. Dxx andM are matrix representations of the difference operatorsδxx and μ, which appear, in infinite form, in Section 5.2.7. The real work involved here is in the solution of the linear system involving the matrix Aat each time step. A full matrix inversion of A (or even full storage of the matrixA itself) is to be avoided in any implementation, asAis tridiagonal and thus very sparse, and various fast solution techniques, most notably the Thomas algorithm [354, 342], are often employed. See Programming Exercise 5.6 in the previous chapter, which illustrates the use of all-purpose iterative methods in the Matlab programming environment.

In exchange for this added complexity, such schemes are potentially much more accurate than explicit schemes, and often operate under much looser stability conditions (though it should be kept in mind that in this very special case, scheme (6.60) is exact whenθ=1). To this end, it is worth again writing the characteristic polynomial corresponding to scheme (6.60), again employing the variablep=sin2(βh/2):

(1−2(1−θ )p) z+(4λ2p−2(1−2(1−θ )p))+(1−2(1−θ )p) z1=0

The stability analysis here is similar to that of the five-point scheme, except that now, one must determine the maximum and minimum values of a rational function over the unit interval; the stability conditions are then

p∈[0,1]min F (p)≥0 and λ2≤ 1

maxp[0,1]F (p) where F (p)= p

1−2(1−θ )p (6.61) which are satisfied when

θ≥ 1

2 and λ≤√

2θ−1 (6.62)

See Problem 6.12. Notice here that asθ becomes large,λcan also be large as well, meaning that, for a given grid spacingh, the time step k can become large as well, leading to fewer recursion steps relative to the standard scheme (6.34), for which λ is bounded strictly by 1. This is the justification often given for using implicit methods —though each step in the recursion becomes more complex, computationally, than that of an explicit scheme, one may get away with fewer

152 THE 1D WAVE EQUATION

such steps. For sound synthesis, this is probably the wrong way of looking at the relative merits of explicit and implicit methods. The time stepk is fixed, from the outset, from the audio sample rate. A better interpretation is that implicit methods,operating at a given sample rate, can allow for much lower numerical dispersion than an explicit schemeoperating at the same sample rate.

Some examples of this will be provided at later stages in this book, especially in the case of bar vibration in Section 7.1.5, but a good question is: in the context of musical sound synthesis, is the reduction of numerical dispersion of enough perceptual importance to justify the use of more complex schemes? The answer, however, can only be dependent on the specifics of the problem at hand. The reduction of numerical dispersion, however, is but one advantage of implicit methods;

another is easier control over stability, one which will be seen to be of great utility in dealing with sound synthesis methods for nonlinear problems. See, for example, Chapter 8 for some examples of the use of implicit methods in the case of nonlinear string vibration.

One potential complication of the use of implicit methods is in setting boundary conditions —it can be far less clear how to do this properly when the update values at the boundaries themselves are coupled to other unknowns. Again, energy analysis is invaluable in this respect. For scheme (6.60), one may employ identity (5.14), and rewrite the scheme as

1+(1θ )h2 2 δxx

δt tu=γ2δxxu

Considering the scheme defined over the semi-infinite domain D=Z+, taking an inner product withδt·ugives, as usual,

δt+h=b where, in this case, one has

h=t+v with t=1

2δtu2Z+(1θ )h2

4 δtδx+u2Z+ v=γ2

2 δx+u, etδx+uZ+

and

b= −γ2u0) (δx−u0)+(1θ )h2

2 u0) (δx−δt tu0)

The scheme will be conservative whenbvanishes, and it is easy to see from the above expression that this will be true when, for example,u0=0, orδxu0=0, which are the same discrete Dirichlet and Neumann conditions as for the simple scheme (6.34).

Dans le document Numerical Sound Synthesis (Page 158-162)