• Aucun résultat trouvé

The simple harmonic oscillator

Dans le document Numerical Sound Synthesis (Page 57-60)

The oscillator

3.1 The simple harmonic oscillator

The simple harmonic oscillator, perhaps the single most important ODE in physics, and of central importance to musical sound synthesis, is defined as

d2u

dt2 = −ω20u (3.1)

It is a second-order ODE, and depends on the single parameter ω0, also known as the angular frequency of oscillation. The frequency f0, in Hertz, is given by f0=ω0/2π. The harmonic oscillator, as it is second order, requires the specification of two initial conditions, normally

u(0)=u0 du dt

t=0=v0

Equation (3.1) above may be arrived at in a variety of different contexts. In mechanics and acoustics, the canonical example is that of the mass– spring system, illustrated in Figure 3.1(a).

A mass M is connected, via a linear spring of spring constantK, to a rigid support, andu(t ) represents the variation of the displacement of the mass about an equilibrium spring extension.

Under these conditions, and if initial conditions such asu0andv0above are given,u(t )satisfies (3.1) withω0=√

K/M.The oscillator also occurs naturally in electrical circuit theory, as illustrated in Figure 3.1(b)—here,u(t )represents the voltage across a linear capacitor, of capacitanceC in series with an linear inductor of inductanceL. Again, if appropriate initial conditions are supplied, the voltage will evolve according to (3.1), with ω0=1/√

LC. Though electrical circuit theory

M K

u(t)

u(t) 0

(a) (b)

L C

Figure 3.1 (a) Mass –spring system, with a massM and a spring of stiffness K, for which the displacement u(t ), measured about an equilibrium distance (marked as 0), solves (3.1). (b) A connection of an inductor of inductanceL, and a capacitor of capacitanceC, for which the voltage u(t )across the capacitor solves (3.1).

THE SIMPLE HARMONIC OSCILLATOR 47 might seem to be a poor match for problems involving musical instrument modeling, and in fact will appear only fleetingly here, it is worth keeping in mind that scattering methods such as digital waveguides [334] and wave digital filters [127], which are heavily used in physical modeling sound synthesis, were all first developed using concepts borrowed from electrical network theory.

See Section 1.2.4 for some general remarks on the use of scattering methods in synthesis, and Section 3.3.3 for a brief examination of wave digital filters. There is also, of course, a long tradition in acoustics of modeling lumped systems in terms of equivalent circuit elements, primarily for simplicity of representation [244].

3.1.1 Sinusoidal solution

It is well known that the solution to (3.1), ifu(t )is constrained to be real valued, and ifω0=0, has the form

u(t )=Acos(ω0t )+Bsin(ω0t ) (3.2) where clearly, one must have

A=u0 B=v00

Another way of writing (3.2) is as

u(t )=C0cos(ω0t+φ0) (3.3)

where

C0=

A2+B2 φ0=tan1(B/A) (3.4)

C0is the amplitude of the sinusoid, andφ0is the initial phase. See Figure 3.2.

From the sinusoidal form (3.3) above, it is easy enough to deduce that

|u(t )| =C0|cos(ω0t+φ0)| ≤C0 for t≥0 (3.5) which serves as a convenient bound on the size of the solution for allt, purely in terms of the initial conditions and the system parameterω0. Such bounds, in a numerical sound synthesis setting, are extremely useful, especially if a signal such asu is to be represented in a limited precision audio format. Note, however, that the bound above is obtained only through a priori knowledge of the form of the solution itself (i.e., it is a sinusoid). As will be shown in the next section, it is not really necessary to make such an assumption.

The use of sinusoidal, or more generally complex exponential, solutions of a given system in order to derive bounds on the size of the solution has developed, in the discrete setting, into a framework for determining the numerical stability of a simulation algorithm, also known as von Neumann analysis [342, 161]. Much more will be said about this from Chapter 5 onwards.

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1

−1

−0.5 0 0.5 u(t) 1

t Figure 3.2 Sinusoid, of the form given in (3.3), withC0=1,f0=ω0/2π=100, andφ0=π/4.

3.1.2 Energy

It is straightforward to derive an expression for the energy of the simple harmonic oscillator.

Recalling the discussion at the beginning of Section 2.4.1, after multiplying (3.1) bydu/dt, one arrives at

