• Aucun résultat trouvé

A finite difference scheme

Dans le document Numerical Sound Synthesis (Page 178-182)

Linear bar and string vibration

7.1 The ideal uniform bar

7.1.4 A finite difference scheme

The most straightforward finite difference scheme for the ideal bar equation (7.2) may be written, in operator form, as

δt tu= −κ2δxxxxu (7.11)

where the definition ofδxxxx is given in (5.12b). When the operator notation is expanded out, the following two-step recursion results:

un+1l =(2−6μ2)unl +4μ2 unl+1+unl−1

μ2 unl−2+unl+2

un−1l (7.12)

In order to be updated, the scheme requires access to values of the grid function two grid spacings away from the update point, and is parameterized by the single numberμ,

μκk/ h2

μplays a role similar toλ, the Courant number, which appears in schemes for the wave equation.

Like the two-step scheme for the wave equation (6.34), scheme (7.11) must be initialized with val-ues of the grid functionunl at time stepsn=0 andn=1. Scheme (7.11) is, formally, second-order accurate in both time and space—unlike the case of scheme (6.34) for the wave equation, there is no special choice of the parameterμwhich leads to improved accuracy.

von Neumann analysis

Just as for schemes for the wave equation, one may employ the test functionunl =znejβlh, which, when inserted in scheme (7.11), gives the following characteristic polynomial inz:

z+(16μ2sin4(βh/2)−2)+z1=0 (7.13) This equation possesses roots of magnitude unity under the condition

μ≤ 1

2 −→ kh2

2κ (7.14)

which is somewhat different from the condition (6.40) which arises in the scheme (6.34) for the 1D wave equation. Now, the time step is bounded by the square of the grid spacing, rather than the grid spacing itself. This condition has interesting ramifications with regard to computational complexity, as will be discussed next.

Degrees of freedom and computational complexity

Supposing that the bar equation is defined over the unit intervalD=U, the number of degrees of freedom of the scheme will be, as in the case of schemes for the wave equation, twice the number of grid points over this interval (scheme (7.11) is again a two-step scheme). Given that this number of grid points is approximately 1/ h, and that the sample rate is defined asfs=1/ k, the number of degrees of freedom will be bounded, from the stability condition (7.14), as

Nfd= 2 h

2fs

κ

which is very similar to the number of modes required to represent the solution of the ideal bar equation to frequencies up tofs, from (7.10), but not the same— it is greater by a factor of√

π/2 which is quite close to one, meaning that a modal representation and the finite difference scheme possess roughly the same number of degrees of freedom. This small discrepancy may be related to effects of numerical dispersion, as described in the next section. It is crucial to note that, in a comparison between the wave equation and the bar equation, for which both possess the same first non-zero modal frequency (or “fundamental,” if one may indeed apply that term to an inharmonic system such as a bar), the bar will possess far fewer degrees of freedom— as a result, computations for dispersive systems such as bars are lighter than those for non-stiff systems such as strings. This may be counterintuitive, given that the bar equation itself looks more complex than the wave equation. Looks can be deceiving. Such an efficiency gain for stiff systems may be exploited to great benefit in, for instance, models of plate reverberation, which are far less computationally intensive than even 2D simulations of the wave equation, in the context of artificial reverberation.

170 LINEAR BAR AND STRING VIBRATION

See Section 12.3.3. On the other hand, the thin bar model is itself an idealization —when more realistic models are employed, the number of degrees of freedom (and thus the memory and operation count in simulation) creeps up again. See Problem 7.2.

Numerical dispersion

When the stability condition (7.14) is satisfied, the roots of the characteristic equation are of the formz=ej ωk, and thus the characteristic polynomial (7.13) may be written as

sin(ωk/2)= ±2μsin2(βh/2)

which is analogous to the dispersion relation (7.4) for the continuous ideal bar equation. In contrast with scheme (6.34) for the wave equation, this scheme exhibits numerical dispersion, beyond the natural dispersion inherent in the bar equation itself, for any allowable choice ofμ. See Figure 7.3 for plots of numerical phase and group velocity for different choices of μ— it remains true, however, that numerical dispersion is minimized as μ approaches the bound given in (7.14), as per Rule of Thumb #1, given on page 136.

It is also true in this case that when the scheme is operating away from the stability condition (7.14) (i.e., when μ <1/2), there will be some loss in available bandwidth for the computed solution. The dispersion relation above possesses solutions for real frequenciesf only when

ffmax= 1

π ksin1(2μ)

wherefmax is a numerical cutoff frequency —this cutoff behavior is clearly visible in Figure 7.3.

Energy conservation and non-negativity

Just as for schemes for the wave equation, energy analysis is possible (and indeed quite straightfor-ward) for scheme (7.11). Considering the problem defined over the infinite domainD=Z, taking an inner product with the grid function δu, and using the double summation by parts identity (5.28), gives