du dt

d2u

dt2 +ω20du

dtu=0 −→ d

dt 1

2 du

dt 2

+ω20 2u2

=0 (3.6)

Writing

H=T+V with T= 1 2

du dt

2

and V=ω20

2u2 (3.7)

one has

dH

dt =0 −→ H(t )=constant≥0

When scaled by a constant with dimensions of mass,T,V, andHare respectively the kinetic energy, potential energy, and total energy (or Hamiltonian) for the simple harmonic oscillator (SHO).

In order to arrive at a bound on solution size in this case, it may first be observed that H(t )=H(0)= 1

2v02+1

2ω20u20= 1 2ω02C02

whereC0 is defined in (3.4). Then, noting the non-negativity ofTandV, as defined in (3.7), it follows that

0≤V(t )≤H(t )=H(0)= 1 2ω02C02 and, using the form ofV(t ), finally

|u(t )| ≤C0 for t≥0 (3.8)

which is the same as the bound obtained in the previous section. In this case, however, one has made no a priori assumptions about the form of the solution. A bound on du/dt can also be obtained; though not so useful for the SHO given the strength of the above condition onu itself, such bounds do come in handy when dealing with distributed systems under free boundary conditions. See Problem 3.1.

This type of analysis, in which frequency domain analysis is avoided, has also been applied to the analysis of numerical simulation techniques, and is sometimes referred to as the energy method [284]. Here, although an energy has been “derived” from system (3.1), one could equally well begin from the expressions for kinetic and potential energy given in (3.7), and, through the application of variational principles, arrive at (3.1). This variational point of view dominates in the modern finite element simulation community.

3.1.3 As first-order system

In the literature, many numerical time-integration techniques are introduced with regard to first-order ODE systems. It is simple enough to expand the definition of the SHO, from (3.1), to a first-order system in two variables, i.e., in matrix form

d dt

u v =

0 1

ω02 0 u

v

All frequency domain and energy analysis can be applied to this equivalent system. Though first-order systems will come up only rarely in this book, it is worth being aware of such

A FINITE DIFFERENCE SCHEME 49 systems, as many time-integration techniques, including the ubiquitous Runge– Kutta family of methods and wave digital filters [127], are indeed usually presented with reference to first-order systems. In the distributed case, the important “finite difference time domain” family of methods [351] is also usually applied to first-order systems, such as the defining equations of electromagnetism.

3.1.4 Coupled systems of oscillators

Coupled second-order ODE systems occur frequently in finite element analysis, and, in musical sound synthesis, directly as descriptions of the dynamics of lumped networks, as per Section 1.2.1;

what often remains, after spatial discretization of a distributed system, is a matrix equation of the form

Md2

dt2u= −Ku (3.9)

whereuis anN×1 column vector, andMandKare known as, respectively, theN×N mass and stiffness matrices, which are (at least for linear and time-invariant problems) constants.Mis normally diagonal, andKis usually symmetric, reflecting reciprocity of forces acting within the system defined by (3.9). If the productM−1Kexists and is diagonalizable, withM−1K=UU−1, then the system may be immediately decoupled as

d2

dt2v= −v (3.10)

where u=Uv, and is the diagonal matrix containing the eigenvalues of M−1K, which are normally real and non-negative. The system (3.9) will then haveN frequenciesωp(which are not necessarily distinct), given by

ωp=

p,p for p=1, . . . , N (3.11)

Energy analysis also extends to systems such as (3.9). Left-multiplying by the row vector duT/dt, where superscriptT indicates a transposition operation, gives

duT dt Md2u

dt2 +duT dt Ku=0 or, using the symmetry ofMandK,

dH

dt =0 with H=T+V and T=1 2

duT dt Mdu

dt V= 1

2uTKu If M and K are positive definite, then the energy Hwill also be non-negative, and bounds on solution size may be derived as in the case of a single oscillator.

Lumped network approaches to sound synthesis, mentioned in Section 1.2.1, are built, essen-tially, around such coupled oscillator systems. The numerical treatment of such systems will appear later in Section 3.4. See Problems 3.2 and 3.3 for some simple concrete examples of coupled oscillators.

Dans le document Numerical Sound Synthesis (Page 57-60)