δu, δt tuZ= −κ2δu, δxxxxuZ= −κ2δxxu, δδxxuZ

or

δt+h=0 with h=t+v and t= 1

2δtu2Z v=κ2

2δxxu, etδxxuZ (7.15)

0 0.5 1 1.5

0.35 0.4 0.45

0.5

2

× 104 0

100 200 300 400

0 0.5 1 1.5

0 200 400 600 800

f

2

× 104 f

vf vg

0.35 0.4

0.5 0.45

Figure 7.3 Numerical phase velocityvφ(left) and group velocityvgas functions of frequencyf for scheme (7.11) for the ideal bar equation, withκ=1, under different choices of the parameter μ (as indicated), plotted as grey lines. The curves for the continuous model system are plotted as black lines. In this case, the time step has been chosen as k=1/44 100. Notice the numerical cutoff visible in the curves for values ofμ <1/2.

The total difference (7.15) above is a statement of conservation of numerical energy for the scheme (7.11), and it thus follows that

hn=h0

Just as in the case of schemes for the wave equation, in order to find conditions under which this energy is non-negative, one may write, using identity (2.22f) and inequality (5.31),

h=1

2δt−u2Z+κ2

2μt−δxxu2Zk2κ2

8 δt−δxxu2Z

≥ 1

2−2k2κ2 h4

δtu2Z+κ2

2μtδxxu2Z

The energy is non-negative under condition (7.14), and under this condition a bound on solution size for allnfollows immediately. Again, energy analysis leads to the same stability condition as von Neumann analysis.

Numerical boundary conditions

Numerical boundary conditions may be derived, again as in the case of schemes for the wave equation. Here, however, the analysis is slightly more delicate—different choices of inner product, as well as uses of summation by parts, can give rise to different conserved energies, accompanied by distinct numerical boundary conditions.

Consider now the scheme (7.11) defined over the semi-infinite domain Z+. Taking the inner product withδt·u, and using the summation by parts identity from (5.27b), gives

δt+h=b with h=t+v and t= 1

2δtu2Z+ v= κ2

2δxxu, etδxxuZ+

and

b= −κ2δx+u0) (δxxu0)+κ2u0) (δx−δxxu0)

Thus numerical energy conservation follows under the following choices of numerical boundary condition at the left end point of a domain:

u=δx+u =0 clamped (7.16a)

u=δxxu =0 simply supported (7.16b)

δxxu=δx−δxxu=0 free (7.16c)

These conditions are analogous to the conditions (7.7) for the ideal bar equation.

The particular form of summation by parts used above, namely that given in (5.27b), leads to a simple, tractable expression for the numerical conserved energy, if b=0 —tractable in the sense that non-negativity is easy to show, as the expression for the potential energyvis limited strictly to theinterior of the problem domain. Just as in the case of the infinite domain discussed in Section 7.1.2, one has

h=1

2δt−u2Z++κ2

2μt−δxxu2Z+k2κ2

8 δt−δxxu2Z+

≥ 1

2−2k2κ2 h4

δt−u2Z++κ2

2μt−δxxu2Z+ and the stability condition (7.14) again leads to non-negativity.

172 LINEAR BAR AND STRING VIBRATION

It is important to note that if one were to use the other form of the summation by parts identity, i.e., that given in (5.27a), the derived boundary conditions would be distinct, as would the expression for energy. In some cases, it is not so easy to show non-negativity as v may not be limited to the interior of the problem domain. See Problem 7.5 for some variations on energy analysis and numerical boundary conditions for the bar.

Implementation of numerical boundary conditions

It is useful to show how numerical boundary conditions such as (7.16), written in compact operator form, may be implemented directly in the scheme (7.11).

The clamped condition atl=0 is the most straightforward: one may set u0=u1=0

at each pass through the recursion. Thus only values ul of the solution at locations l=2,3, . . . need be computed; because the operator δxxxx is of width 5, its value may be computed directly using the settings above foru0 andu1.

The simply supported conditions are slightly more complicated. They may be rewritten as u0=0 u−1= −u1

Now, values at the grid locationsl=1, . . .must be updated; under the action ofδxxxx, the value at l=1 will require access to a value at a virtual grid pointl= −1 (see Section 5.2.8). It is sufficient to examine the behavior of the operator δxxxx at locations near the boundary, and employ both conditions above:

δxxxxu1= 1

h4(u3−4u2+6u1−4u0+u1)= 1

h4(u3−4u2+5u1)

Such conditions may be incorporated into a matrix form of the operator δxxxx, as outlined in Section 5.2.8.

The settings for the free boundary condition are left to Problem 7.6.

Dans le document Numerical Sound Synthesis (Page 178-182)