Geometric-integration tools for the simulation of musical sounds

  • Ai Ishikawa
  • Dominik L. Michels
  • Takaharu Yaguchi
Open Access
Original Paper Area 2
  • 260 Downloads

Abstract

During the last decade, much attention has been given to sound rendering and the simulation of acoustic phenomena by solving appropriate models described by Hamiltonian partial differential equations. In this contribution, we introduce a procedure to develop appropriate tools inspired from geometric integration in order to simulate musical sounds. Geometric integrators are numerical integrators of excellent quality that are designed exclusively for Hamiltonian ordinary differential equations. The introduced procedure is a combination of two techniques in geometric integration: the semi-discretization method by Celledoni et al. (J Comput Phys 231:6770–6789, 2012) and symplectic partitioned Runge–Kutta methods. This combination turns out to be a right procedure that derives numerical schemes that are effective and suitable for computation of musical sounds. By using this procedure we derive a series of explicit integration algorithms for a simple model describing piano sounds as a representative example for virtual instruments. We demonstrate the advantage of the numerical methods by evaluating a variety of numerical test cases.

Keywords

Acoustic phenomena Acoustic simulation Geometric integration Musical sounds Partitioned Runge–Kutta methods Separable Hamiltonian system Sound rendering Sound simulation Symplectic integration Virtual instruments Virtual piano 

Mathematics Subject Classification

37M15 65P10 65M06 

1 Introduction

We introduce a systematic procedure inspired from geometric integration in order to simulate musical sounds. In this context, we consider a piano model as a representative example for virtual instruments. The piano sounds are computed by integrating a Hamiltonian partial differential equation (PDE) model describing the oscillations of the string and an ordinary differential equation (ODE) model describing the dynamics of the hammer. The procedure has its basis on the semi-discretization method by Celledoni et al. [13], which semi-discretizes the PDE to a system of ODEs while preserving the Hamiltonian structure. This method allows the application of geometric integrators, which are numerical integrators with excellent quality for Hamiltonian ODEs. Symplectic partitioned Runge–Kutta methods are particularly focused on because they yield explicit numerical schemes for a certain class of Hamiltonian systems. The Hamiltonian systems in the class are called separable Hamiltonian systems, whose Hamiltonian is nicely divided into a sum of two functions. Fortunately, most DE models in sound synthesis are of this type. One example of such models is a model of bar vibrations
$$\begin{aligned}&u_t=v, \quad v_{t}=\gamma _s^2(u_{xx}-\psi _x), \\&\psi _t=\epsilon ^2\phi , \quad \epsilon ^2\phi _{t}=\epsilon ^2\gamma _l^2\psi _{xx}+\gamma _s^2(u_x-\psi ), \quad (x\in [0,1]) \\&H(u,\psi ,v,\phi )=\int _0^1 \left[ \frac{1}{2}v^2+\frac{\varepsilon ^2}{2}\phi ^2+\frac{\varepsilon ^2\gamma _l^2}{2}\psi _x^2+\frac{\gamma _s^2}{2}(u_x-\psi )^2\right] \mathrm {d}x, \end{aligned}$$
where u is the transverse displacement of the bar, \(\psi \) is the rotation of the bar cross-section relative to the normal, v and \(\phi \) are the corresponding velocity to u and \(\psi \) and \(\gamma _l\), \(\gamma _s\), \(\varepsilon \in {\mathbb {R}}\). Another example is the Webster equation [30] which is a model of sound waves in vocal tracts or bodies of wind instruments
$$\begin{aligned}&Sp_t=\gamma u_x, \quad \frac{1}{S}\,u_t=-\gamma p_x, \quad (x\in [0,1])\\&H(p,u)=\frac{\gamma }{2} \int _0^1 \left[ Sp^2+\frac{1}{S}\,u^2 \right] \mathrm {d}x, \end{aligned}$$
where the pressure in the tube are denoted with p, the volume velocity in it with u, the function of x describing the cross-section area of the tube with S and \(\gamma \in {\mathbb {R}}\). Other examples are introduced, for example, in [9]. In this contribution, we illustrate that the combination of the above two techniques in geometric integration is a right procedure for designing numerical schemes for computation of sound waves, in that the procedure indeed facilitates the design of stable numerical schemes for the simulation of musical instruments.

First, we briefly summarize the recent developments in the field of musical sound synthesis as well as the difficulties, and illustrate their connections to geometric integration.

In the past decade, large efforts have been devoted to the simulation of acoustic effects and sounds. In the context of special effects or more general in computer-generated movies, this is simply motivated by the fact that traditional computational physics simulations usually lead to silent movies, because no practical algorithms existed for synthesizing synchronized sounds automatically. Instead, sound recordings were edited manually during the animation process or triggered automatically in interactive applications. Since the former is inflexible and labor intensive and the latter one produces dreary and repetitive results, researchers have investigated on this; see e.g. [32, 34]. Furthermore, the simulation of sounds is well motivated due to the interest in the development of virtual instruments. Such digital devices would be superior to the conventional real musical instruments. For example according to [52] they would be less expensive because different instruments would be able to share a common input device; e.g. a virtual flute would be able to produce sounds of any kind of wind instruments. This makes it affordable for a variety of people enriching their creative work. Also, tuning and any other kind of labor intensive maintaining would not be necessary and the transportation of large and sensitive instruments can be avoided and location-based constraints therefore easily resolved—people from different places can join a common virtual orchestra.

The conventional approach to sound synthesis of musical instruments is based on signal processing-related techniques (e.g. [1, 2, 52, 55]). This is currently an established way of musical sound synthesis because the produced sounds are fairly well perceptually and the algorithms are computationally efficient, so that digital interactive sound systems working in real-time can be developed. Although this approach has achieved a great success, it comes with significant shortcomings: the models have no definite physical interpretation and the quality of sounds is often less than satisfactory. In particular, the unpredictable sounds produced by the non-linear interaction between the input devices (e.g. the hammers in the case of a piano) and the instruments (e.g. the strings and the bodies of the piano) are not successfully reproduced. These difficulties can be resolved using sound synthesis based on appropriate physical models of virtual musical instruments. One of the most significant approaches is the one where the motion of the fundamental components of the instruments is described by differential equations (e.g. strings, hammers, and bows). Compared to the conventional approaches inspired by signal processing, the parameters in these models directly represent physical features of the instruments (e.g. the material of the body). Appropriate fitting parameters can be integrated, which enables the design of more realistic models. Previous research in this direction includes the modeling and simulation of the hammer [11, 12, 19, 53], the key action [31, 44, 45, 48, 49], string vibrations [3, 4, 5, 17, 18, 54], and the soundboard [20, 21, 36]. The interactions between the components are also considered in the literature; in particular, Chabassier et al. established a model and a numerical method for simulation of the whole piano [14, 16].

The research on sound synthesis using PDEs is still at the beginning and there are many open problems. In this contribution, we address the challenging development of efficient and high-quality numerical integration algorithms for such models. This is a difficult task, because the auditory area of human beings is approximately between 20 and 20,000 Hz, for which reason the computation of thousands of vibrations is required for a sound of just a few seconds. Assume, that this sound wave is generated from a string with both ends fixed on the body of an instrument so that the vibration of the string is modeled by the wave equation under Dirichlet boundary conditions
$$\begin{aligned}&u_{tt} - c^2 u_{xx} = 0, \quad x \in (0, L)\\&u(t, 0) = u(t, L) = 0, \end{aligned}$$
where u is the amplitude of the vibration and c is the speed of the wave. Then each peak of the sound wave corresponds to one periodic motion of the wave packet; see Fig. 1. In typical numerical computations of the wave equation, just one period of the periodic motion is of interest because the behavior of the waves is almost the same in each of the repetitions. However, in the simulation of sound we need to compute thousands of periods of the motion. In other words, the simulation of sound waves requires a long-time calculation compared to the time scale of the phenomena. In those cases, numerical methods must be carefully designed because conventional ones usually result in unstable or meaningless solutions.
In this context, one of the most successful approaches is the energy-based one by Bilbao et al. (e.g. [7, 8, 9, 10, 11, 15]), which made a breakthrough in this area. Their numerical schemes are designed in a way, that a discrete approximation of the total energy of the system is exactly preserved. Because the energy often dominates the norm of the solution, the preservation of the energy results in a bound of the numerical solution. Hence this way of construction makes the resulting schemes stable and long-time calculations possible.
Fig. 1

Illustration of an example of computed sound waves for 0.01 s generated from a string of a piano (left) and the motion of the whole string for the same period (right). There are approximately three periods observed. Because the motion of the string for each period is almost identical, typically, just one motion period is computed

The aim of this contribution is to introduce a procedure that automatically derives numerical schemes with such a property. The key tools are from geometric integration, which is briefly explained below.

Long-time computations are also required in other research areas such as electromagnetics, quantum theory, fluid-, electro- and molecular dynamics, plasma transport, and celestial mechanics. In such areas so-called geometric integrators are employed to solve the occurring ordinary, partial, or stochastic differential equations derived from Hamiltonian mechanics. These methods typically discretize the underlying equations while preserving the mechanical and/or the geometric structure of the differential equations. As an example, the discrete gradient method is a method to derive energy-conservative and energy-dissipative numerical schemes for the Hamilton equation and the gradient flows, respectively (e.g. [27, 28, 43, 46]). A similar method for PDEs also exists, which is called the discrete variational derivative method (e.g. [22, 23, 24, 26]). Other examples are symplectic integrators, which are numerical methods that preserve the symplecticity of the Hamiltonian flow in the discrete setup. The application of a backward error analysis shows that numerical solutions of these methods are the same as solutions of the Hamilton equation which is an approximation of the original equation [47]. As a consequence, energy conservation laws and other similar conservation laws (e.g. the conservation of the linear and the angular momentum) are approximately preserved by these methods, which leads to a globally accurate behavior. Because of these conservation laws, such algorithms often outclass conventional numerical methods in stability and reproducibility of significant phenomena.

In this regard, the goal of our work is the development of efficient geometric integrators for the models for musical instruments. The key observation is that most PDE models for musical instruments are separable Hamiltonian systems. Therefore, as explained in the first paragraph of this section, symplectic partitioned Runge–Kutta methods give explicit and hence efficient integrators for these systems. In order to apply symplectic partitioned Runge–Kutta methods, the models must be semi-discretized to ODEs while preserving the separable Hamiltonian structure. To achieve this, we focus our attention on the semi-discretization method, which we call the variational semi-discretization, by Celledoni et al. [13]. The variational semi-discretization is originally proposed as a method for deriving a suitable semi-discrete scheme for designing numerical schemes that preserve a certain energy behavior. However, as suggested in [13], this method could be used also for deriving semi-discrete schemes for Hamiltonian systems while preserving the Hamiltonian structure. The procedure introduced in this contribution is a combination of this semi-discretization method and symplectic partitioned Runge–Kutta methods. This procedure automatically derives explicit and symplectic integrators for most models for musical instruments. In this contribution, we illustrate this procedure by applying it to a simple model of the piano to develop symplectic numerical methods.

Remark 1

A similar, but slightly different semi-discretization is obtained by the discrete variational derivative method (DVDM) [22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42]. The DVDM derives energy-preserving or -dissipative numerical schemes for a certain class of PDEs. Taking the limit of the scheme for the Hamilton PDEs by the DVDM as the time step size goes to 0 yields the semi-discretized Hamilton ODEs in principle. The difference between these two approaches is the treatment of the boundary conditions. In the variational semi-discretization, the boundary conditions are included in the definition of the discrete phase space, and hence semi-discretized schemes by this approach are always Hamiltonian. On the other hand, in the DVDM appropriate discrete boundary conditions are assumed; that is, discrete boundary conditions that are compatible with the method must be imposed.

This paper is organized as follows. In Sect. 2 the model of the piano is described. In Sect. 3 we explain the variational semi-discretization, which is the technique to derive a semi-discrete scheme while preserving the Hamiltonian structure of the equation. We apply this approach to the piano model for illustration reasons. After that, we develop several symplectic numerical methods by applying symplectic Runge–Kutta methods in Sect. 4.

2 Mathematical model for virtual pianos

Pianos are composed of many distinct parts, such as strings, hammers, black and white keys, and a sounding board. Although an excellent model that consists of most of these parts was recently proposed in [14, 16], we use a rather simplified model, which only consists of a string part and a hammer part. This is because the aim of this paper is not the development of a realistic piano model but the introduction of a way to automatically get a simulation method that comprises an arbitrary geometric integrator.

The model we use in this study consists of a wave-type equation
$$\begin{aligned}&{\left\{ \begin{array}{ll} u_t = v, \\ v_{t} = c^2 u_{xx} - \kappa ^2 u_{xxxx} - d_1 u_t + d_3 u_{txx} + \varepsilon f_\mathrm {h}, \end{array}\right. } \end{aligned}$$
(1)
for the motion of a string, and the mass-spring model
$$\begin{aligned} {\left\{ \begin{array}{ll} \displaystyle \frac{\mathrm {d}u_\mathrm {h}}{\mathrm {d}t} = v_\mathrm {h}, \\ \\ \displaystyle \frac{\mathrm {d}v_\mathrm {h}}{\mathrm {d}t} = -\frac{1}{M_\mathrm {h}}f_\mathrm {h}({u,u_\mathrm {h}, v,v_\mathrm {h}}), \end{array}\right. } \end{aligned}$$
(2)
for the hammer’s motion. These models are typical for piano simulations. The string displacement and the velocity are denoted with u(tx) and v(tx) respectively, the wave speed with c, the stiffness with \(\kappa \), the frequency independent damping coefficient with \(d_1\) and the frequency dependent damping coefficient with \(d_3\). Similarly, the displacement, the velocity and the mass of the hammer are denoted with \(u_\mathrm {h}\), \(v_\mathrm {h}\) and \(M_\mathrm {h}\). We assume that all the coefficients are positive. Since the ends of the string are fixed to the piano body, we assume the boundary conditions
$$\begin{aligned} u(t, 0) = u(t, L) = u_{xx}(t, 0) = u_{xx}(t, L) = 0. \end{aligned}$$
(3)
More practical boundary conditions are provided e.g. in [56]. The non-linear interaction between the hammer and the string is specified using the function
$$\begin{aligned} f_\mathrm {h}(u,u_\mathrm {h}, v,v_\mathrm {h}) = -K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^\alpha (1+\mu v_\mathrm {r}), \quad v_\mathrm {r} = \left\langle \varepsilon , v \right\rangle - v_\mathrm {h}, \end{aligned}$$
where we denote the felt stiffness coefficient with \(K_\mathrm {h}\), the hammer stiffness exponent with \(\alpha \) and the felt loss coefficient with \(\mu \). These coefficients also have a positive value. Here, \(\varepsilon (x)\) determines the hammer-string collision profile and satisfies \(\langle \varepsilon , 1 \rangle =1\) so that \(\varepsilon (x)\) becomes an approximation to the delta function. The expression \([ \xi ]^+\) is defined by
$$\begin{aligned}{}[ \xi ]^+ = {\left\{ \begin{array}{ll} \xi , &{} (\xi > 0) \\ 0, &{} (\text{ otherwise }) \end{array}\right. } \end{aligned}$$
and \(\langle \varepsilon , u\rangle \) denotes the \(L^2\) inner product
$$\begin{aligned} \langle \varepsilon , u\rangle := \int _0^L \varepsilon (x) u(t, x) \mathrm {d}x. \end{aligned}$$
The estimated values of the parameters for the C4 tone are listed in Tables 1 and 2. For parameters of other tones we refer e.g. to [3, 4, 18].
Table 1

Estimated parameter values used in [4] to describe the hammer model

Symbol

Definition

Estimated value

\(M_\mathrm {h}\)

Mass of the Hammer

\(5.687 \times 10^{-3}\)

\(K_\mathrm {h}\)

Felt stiffness coefficient

\(1.51647 \times 10^{9}\)

\(\alpha \)

Hammer stiffness exponent

2.56

\(\mu \)

Felt loss coefficient

0.1998

Table 2

Estimated parameter values used in [4] to specifying the C4 tone

Symbol

Definition

Estimated value

L

Length of the string

0.63

c

Wave speed

329.6

\(\kappa \)

String stiffness coefficient

1.25

\(d_1\)

Frequency independent damping coefficient

1.1

\(d_3\)

Frequency dependent damping coefficient

\(2.7 \times 10^{-4}\)

As it is shown below, when the damping terms are ignored, that is, \(\mu =\mathrm {d}_1=\mathrm {d}_3=0\), the above model is a separable Hamiltonian system, which is a system with a remarkable Hamiltonian structure from a viewpoint of numerical analysis. As explained in Sect. 4, this special Hamiltonian structure allows us to design explicit symplectic numerical methods.

To illustrate the Hamiltonian structure of this system, we introduce \(p_\mathrm {h}:= M_\mathrm {h}v_\mathrm {h}\), and an energy function
$$\begin{aligned}&{{H}}(u, v, {u}_\mathrm {h}, {p}_\mathrm {h})\nonumber \\&= \int _0^L \left[ \frac{1}{2} v^2 + \frac{c^2}{2 } u_x^2 + \frac{\kappa ^2}{2 } u_{xx}^2 \right] \mathrm {d}x + \frac{1}{2M_\mathrm {h}} {p_\mathrm {h}}^2 + \frac{K_\mathrm {h}}{\alpha + 1} ([ \langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha +1}. \end{aligned}$$
(4)
This is a separable Hamiltonian in the sense that \({{H}}\) is written as a sum of two functions:
$$\begin{aligned} {{H}}(u, v, {u}_\mathrm {h}, {p}_\mathrm {h})&= T(v, p_\mathrm {h}) + U(u, u_\mathrm {h}), \\ T(v, p_\mathrm {h})&= \int _0^L \left[ \frac{1}{2} v^2 \right] \mathrm {d}x + \frac{1}{2M_\mathrm {h}} {p_\mathrm {h}}^2, \\ U(u, u_\mathrm {h})&= \int _0^L \left[ \frac{c^2}{2 } u_x^2 + \frac{\kappa ^2}{2 } u_{xx}^2 \right] \mathrm {d}x + \frac{K_\mathrm {h}}{\alpha + 1} ([ \langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha +1}. \end{aligned}$$
Then it is straightforward to check the following theorem.

Theorem 1

The model (1, 2) is equivalent to
$$\begin{aligned} \begin{pmatrix} u_t \\ \dot{u}_\mathrm {h}\\ v_t \\ \dot{p}_\mathrm {h}\end{pmatrix}&= \begin{pmatrix} \phantom {-}0 &{} \phantom {-}0 &{} 1 &{} 0\\ \phantom {-}0 &{} \phantom {-}0 &{} 0 &{} 1\\ -1 &{} \phantom {-}0 &{} 0 &{} 0 \\ \phantom {-}0 &{} -1 &{} 0 &{} 0 \end{pmatrix} \,\, \begin{pmatrix} \frac{\delta {{H}}}{\delta u}&\frac{\partial {{H}}}{\partial u_\mathrm {h}}&\frac{\delta {{H}}}{\delta v}&\frac{\partial {{H}}}{\partial p_\mathrm {h}} \end{pmatrix}^\top \\&\qquad +\begin{pmatrix} 0 \\ 0 \\ -d_1 v + d_3 v_{xx} -\varepsilon K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^\alpha \mu v_\mathrm {r} \\ {K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^\alpha \mu v_\mathrm {r}} \end{pmatrix} \\&= \begin{pmatrix} v \\ \frac{p_\mathrm {h}}{M_\mathrm {h}} \\ c^2 u_{xx} - \kappa ^2 u_{xxxx} - {\varepsilon K_\mathrm {h}} ([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^\alpha (1 + \mu v_\mathrm {r}) - {d_1} v + {d_3} v_{xx} \\ K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^\alpha (1+\mu v_\mathrm {r}) \end{pmatrix}. \end{aligned}$$
Moreover, if the damping coefficients \(\mu , d_1\) and \(d_3\) vanish, the system is a separable Hamiltonian system.

We show the energy behavior of this model in the following theorem.

Theorem 2

Under the boundary conditions (3), the energy function \({{H}}\) is not increasing:
$$\begin{aligned} \frac{\mathrm {d}{{H}}}{\mathrm {d}t} =&- \mu v_\mathrm {r}^2 K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } - d_1 \int _0^L v^2 \,\mathrm {d}x - d_3 \int _0^L v_x^2 \,\mathrm {d}x \le 0. \end{aligned}$$
Moreover, if \(\mu = d_1 = d_3 = 0\), the system is conservative.

Proof

From the integration by parts and the boundary conditions \(u(t, 0)=u_{xx}(t, 0)=u(t, L)=u_{xx}(t, L)=0\), we obtain
$$\begin{aligned} \frac{\mathrm {d}{{H}}}{\mathrm {d}t} =&\int _0^L \left[ v v_t - c^2 u_{xx} u_t + \kappa ^2 u_{xxxx} u_t + K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } \varepsilon u_t \right] \mathrm {d}x \\&+ \left[ c^2 u_x u_t \right] _0^L + \left[ \kappa ^2 u_{xx} u_{xt} \right] _0^L - \left[ \kappa ^2 u_{xxx} u_{t} \right] _0^L + \frac{p_\mathrm {h}}{M_\mathrm {h}}{\dot{p}_\mathrm {h}} - K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } \dot{u}_\mathrm {h}\\ =&\int _0^L \left[ v v_t - c^2 u_{xx} u_t + \kappa ^2 u_{xxxx} u_t + K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } \varepsilon u_t \right] \mathrm {d}x \\&+ \frac{p_\mathrm {h}}{M_\mathrm {h}}{\dot{p}_\mathrm {h}} - K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } \dot{u}_\mathrm {h}. \end{aligned}$$
Substitution leads to
$$\begin{aligned} \frac{\mathrm {d}{{H}}}{\mathrm {d}t} =&\int _0^L \left[ v_t - c^2u_{xx} + \kappa ^2 u_{xxxx}+\varepsilon K_\mathrm {h}([\langle \varepsilon ,u \rangle -u_\mathrm {h}]^+)^\alpha ) \right] v \mathrm {d}x \\&+ \frac{p_\mathrm {h}}{M_\mathrm {h}} K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } (1 + \mu v_\mathrm {r}) - K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } \frac{p_\mathrm {h}}{M_\mathrm {h}} \\ =\,\,&\mu v_\mathrm {r}\frac{p_\mathrm {h}}{M_\mathrm {h}} K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } - \mu v_\mathrm {r}\langle \varepsilon , v \rangle K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } \\&- d_1 \int _0^L v^2 \,\mathrm {d}x + d_3 \int _0^L v v_{xx} \,\mathrm {d}x. \end{aligned}$$
Because \(v_\mathrm {r}= \langle \varepsilon , v\rangle - p_\mathrm {h}/M_\mathrm {h}\) holds and the boundary condition implies \(v(t, 0) = v(t, L) = 0\), we obtain
$$\begin{aligned} \frac{\mathrm {d}{{H}}}{\mathrm {d}t} =&- \mu v_\mathrm {r}^2 K_\mathrm {h}([\langle \varepsilon , u\rangle - u_\mathrm {h}]^+)^{\alpha } - d_1 \int _0^L v^2 \,\mathrm {d}x - d_3 \int _0^L v_x^2 \,\mathrm {d}x \le 0. \end{aligned}$$
\(\square \)

3 Variational semi-discretization and the application to the piano model

In order to make use of geometric integrators, a spatial discretization that preserves the Hamiltonian structure is required. The semi-discretization is typically done by replacing the spatial differential operators in the target equation by spatial difference operators, or using the finite element method. However, the resulting scheme does not always admit the Hamiltonian structure by using such approaches. To avoid the absence of the Hamiltonian structure, we use the variational semi-discretization [13] where the Hamiltonian is first discretized and then a semi-discrete scheme is obtained by variational calculus (see Fig. 2). This process automatically leads to a semi-discrete Hamiltonian scheme.
Fig. 2

This diagram shows the core idea of the variational semi-discretization. In typical approaches (shown by the dashed lines) the equation is directly discretized and hence the Hamiltonian structure may not be preserved. Instead, in this approach (shown by the solid lines) the Hamiltonian is discretized first and then the semi-discrete scheme is obtained as the Hamilton equation. This procedure automatically leads to a Hamiltonian semi-discrete scheme

In what follows, for illustration purpose this procedure is applied to the Hamilton equation describing the piano model without the damping terms. We use a uniform mesh with a step size \(\varDelta x=L/N\) so that \(N+1\) equals to a total number of points in the interval [0, L], and denote the approximated value of \(p(t, l\varDelta x)\) with \(p_l(t)\), or \(p_l\) by omitting the argument t. We also denote a forward, a backward and a second difference operator with
$$\begin{aligned} \delta _x^+ q_l = \frac{q_{l+1}-q_l}{\varDelta x}, \quad \delta _x^- q_l = \frac{q_l-q_{l-1}}{\varDelta x}\quad \text{ and } \quad \delta _x^{\langle 2\rangle } q_l = \frac{q_{l+1}-2q_l+q_{l-1}}{\varDelta x^2}, \end{aligned}$$
respectively. We first consider the phase space:
$$\begin{aligned} \tilde{\mathscr {X}}{:=}\{ \tilde{\varvec{u}}\in {\mathbb {R}}^{N+3}\mid \tilde{\varvec{u}} = ({\tilde{u}}_{-1} \ {\tilde{u}}_0 \ {\tilde{u}}_1 \ \cdots \ {\tilde{u}}_{N-1} \ {\tilde{u}}_{N} \ {\tilde{u}}_{N+1} )^\top \}. \end{aligned}$$
(5)
For \(\tilde{\varvec{u}}\), \(\tilde{\varvec{v}} \in \tilde{\mathscr {X}}\), we define the discrete Hamiltonian \({{\tilde{H}}}_\mathrm {d}\) in \(\tilde{\mathscr {X}}\) using the trapezoidal rule to approximate the integral in H:
$$\begin{aligned}&{{\tilde{H}}}_\mathrm {d}(\tilde{\varvec{u}}, \tilde{\varvec{v}}, u_\mathrm {h}, p_\mathrm {h})\nonumber \\&=\left[ \frac{1}{2}v_0^2 + \frac{c^2}{2} \frac{\left( \delta _x^+u_0 \right) ^2 + \left( \delta _x^-u_0 \right) ^2}{2} + \frac{\kappa ^2}{2}\left( \delta _x^{\langle 2\rangle }u_0 \right) ^2 \right] \frac{\varDelta x}{2}\nonumber \\&\quad +\sum _{l=1}^{N-1} \left[ \frac{1}{2}v_l^2 + \frac{c^2}{2} \frac{\left( \delta _x^+u_l \right) ^2 + \left( \delta _x^-u_l \right) ^2}{2} +\frac{\kappa ^2}{2}\left( \delta _x^{\langle 2\rangle }u_l \right) ^2 \right] \varDelta x \nonumber \\&\quad + \left[ \frac{1}{2}v_N^2 + \frac{c^2}{2} \frac{\left( \delta _x^+u_N \right) ^2 + \left( \delta _x^-u_N \right) ^2}{2} + \frac{\kappa ^2}{2}\left( \delta _x^{\langle 2\rangle }u_N \right) ^2 \right] \frac{\varDelta x}{2}\nonumber \\&\quad +\frac{1}{2M_\mathrm {h}}p_\mathrm {h}^2 + \frac{K_\mathrm {h}}{\alpha +1}\left( [\langle \varvec{\varepsilon }, \tilde{\varvec{u}} \rangle _{\tilde{\mathscr {X}}} -u_\mathrm {h}]^{+} \right) ^{\alpha +1}, \end{aligned}$$
(6)
where \(\varvec{\varepsilon }\in \tilde{\mathscr {X}}\) is an approximation of the function \(\varepsilon (x)\) and \(\langle \cdot , \cdot \rangle _{\tilde{\mathscr {X}}}\) means
$$\begin{aligned} \langle \tilde{\varvec{u}}, \tilde{\varvec{v}} \rangle _{\tilde{\mathscr {X}}}={\tilde{u}}_0 {\tilde{v}}_0\frac{\varDelta x}{2}+\sum _{l=1}^{N-1} {\tilde{u}}_l {\tilde{v}}_l \varDelta x + {\tilde{u}}_N {\tilde{v}}_N\frac{\varDelta x}{2} \end{aligned}$$
(7)
for \(\tilde{\varvec{u}}, \tilde{\varvec{v}} \in \tilde{\mathscr {X}}\).

Remark 2

Regarding the approximation to the term \(u_x\) in H, we chose
$$\begin{aligned} u_x(t,l\varDelta x)^2\approx \frac{(\delta _x^+u_l)^2+(\delta _x^-u_l)^2}{2}, \end{aligned}$$
which is a typical choice in [26]; however, we can also use, for example, the central difference and define the Hamiltonian as
$$\begin{aligned}&\tilde{{\tilde{H}}}_\mathrm {d}(\tilde{\varvec{u}}, \tilde{\varvec{v}}, u_\mathrm {h}, p_\mathrm {h})\nonumber \\&=\left[ \frac{1}{2}v_0^2 + \frac{c^2}{2} \left( \frac{\delta _x^++\delta _x^-}{2}u_0\right) ^2 + \frac{\kappa ^2}{2}\left( \delta _x^{\langle 2\rangle }u_0 \right) ^2 \right] \frac{\varDelta x}{2}\nonumber \\&\quad +\sum _{l=1}^{N-1} \left[ \frac{1}{2}v_l^2 + \frac{c^2}{2} \left( \frac{\delta _x^++\delta _x^-}{2}u_l\right) ^2 +\frac{\kappa ^2}{2}\left( \delta _x^{\langle 2\rangle }u_l \right) ^2 \right] \varDelta x \nonumber \\&\quad + \left[ \frac{1}{2}v_N^2 + \frac{c^2}{2} \left( \frac{\delta _x^++\delta _x^-}{2}u_N\right) ^2 + \frac{\kappa ^2}{2}\left( \delta _x^{\langle 2\rangle }u_N \right) ^2 \right] \frac{\varDelta x}{2}\nonumber \\&\quad +\frac{1}{2M_\mathrm {h}}p_\mathrm {h}^2 + \frac{K_\mathrm {h}}{\alpha +1}\left( [\langle \varvec{\varepsilon }, \tilde{\varvec{u}} \rangle _{\tilde{\mathscr {X}}} -u_\mathrm {h}]^{+} \right) ^{\alpha +1}. \end{aligned}$$
As is pointed out in pp. 90–91 of [26], it is difficult to judge whether a choice of the approximations of H defines a useful scheme or not, because it depends on the equation and possibly on other factors. Hereinafter we mainly use \({{\tilde{H}}}_\mathrm {d}\) as the discrete Hamiltonian because it is found from the numerical tests, which are shown in Fig. 4 in Sect. 4, that the numerical solutions derived by using \(\tilde{{{\tilde{H}}}}_\mathrm {d}\) converge to the exact ones slower than that derived by using \({{{\tilde{H}}}}_\mathrm {d}\).
The boundary conditions corresponding to (3) are imposed by
$$\begin{aligned} u_0=u_N=0, \quad u_{1}=-u_{-1}, \quad \text{ and } \quad u_{N-1}=-u_{N+1}, \end{aligned}$$
(8)
and by using them, we can rewrite \({{\tilde{H}}}_\mathrm {d}\) without the boundary terms \(u_{-1}\), \(u_0\), \(u_N\) and \(u_{N+1}\).
This is equivalent to the restriction of \({{\tilde{H}}}_\mathrm {d}\) to the subspace of \(\tilde{\mathscr {X}}\):
$$\begin{aligned} {\mathscr {X}} = \{ \varvec{u} \in \tilde{\mathscr {X}} \mid u_0=u_{N}=0, \quad u_{1}=-u_{-1}, \quad u_{N-1}=-u_{N+1} \} \simeq {\mathbb {R}}^{N-1}. \end{aligned}$$
We denote this restricted discrete Hamiltonian with \(H_\mathrm {d}\). For \(\varvec{u}\), \(\varvec{v} \in \mathscr {X}\), \(H_\mathrm {d}\) is defined as
$$\begin{aligned}&H_\mathrm {d}(\varvec{u}, \varvec{v}, u_\mathrm {h}, p_\mathrm {h})\nonumber \\&\quad = \left[ \frac{c^2}{2} \left( \frac{u_1}{\varDelta x} \right) ^2 \right] \frac{\varDelta x}{2} \nonumber \\&\quad + \left[ \frac{c^2}{2} \frac{\left( \delta _x^+u_1 \right) ^2 + \left( u_1/\varDelta x \right) ^2}{2} + \frac{\kappa ^2}{2} \left( \frac{u_2-2u_1}{\varDelta x^2} \right) ^2 \right] \varDelta x \nonumber \\&\quad + \sum _{l=2}^{N-2} \left[ \frac{c^2}{2} \frac{\left( \delta _x^+u_l \right) ^2 + \left( \delta _x^-u_l \right) ^2}{2} +\frac{\kappa ^2}{2}\left( \delta _x^{\langle 2\rangle }u_l \right) ^2 \right] \varDelta x \nonumber \\&\quad + \left[ \frac{c^2}{2} \frac{\left( {u_{N-1}}/{\varDelta x} \right) ^2 + \left( \delta _x^-u_{N-1} \right) ^2}{2} +\frac{\kappa ^2}{2}\left( \frac{-2u_{N-1}+u_{N-2}}{\varDelta x^2} \right) ^2 \right] \varDelta x \nonumber \\&\quad + \left[ \frac{c^2}{2} \left( \frac{u_{N-1}}{\varDelta x} \right) ^2 \right] \frac{\varDelta x}{2} \nonumber \\&\quad +\sum _{l=1}^{N-1}\frac{1}{2}v_l^2\varDelta x+\frac{1}{2M_\mathrm {h}}p_\mathrm {h}^2 + \frac{K_\mathrm {h}}{\alpha +1}\left( [\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} -u_\mathrm {h}]^{+} \right) ^{\alpha +1}, \end{aligned}$$
(9)
where \(\langle \cdot , \cdot \rangle _{\mathscr {X}}\) means
$$\begin{aligned} \langle \varvec{u},\varvec{v}\rangle _{\mathscr {X}} = \sum _{l=1}^{N-1} u_lv_l \varDelta x\quad \hbox { for all }\quad \varvec{u} , \varvec{v}\in \mathscr {X}. \end{aligned}$$
(10)
We note that this is equivalent to (7) under the boundary condition (8).
We calculate the partial derivatives of \(H_\mathrm {d}\) to obtain the gradient in the Hamilton equation. The partial derivatives of \(H_\mathrm {d}\) with respect to \(u_l\) and \(v_l\) \((l=1,\ldots ,N-1)\) are
$$\begin{aligned} \frac{\partial H_\mathrm {d}}{\partial u_1}&= \Bigl \{ - c^2\frac{-2u_1+u_2}{\varDelta x^2} + \kappa ^2\frac{5u_1-4u_2+u_3}{\varDelta x^4} + \varepsilon _1 K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha \Bigr \}\varDelta x, \\ \frac{\partial H_\mathrm {d}}{\partial u_2}&= \Bigl \{ - c^2\frac{u_1-2u_2+u_3}{\varDelta x^2}+\kappa ^2\frac{-4u_1+6u_2-4u_3+u_4}{\varDelta x^4}\\&\quad + \varepsilon _2 K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha \Bigr \}\varDelta x,\\ \frac{\partial H_\mathrm {d}}{\partial u_l}&= \Bigl \{ - c^2\frac{u_{l-1}-2u_l+u_{l+1}}{\varDelta x^2} + \kappa ^2\frac{u_{l-2}-4u_{l-1}+6u_l-4u_{l+1}+u_{l+2}}{\varDelta x^4}\\&\quad + \varepsilon _l K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha \Bigr \}\varDelta x, \quad (l=3,4,\dots ,N-3) \\ \frac{\partial H_\mathrm {d}}{\partial u_{N-2}}&= \Bigl \{ - c^2\frac{u_{N-3}-2u_{N-2}+u_{N-1}}{\varDelta x^2} + \kappa ^2\frac{u_{N-4}-4u_{N-3}+6u_{N-2}-4u_{N-1}}{\varDelta x^4} \\&\quad + \varepsilon _{N-2} K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha \Bigr \}\varDelta x,\\ \frac{\partial H_\mathrm {d}}{\partial u_{N-1}}&= \Bigl \{ - c^2\frac{u_{N-2}-2u_{N-1}}{\varDelta x^2} + \kappa ^2\frac{ u_{N-3}-4u_{N-2}+5u_{N-1}}{\varDelta x^4} \\&\quad + \varepsilon _{N-1} K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha \Bigr \}\varDelta x, \\ \frac{\partial H_\mathrm {d}}{\partial v_l}&=v_l\varDelta x, \quad (l=1,2,\dots ,N-1) \end{aligned}$$
and the partial derivatives with respect to \(u_\mathrm {h}\) and \(p_\mathrm {h}\) are
$$\begin{aligned} \frac{\partial H_\mathrm {d}}{\partial u_\mathrm {h}}&=-K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha , \\ \frac{\partial H_\mathrm {d}}{\partial p_\mathrm {h}}&=\frac{p_\mathrm {h}}{M_\mathrm {h}}. \end{aligned}$$
We denote the difference matrices of order \(N-1\) with
$$\begin{aligned} D_2= \frac{1}{\varDelta x^2} \begin{pmatrix} -2 &{} 1 &{} &{} &{} \\ 1 &{} -2 &{} 1 &{} &{} \\ &{} \ddots &{} \ddots &{} \ddots &{} \\ &{} &{} 1 &{} -2 &{} 1 \\ &{} &{} &{} 1 &{} -2 \\ \end{pmatrix},\quad \ D_4= \frac{1}{\varDelta x^4} \begin{pmatrix} 5 &{} -4 &{} 1 &{} &{} &{} &{} \\ -4 &{} 6 &{} -4 &{} 1 &{} &{} &{} \\ 1 &{} -4 &{} 6 &{} -4 &{} 1 &{} &{} \\ &{} \ddots &{} \ddots &{} \ddots &{} \ddots &{} \ddots &{} \\ &{} &{} 1 &{} -4 &{} 6 &{} -4 &{} 1 \\ &{} &{} &{} 1 &{} -4 &{} 6 &{} -4 \\ &{} &{} &{} &{} 1 &{} -4 &{} 5 \\ \end{pmatrix}. \end{aligned}$$
The semi-discrete scheme is defined by the following separable Hamiltonian system:
$$\begin{aligned} \frac{\mathrm {d}}{\mathrm {d}t} \begin{pmatrix} \varvec{u} \\ u_\mathrm {h}\\ \varvec{v} \\ p_\mathrm {h}\end{pmatrix}&= \begin{pmatrix} &{}&{}I&{}\varvec{0}\\ &{}&{}{\varvec{0}}^\top &{}1\\ -I&{}\phantom {-}\varvec{0}&{}&{}\\ {\varvec{0}}^\top &{}-1&{}&{} \end{pmatrix} \,\, \begin{pmatrix} \nabla _{\varvec{u}} H_\mathrm {d}^\top&\nabla _{u_\mathrm {h}} H_\mathrm {d}&\nabla _{\varvec{v}} H_\mathrm {d}^\top&\nabla _{p_\mathrm {h}} H_\mathrm {d}\end{pmatrix}^\top \nonumber \\&=\begin{pmatrix} &{}&{}I&{}\varvec{0}\\ &{}&{}{\varvec{0}}^\top &{}1\\ -I&{}\phantom {-}\varvec{0}&{}&{}\\ {\varvec{0}}^\top &{}-1&{}&{} \end{pmatrix} \,\, \begin{pmatrix} -c^2 D_2 \varvec{u}+\kappa ^2D_4\varvec{u} + \varvec{\varepsilon }K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^{\alpha }\\ - K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha \\ \varvec{v}\\ \frac{p_\mathrm {h}}{M_\mathrm {h}} \end{pmatrix}, \end{aligned}$$
(11)
where \(\nabla _q H_\mathrm {d}\) means the gradient of \(H_\mathrm {d}\) in the q direction associated with the inner product (10). In the following theorem we address the energy behavior of this model.

Theorem 3

The semi-discretized Hamiltonian system (11) preserves the discretized energy function \(H_\mathrm {d}\) (9), i.e.
$$\begin{aligned} \frac{\mathrm {d}H_\mathrm {d}}{\mathrm {d}t}=0. \end{aligned}$$

Remark 3

This theorem is generalized to include the damping terms in Theorem 5, and a proof is given there.

4 Application of symplectic integrators

We apply symplectic partitioned Runge–Kutta (PRK) methods to (11) for illustration purpose. PRK methods are a series of numerical methods for equations of the form
$$\begin{aligned} \frac{\mathrm {d}y(t)}{\mathrm {d}t} =F(y(t), z(t)), \quad \frac{\mathrm {d}z(t)}{\mathrm {d}t}=G(y(t), z(t)). \end{aligned}$$
(12)

Definition 1

Let \(a_{ij}, \ b_i\), and \({\hat{a}}_{ij}, \ {\hat{b}}_i\) be the coefficients of two Runge–Kutta methods. Then, an s-stage PRK method for (12) with a step size \(\varDelta t\) is given by
$$\begin{aligned} k_i&=F\left( y^n+\varDelta t \sum _{j=1}^{s}a_{ij}k_j, z^n+\varDelta t \sum _{j=1}^{s}{\hat{a}}_{ij}l_j\right) , \nonumber \\ l_i&=G\left( y^n+\varDelta t \sum _{j=1}^{s}a_{ij}k_j, z^n+\varDelta t \sum _{j=1}^{s}{\hat{a}}_{ij}l_j\right) , \nonumber \\ y^{n+1}&=y^n+\varDelta t \sum _{i=1}^{s}b_ik_i, \quad z^{n+1}=z^n+\varDelta t \sum _{i=1}^{s}{\hat{b}}_il_i. \end{aligned}$$
(13)

As mentioned above, long-time computations are required for the simulation of musical sounds. For this reason, in addition to accuracy, we need to take long-term stability and computational efficiency into consideration. All these three requirements are fulfilled by the application of a special class of PRK methods. As explained before, if a method is symplectic, the method has superior long-term stability in most cases. The following theorem identifies the condition for PRK methods to be symplectic; see [33, 50, 51].

Theorem 4

(Symplectic Partitioned Runge–Kutta (SPRK) Method) An s-stage PRK method (13) is symplectic if it satisfies the conditions
$$\begin{aligned} {\left\{ \begin{array}{ll} b_i={\hat{b}}_i,\\ b_i {\hat{a}}_{ij}+{\hat{b}}_j a_{ji}-b_i{\hat{b}}_j=0, \end{array}\right. }\quad \hbox { for }\quad \ i=1, \dots , s, \quad j=1, \dots , s. \end{aligned}$$
The first condition is not necessary if the system is a separable Hamiltonian system.
Although the PRK method is available for any semi-discretized equation, the SPRK method requires the Hamiltonian structure for the equations. The semi-discretization in the way of Sect. 3 allows us to apply the SPRK method to any Hamiltonian PDEs. In addition, if carefully designed, symplectic and explicit methods can be designed for separable Hamiltonians; see [29]. These methods are not only being explicit. Moreover, they have a favourable implementation where no additional storage is necessary. We use the coefficients of Table 3 to achieve the above properties. A PRK method with these coefficients becomes symplectic and explicit for separable Hamiltonian systems. Following [50], we write the coefficients of Table 3 as
$$\begin{aligned} (b_1, b_2, \dots , b_s)[{\hat{b}}_1, {\hat{b}}_2, \dots , {\hat{b}}_s]. \end{aligned}$$
Furthermore, these coefficients enable us to use Algorithm 1 to reduce the amount of storage. In Algorithm 1, for example, \(Q_0\) can be overwritten on \(q^n\) and this applies also for other \(Q_i\)’s.
Table 3

The Butcher tableau of an s-stage SPRK method

In summary, when using model (11) and a PRK method with the coefficients shown in Table 3, the method becomes explicit and symplectic because of the separability of the Hamiltonian system. Furthermore using Algorithm 1 the method is implemented with small amount of storage.
We tested three numerical schemes for the computation of piano sounds. These schemes are obtained by applying the SPRK methods to
$$\begin{aligned}&\frac{\mathrm {d}}{\mathrm {d}t} \begin{pmatrix} \varvec{u}\\ u_\mathrm {h}\\ \varvec{v}\\ p_\mathrm {h}\end{pmatrix}= \begin{pmatrix} \phantom {-}O&II&O \end{pmatrix} \begin{pmatrix} {F(\varvec{u}, u_\mathrm {h},\varvec{v}, p_\mathrm {h})}\\ {G(\varvec{v}, p_\mathrm {h})} \end{pmatrix}, \\&\quad F({\varvec{u}, u_\mathrm {h},\varvec{v}, p_\mathrm {h}}) \nonumber \\&\quad := \begin{pmatrix} -c^2 D_2 \varvec{u}+\kappa ^2D_4\varvec{u}+\varvec{\varepsilon }K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^{\alpha }(1+\mu v_{\mathrm {r}, \mathrm {d}})+d_1\varvec{v}-d_3D_2\varvec{v}\\ -K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r}, \mathrm {d}}) \end{pmatrix},\nonumber \\&G({\varvec{v}, p_\mathrm {h}}):= \begin{pmatrix} \varvec{v}^\top&\frac{p_\mathrm {h}}{M_\mathrm {h}} \end{pmatrix}^\top ,\quad v_{\mathrm {r}, \mathrm {d}} := \langle \varvec{\varepsilon }, \varvec{v} \rangle _{\mathscr {X}} - \frac{p_\mathrm {h}}{M_\mathrm {h}}, \nonumber \end{aligned}$$
(14)
or, equivalently,
$$\begin{aligned} {\left\{ \begin{array}{ll} \dot{u}_l = v_l, \quad (l=1,2,\dots ,N-1)\\ \dot{u}_\mathrm {h}= \frac{p_\mathrm {h}}{M_\mathrm {h}},\\ \dot{v}_1 = c^2\frac{-2u_1+u_2}{\varDelta x^2} - \kappa ^2\frac{5u_1-4u_2+u_3}{\varDelta x^4}\\ \qquad \quad -\,\, \varepsilon _1 K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} -u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r},\mathrm {d}})-d_1v_1+d_3\frac{-2v_1+v_2}{\varDelta x^2},\\ \dot{v}_2 = c^2 \delta _x^{\langle 2\rangle }u_2 - \kappa ^2\frac{-4u_1+6u_2-4u_3+u_4}{\varDelta x^4}\\ \qquad \quad -\,\, \varepsilon _2 K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r},\mathrm {d}})-d_1v_2+d_3\delta _x^{\langle 2\rangle }v_2,\\ \dot{v}_l = c^2 \delta _x^{\langle 2\rangle }u_l - \kappa ^2 \delta _x^{\langle 4\rangle }u_l - \varepsilon _l K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r},\mathrm {d}})\\ \qquad \quad -\,\, d_1 v_l + d_3\delta _x^{\langle 2\rangle }v_l, \quad (l=3,\ldots ,N-3)\\ \dot{v}_{N-2} = c^2 \delta _x^{\langle 2\rangle }u_{N-2} - \kappa ^2\frac{u_{N-4}-4u_{N-3}+6u_{N-2}-4u_{N-1}}{\varDelta x^4} \\ \qquad \quad -\,\, \varepsilon _{N-2} K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r},\mathrm {d}}) - d_1 v_{N-2} + d_3 \delta _x^{\langle 2\rangle }v_{N-2},\\ \dot{v}_{N-1} = c^2\frac{u_{N-2}-2u_{N-1}}{\varDelta x^2} - \kappa ^2\frac{u_{N-3}-4u_{N-2}+5u_{N-1}}{\varDelta x^4} \\ \qquad \quad -\,\, \varepsilon _{N-1} K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} -u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r},\mathrm {d}}) - d_1 v_{N-1} + d_3 \frac{v_{N-2}-2v_{N-1}}{\varDelta x^2},\\ \dot{p}_\mathrm {h}= K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} -u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r},\mathrm {d}}), \end{array}\right. } \end{aligned}$$
(15)
where \(\delta _x^{\langle 4\rangle }:=\delta _x^{\langle 2\rangle }\delta _x^{\langle 2\rangle }\). These are the semi-discretized Eq. (11) along with the damping terms added for realistic behavior. The energy behavior of this system is described by the following theorem.

Theorem 5

The discrete energy function \(H_\mathrm {d}\) (9) is not increasing:
$$\begin{aligned} \frac{\mathrm {d}H_\mathrm {d}}{\mathrm {d}t}=&-\,\mu v_{\mathrm {r}, \mathrm {d}}^2K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha - d_1\sum _{l=1}^{N-1} v_l^2\varDelta x \\&-\, d_3\Biggl [ \frac{(\delta _x^+v_0)^2 + (\delta _x^-v_0)^2}{2}\frac{\varDelta x}{2} +\sum _{l=1}^{N-1} \frac{(\delta _x^+v_l)^2+(\delta _x^-v_l)^2}{2}\varDelta x \\&+\,\frac{(\delta _x^+v_N)^2 + (\delta _x^-v_N)^2}{2}\frac{\varDelta x}{2} \Biggr ]\le 0. \end{aligned}$$
Moreover, if \(\mu =d_1=d_3=0\), the system is conservative according to Theorem 3.

Proof

From the differentiation of \(H_\mathrm {d}\), we obtain
$$\begin{aligned} \frac{\mathrm {d}H_\mathrm {d}}{\mathrm {d}t}&=\frac{\mathrm {d}{{\tilde{H}}}_\mathrm {d}}{\mathrm {d}t}\\&=\left[ v_0\dot{v}_0 + c^2 \frac{(\delta _x^+u_0)(\delta _x^+\dot{u}_0) + (\delta _x^-u_0)(\delta _x^-\dot{u}_0)}{2} + \kappa ^2 (\delta _x^{\langle 2\rangle }u_0)(\delta _x^{\langle 2\rangle }\dot{u}_0) \right] \frac{\varDelta x}{2}\\&\quad + \sum _{l=1}^{N-1} \Biggl [ v_l\dot{v}_l + c^2 \frac{(\delta _x^+u_l)(\delta _x^+\dot{u}_l) + (\delta _x^-u_l)(\delta _x^-\dot{u}_l)}{2} + \kappa ^2(\delta _x^{\langle 2\rangle }u_l)(\delta _x^{\langle 2\rangle }\dot{u}_l) \Biggr ]\varDelta x\\&\quad +\, \left[ v_N\dot{v}_N + c^2 \frac{(\delta _x^+u_{N})(\delta _x^+\dot{u}_{N}) + (\delta _x^-u_{N})(\delta _x^-\dot{u}_{N})}{2} + \kappa ^2 (\delta _x^{\langle 2\rangle }u_N)(\delta _x^{\langle 2\rangle }\dot{u}_N) \right] \frac{\varDelta x}{2}\\&\quad +\, \frac{p_\mathrm {h}}{M_\mathrm {h}}\dot{p}_\mathrm {h}\,+\, K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha (\langle \varvec{\varepsilon },\dot{\varvec{u}}\rangle _{\mathscr {X}}-\dot{u}_\mathrm {h}). \end{aligned}$$
Instead of the integration by parts, we introduce the summation by parts [22]:
$$\begin{aligned}&a_0(\delta _x^+b_0) \frac{\varDelta x}{2} + \sum _{l=1}^{N-1} a_l(\delta _x^+b_l) \varDelta x + a_N(\delta _x^+b_N) \frac{\varDelta x}{2} \\&\quad + (\delta _x^-a_0)b_0 \frac{\varDelta x}{2} + \sum _{l=1}^{N-1} (\delta _x^-a_l)b_l \varDelta x + (\delta _x^-a_N)b_N \frac{\varDelta x}{2} \\&= -\frac{1}{2}\left( a_0b_1+a_{-1}b_0 \right) + \frac{1}{2}\left( a_Nb_{N+1}+a_{N-1}b_N \right) . \end{aligned}$$
Using the summation by parts, we obtain
$$\begin{aligned} \frac{\mathrm {d}H_\mathrm {d}}{\mathrm {d}t}&= -\Biggl [ \frac{c^2}{2}\left\{ \frac{(\delta _x^+u_0)\dot{u}_1 + (\delta _x^+u_{-1})\dot{u}_0}{2} + \frac{\dot{u}_0(\delta _x^-u_1) + \dot{u}_{-1}(\delta _x^-u_0)}{2} \right\} \\&\quad + \kappa ^2 \frac{(\delta _x^{\langle 2\rangle }u_0)(\delta _x^-\dot{u}_1) + (\delta _x^{\langle 2\rangle }u_{-1})(\delta _x^-\dot{u}_0)}{2} \Biggr ] \\&\quad + \kappa ^2 \frac{\dot{u}_0(\delta _x^-\delta _x^{\langle 2\rangle }u_1) + \dot{u}_{-1}(\delta _x^-\delta _x^{\langle 2\rangle }u_0)}{2} \\&\quad +\Biggl [ v_0 \dot{v}_0 - c^2(\delta _x^{\langle 2\rangle }u_0) \dot{u}_0 + \kappa ^2 (\delta _x^{\langle 4\rangle }u_0)\dot{u}_0 + K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \varepsilon _0\dot{u}_0 \Biggr ]\frac{\varDelta x}{2}\\&\quad + \sum _{l=1}^{N-1} \Biggl [ v_l \dot{v}_l - c^2(\delta _x^{\langle 2\rangle }u_l) \dot{u}_l + \kappa ^2 (\delta _x^{\langle 4\rangle }u_l)\dot{u}_l + K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \varepsilon _l\dot{u}_l \Biggr ]\varDelta x \\&\quad +\Biggl [ v_N \dot{v}_N - c^2(\delta _x^{\langle 2\rangle }u_N) \dot{u}_N + \kappa ^2 (\delta _x^{\langle 4\rangle }u_N)\dot{u}_N + K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \varepsilon _N\dot{u}_N \Biggr ] \frac{\varDelta x}{2} \\&\quad -\kappa ^2 \frac{\dot{u}_N(\delta _x^-\delta _x^{\langle 2\rangle }u_{N+1}) + \dot{u}_{N-1}(\delta _x^-\delta _x^{\langle 2\rangle }u_N)}{2} \\&\quad + \Biggl [ \frac{c^2}{2}\left\{ \frac{(\delta _x^+u_N)\dot{u}_{N+1} + (\delta _x^+u_{N-1})\dot{u}_N}{2} + \frac{\dot{u}_N(\delta _x^-u_{N+1}) + \dot{u}_{N-1}(\delta _x^-u_N)}{2} \right\} \\&\quad + \kappa ^2 \frac{(\delta _x^{\langle 2\rangle }u_N)(\delta _x^-\dot{u}_{N+1}) + (\delta _x^{\langle 2\rangle }u_{N-1})(\delta _x^-\dot{u}_N)}{2} \Biggr ] \\&\quad + \frac{p_\mathrm {h}}{M_\mathrm {h}} \dot{p}_\mathrm {h}- K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \dot{u}_\mathrm {h}\\&= \sum _{l=1}^{N-1} \Biggl [ v_l \dot{v}_l - c^2(\delta _x^{\langle 2\rangle }u_l) \dot{u}_l + \kappa ^2 (\delta _x^{\langle 4\rangle }u_l)\dot{u}_l + K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \varepsilon _l\dot{u}_l \Biggr ]\varDelta x \\&\quad + \frac{p_\mathrm {h}}{M_\mathrm {h}} \dot{p}_\mathrm {h}- K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \dot{u}_\mathrm {h}. \end{aligned}$$
We used the boundary conditions (8) at the last equality. Substituting the semi-discretized scheme (15), we get
$$\begin{aligned} \frac{\mathrm {d}H_\mathrm {d}}{\mathrm {d}t}&= \sum _{l=1}^{N-1} \left\{ \dot{v}_l - c^2 (\delta _x^{\langle 2\rangle }u_l) + \kappa ^2 (\delta _x^{\langle 4\rangle }u_l) + K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \varepsilon _l \right\} v_l \varDelta x \\&\quad + \frac{p_\mathrm {h}}{M_\mathrm {h}} K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u}\rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha (1+\mu v_{\mathrm {r},\mathrm {d}}) - K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha \frac{p_\mathrm {h}}{M_\mathrm {h}}\\&= \mu v_{\mathrm {r},\mathrm {d}}\frac{p_\mathrm {h}}{M_\mathrm {h}} K_\mathrm {h}([\langle \varvec{\varepsilon }, \varvec{u} \rangle _{\mathscr {X}} - u_\mathrm {h}]^+)^\alpha - \mu v_{\mathrm {r},\mathrm {d}} \langle \varvec{\varepsilon }, \varvec{v} \rangle _{\mathscr {X}}K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u} \rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha \\&\quad - d_1 \sum _{l=1}^{N-1} v_l^2 \varDelta x + d_3 \sum _{l=1}^{N-1} (\delta _x^{\langle 2\rangle }v_l) v_l \varDelta x\\&= - \mu v_{\mathrm {r},\mathrm {d}}^2 K_\mathrm {h}([\langle \varvec{\varepsilon },\varvec{u} \rangle _{\mathscr {X}}-u_\mathrm {h}]^+)^\alpha - d_1 \sum _{l=1}^{N-1} v_l^2 \varDelta x \\&\quad - d_3 \Biggl [ \frac{(\delta _x^+v_0)^2+(\delta _x^-v_0)^2}{2} \frac{\varDelta x}{2} + \sum _{l=1}^{N-1} \frac{(\delta _x^+v_l)^2+ (\delta _x^-v_l)^2}{2}\varDelta x \\&\quad + \frac{(\delta _x^+v_N)^2+(\delta _x^-v_N)^2}{2} \frac{\varDelta x}{2} \Biggr ] \le 0. \end{aligned}$$
\(\square \)
In the following numerical tests, we confirm that sounds generated by the numerical schemes derived by the above procedure certainly have basic characteristics of piano tones. We tested the 3-stage 3rd-order, the 4-stage 4th-order, and the 6-stage 4th-order SPRK methods with the following coefficients:
$$\begin{aligned}&(-1/24, 3/4, 7/24)[1, -2/3, 2/3],\\&(\omega , \nu , \omega , 0)[\omega /2, (\omega +\nu )/2, (\omega +\nu )/2, \omega /2],\\&(-1/48, 3/8, 7/24, 3/8, -1/48, 0)[1/2, -1/3, 1/3, 1/3, -1/3, 1/2], \end{aligned}$$
where \(\omega =(2+2^{1/3}+2^{-1/3})/3\) and \(\nu =1-2\omega \); see [51]. The initial conditions are
$$\begin{aligned} u(0,x)=v(0,x)=0, \quad u_\mathrm {h}(0)=0.0005, \quad p_\mathrm {h}=-4.0\,M_\mathrm {h}. \end{aligned}$$
We employed the approximated delta function \(\varvec{\varepsilon }(l_\mathrm {h})\) used in [9]:
$$\begin{aligned} (\varvec{\varepsilon }(l_\mathrm {h}))_l= {\left\{ \begin{array}{ll} -\beta _{\mathrm {h}}(\beta _{\mathrm {h}}-1)(\beta _{\mathrm {h}}-2)/(6\varDelta x), \quad &{}\text{( }l\,=\,l_{\mathrm {h}}-1\text{) }\\ (\beta _{\mathrm {h}}-1)(\beta _{\mathrm {h}}+1)(\beta _{\mathrm {h}}-2)/(2\varDelta x), \quad &{}\text{( }l\,=\,l_\mathrm {h}\text{) }\\ -\beta _{\mathrm {h}}(\beta _{\mathrm {h}}+1)(\beta _{\mathrm {h}}-2)/(2\varDelta x), \quad &{} \text{( }l\,=\,l_{\mathrm {h}}+1\text{) }\\ \beta _{\mathrm {h}}(\beta _{\mathrm {h}}-1)(\beta _{\mathrm {h}}+1)/(6\varDelta x), \quad &{} \text{( }l\,=\,l_{\mathrm {h}}+2\text{) }\\ 0. \quad &{} \text{(otherwise) } \end{array}\right. } \end{aligned}$$
According to [9], this is a 3rd-order approximation of \(\delta (x-(\beta _\mathrm {h}+l_\mathrm {h})\varDelta x)\). Because in (11) the central difference operators are used in the spatial direction, the entire scheme becomes 2nd-order in space. We used the values of u(t, 0.7L) as the computed sound waves and also set \(l_\mathrm {h}=0.2N\) and \(\beta _\mathrm {h}=0.3\).
Before testing the piano sound, we investigate the validity of the discretization method for H. We excluded the damping terms and the hammer, and only consider the Hamilton PDE that describes the string in this validation. Figure 3 shows the comparison of the numerical solutions by the 4-stage 4th-order SPRK under the various values of \(\varDelta t\) and \(\varDelta x\) with the following exact solution under the boundary condition (3):
$$\begin{aligned} u(t,x)&= \sum _{m=1}^{15} \sin \left( m\pi \frac{x}{L}\right) \left( A_m\cos (\sqrt{\lambda _m} t) + B_m\sin (\sqrt{\lambda _m} t) \right) , \end{aligned}$$
(16)
$$\begin{aligned} \lambda _m&=c^2\left( \frac{m\pi }{L}\right) ^2+\kappa ^2\left( \frac{m\pi }{L}\right) ^4. \end{aligned}$$
(17)
We set two constants above to \(A_m=B_m=1/15\). We also used this exact solution at \(t=0\) as the initial condition. The graph in Fig. 3 shows that the numerical solution indeed converges to the exact solution as \(\varDelta t\rightarrow 0\) and \(\varDelta x\rightarrow 0\). This is in fact quantitatively confirmed in Table 4, where the \(L^2\)-norm and the \(L^\infty \)-norm are defined by
$$\begin{aligned}&||\varvec{e}(t)||_2=\left( \sum _{l=1}^{N-1} | e_l(t) |^2 \varDelta x\right) ^{1/2}, \quad ||\varvec{e}(t)||_\infty =\mathrm {max}_{l=1,\ldots ,N-1} | e_l(t) |,\\&\varvec{e}(t) = (e_1(t) \ldots \ e_{N-1}(t)), \quad e_l(t)={{\hat{u}}}_l^{t/\varDelta t}-u(t,l\varDelta x). \end{aligned}$$
Fig. 3

Comparison of the numerical solutions by the 4-stage 4th-order SPRK with the exact solution by using the piano model without the terms regarding the hammer and the damping of the string. This graph shows the numerical solution \(\varvec{u}\) at \(t=0.1\) in the various conditions. The numerical solutions indeed converge to the exact solution as \(\varDelta t \rightarrow 0\) and \(\varDelta x \rightarrow 0\)

Table 4

Errors of the numerical solution of (11) without the hammer and the damping terms by the 4-stage 4th-order SPRK

\(\varDelta t\)

N

\(|| \varvec{e}(0.1) ||_2\)

\(|| \varvec{e}(0.1) ||_\infty \)

\(44100^{-1}\)

40

\(2.80314\times 10^{-1}\)

\(5.41141\times 10^{-1}\) \((x=0.4410)\)

\((44100\times 10)^{-1}\)

100

\(4.68303\times 10^{-1}\)

\(5.85610\times 10^{-1}\) \((x=0.1134)\)

\((44100\times 100)^{-1}\)

1000

\(1.5081\times 10^{-2}\)

\(5.97745\times 10^{-2}\) \((x=0.0233)\)

\((44100\times 200)^{-1}\)

1500

\(3.7458\times 10^{-3}\)

\(2.64958\times 10^{-2}\) \((x=0.0231)\)

Fig. 4

The numerical solutions of the scheme derived by using \(\tilde{{\tilde{H}}}_\mathrm {d}\). Although \(\varDelta t\) and \(\varDelta x\) are the same or less, the waveform of that by \({{\tilde{H}}}_\mathrm {d}\) is closer to the exact solution than the other two results

Fig. 5

Comparison of the 4-stage 4th-order SPRK with the exact solution by using the piano model without the terms regarding the hammer and the damping of the string. These graphs show the gap of the discrete energy between the computed and the exact value with \(A_m=B_m=10^{-5}\) and \(N=100\). The discrete energy also converges to the exact value as \(\varDelta t\rightarrow 0\)

Fig. 6

The waveforms of the string computed with the three SPRK methods with \(N=1000\) for 1 s. The graph on the top is the numerical solution computed with the 4-stage 4th-order method, the one in the middle is computed with the 3-stage 3rd-order method and the bottom one with the 6-stage 4th-order method

We also show the numerical solutions of the scheme derived by using \(\tilde{{\tilde{H}}}_\mathrm {d}\) in Fig. 4. Although we used the same or less \(\varDelta t\) and \(\varDelta x\), the waveform of that by \({{\tilde{H}}}_\mathrm {d}\) is closer to the exact solution. Figure 5 shows the gap between the computed value and the exact value of the discrete energy with \(A_m=B_m=10^{-5}\) and \(N=100\). The exact value of the discrete energy is approximately equal to 0.110. We used \(\varDelta t=1/(44{,}100\cdot 200)\) and \(N=1000\) hereinafter if it is not specifically noted.
Fig. 7

The waveform of the string computed with the 4-stage 4th-order SPRK method with \(N=1000\). This is the waveform from 0.4 to 0.45 s. We find that some waves are regularly repeated and expect that this includes the integer multiple of the frequency of 261.63 Hz which corresponds to the note C4

Fig. 8

The spectrum of the numerical solution computed with the 4-stage 4th-order SPRK method with \(N=1000\). The spectrum under 10,000 Hz is shown at the top and the enlarged one under 2000 Hz at the bottom. The frequency of a note C4 is 261.63 Hz and the large peaks are observed near the integer multiples of 261.63 Hz

Figure 6 shows the numerical solutions obtained by the 3-stage 3rd-order, the 4-stage 4th-order, and the 6-stage 4th-order SPRK schemes for (14).

Any significant difference is not observed between these figures. We also compare the notes calculated by each method by carefully listening to them; however we did not notice a difference again. Hence, concerning the computation time, we conclude that the 3-stage or the 4-stage method is practical enough.

Figure 7 is the enlarged figure of the waveform of the 4-stage 4th-order SPRK method. We find that this waveform is formed by repeating several kinds of waves with different amplitudes one after the other. This result gives an expectation that this waveform is a superposition of the wave of 261.63 Hz, which is the frequency of C4, and integer multiples of it. To confirm this, we show the spectrum of the waveform in Fig. 8.

There are large peaks expectedly near the positive integer multiples of 261.63 Hz. The notes of a real piano are indeed a superposition of such frequency components. Actually the spectrum shown in Fig. 8 is similar to those reported in the literature; see [18].

Figure 9 shows the gap of the energy \(H_\mathrm {d}\) (9) between the value of the numerical solution by the 4-stage 4th-order SPRK method and the exact value, which is approximately equal to \(4.5496\times 10^{-2}\). We excluded the damping terms in this numerical test so that the energy is preserved.
Fig. 9

The evolutions of the error of the energy of the numerical solutions for the first 10 s computed with the 4-stage 4th-order SPRK method with \(N=1000\) and \(\varDelta t = 1/(44{,}100 \cdot 10)\), \(1/(44{,}100 \cdot 100)\). A similar result to Fig. 3 which shows the convergence of the energy as \(\varDelta t\rightarrow 0\) is observed

The graph on the top shows that the displacements are within a certain range despite a large amount of the calculation steps ( 44,100,000 steps for 10 s). This energy behavior is due to the symplectic property of the method and shows that the proposed scheme certainly has a superior property regarding stability. Moreover, a similar result to Fig. 3 in which the recovery of the energy conservation law as \(\varDelta t\rightarrow 0\) is shown is again observed in this test.
Fig. 10

The waveforms of the string computed with the 4-stage 4th-order SPRK method. We changed the number of points N from 1000 to 50. The shape of the outline of the waveform is smoother than that in Fig. 6

Fig. 11

The spectrum in the law-frequency zone of the numerical solution computed with the 4-stage 4th-order SPRK method with \(N=50\). The power and the peak of the spectrum in the low-frequency zone are almost unchanged

Fig. 12

The gap between the energy of the numerical solution computed with the 4-stage 4th-order SPRK method with \(N=50\) and that of the exact solution. The values are within a fixed range and converge to 0 as \(\varDelta t\) tends to 0

Figures  10, 11, 12 show the result when the number of points N is changed from 1000 to 50. We used \(l_{\mathrm {h}}=0.2N\) and \(\beta _\mathrm {h}=0.00945\) so that the hammer strikes the same position (\(x \approx 0.126\,L\)) of the string as in the previous experiments. In the first two experiments, the damping terms are included. Compared to Fig. 6, the waveform in Fig. 10 is smoother, which implies suppression of high-frequency tones. By carefully listening to the calculated notes, we in fact noticed that the sound was slightly blurred; on the other hand, as shown in Fig. 11, the power and the peak of the spectrum in the low-frequency zone are almost unchanged. The gap between the computed and the exact energy, which is approximately equal to \(4.5496\times 10^{-2}\), is shown in Fig. 12. The values of \(H_\mathrm {d}\) are still within a certain fixed range and converge to the exact value by \(\varDelta t\rightarrow 0\) as well as in the case illustrated in Fig. 9.

5 Conclusion

Recently, much attention has been paid to novel approaches to the development of virtual musical instruments, where the PDE models of the components of the instruments are solved numerically. Since extensively long-time calculations are required to reproduce notes even for a few seconds, the computation time is significantly large and the accumulation of errors is not negligible. Hence numerical schemes for the musical simulations must be carefully designed—not only accurate and stable, but also efficient.

In this contribution we have introduced a procedure for deriving numerical schemes for models of musical instruments. The procedure is a combination of the variational semi-discretization by Celledoni et al. and the symplectic Runge–Kutta methods. The outline of the variational semi-discretization is illustrated in Fig. 2. This technique automatically derives a semi-discrete scheme while preserving the Hamiltonian structure. Thereby, geometric integrators can be immediately applied without any additional steps. Geometric integrators are numerical integrators of ODEs that preserve a significant property of the equations, typically energy conservation or symplecticity. By preserving one of these properties, the exact or approximated energy is accurately conserved. Since with this discrete conservation law numerical schemes often have excellent stability properties, the above procedure facilitates the design of several stable numerical schemes for musical simulations. We focus our attention on the observation that most PDE models of musical instruments are separable Hamiltonian systems and also on the fact that a class of SPRK methods yields explicit schemes for this type of Hamiltonian systems. Based on these facts, we have shown that the combination of the variational semi-discretization and SPRK methods is a right procedure for deriving numerical schemes that are suitable for simulations of musical instruments; indeed this procedure automatically yields explicit and symplectic schemes of a high order of accuracy for most of the models for musical instruments.

For illustration purposes, we have applied this procedure to a simple piano model and have derived a series of symplectic integrators by the application of SPRK methods. In absence of the damping terms, the model is shown to be a separable Hamiltonian system, so that the schemes are explicit and computationally efficient for computing piano sounds. We tested the 3-stage 3rd-order, the 4-stage 4th-order, and the 6-stage 4th-order PRK methods numerically and all of them are shown to be sufficiently stable. Although we used higher order schemes (in time), the 3-stage 3rd-order or the 4-stage 4th-order method may be practical enough; almost no difference is observed between the waveforms computed by these methods. In particular, the 6-stage method needs more computational time but the result is almost the same compared to the other methods used in our numerical experiments.

Since we only took the consideration of the accuracy in the time direction into account, and only used the 2nd order difference operators in the spatial direction, in our future work we plan to improve accuracy in the space direction. In particular, the use of higher order compact schemes, which are known to be effective in the calculations of sound waves [35], is of importance. Also, this procedure must be tested for more realistic models of musical instruments. In this context, the model of a whole piano by Chabassier et al. (see [14, 15]) is important, for which reason we plan to consider it in our future work.

From a theoretical perspective, the effectiveness of the application of symplectic integrators to dissipative systems should be investigated because the model for the piano has the damping terms. Although this is a challenging problem, there exist a few results on analyses on this topic (e.g. [6]). The results of these analyses could give an insight on the qualitative acoustical analyses of computations of musical sounds.

Notes

Acknowledgements

This work was partially supported by the KAKENHI Grant (26400200) of the Japan Society for the Promotion of Science. The authors appreciate the valuable comments, suggestions and references given by the anonymous referees.

References

  1. 1.
    Bank, B., Avanzini, F., Borin, G., De Poli, G., Fontana, F., Rocchesso, D.: Physically informed signal processing methods for piano sound synthesis: a research overview. EURASIP J. Adv. Signal Process. 2003, 941–952 (2003)CrossRefGoogle Scholar
  2. 2.
    Bank, B., Sujbert, L.: Generation of longitudinal vibrations in piano strings: from physics to sound synthesis. J. Acoust. Soc. Am. 117, 2268–2278 (2005)CrossRefGoogle Scholar
  3. 3.
    Bensa, J., Bilbao, S., Kronland-Martinet, R., Smith, J.O.: The simulation of piano string vibration: from physical models to finite difference schemes and digital waveguides. J. Acoust. Soc. Am. 114, 1095–1107 (2003)CrossRefGoogle Scholar
  4. 4.
    Bensa, J., Gipouloux, O., Kronland-Martinet, R.: Parameter fitting for piano sound synthesis by physical modeling. J. Acoust. Soc. Am. 118, 495–504 (2005)CrossRefGoogle Scholar
  5. 5.
    Bensa, J., Bilbao, S., Kronland-Martinet, R., Smith, J.O., Voinier, T.: Computational modeling of stiff piano strings using digital waveguides and finite differences. Acta Acust. United Acust. 91, 289–298 (2005)Google Scholar
  6. 6.
    Bhatt, A., Floyd, D., Moore, B.E.: Second order conformal symplectic schemes for damped Hamiltonian systems. J. Sci. Comput. 66, 1234–1259 (2016)MathSciNetCrossRefMATHGoogle Scholar
  7. 7.
    Bilbao, S.: Conservative numerical methods for nonlinear strings. J. Acoust. Soc. Am. 118, 3316–3327 (2005)CrossRefGoogle Scholar
  8. 8.
    Bilbao, S.: Robust physical modeling sound synthesis for nonlinear systems. IEEE Signal Process. Magn. 24, 32–41 (2007)CrossRefGoogle Scholar
  9. 9.
    Bilbao, S.: Numerical Sound Synthesis: Finite Difference Schemes and Simulation in Musical Acoustics. Wiley, Chichester (2009)CrossRefMATHGoogle Scholar
  10. 10.
    Bilbao, S., Smith, J.O.: Energy-conserving finite difference schemes for nonlinear strings. Acta Acust. United Acust. 91, 299–311 (2005)Google Scholar
  11. 11.
    Bilbao, S., Torin, A., Chatziioannou, V.: Numerical modeling of collisions in musical instruments. Acta Acust. United Acust. 101, 155–173 (2015)CrossRefGoogle Scholar
  12. 12.
    Boutillon, X.: Model for piano hammers: experimental determination and digital simulation. J. Acoust. Soc. Am. 83, 746–754 (1988)CrossRefGoogle Scholar
  13. 13.
    Celledoni, E., Grimm, V., McLachlan, R.I., McLaren, D.I., O’Neale, D., Owren, B., Quispel, G.R.W.: Preserving energy resp. dissipation in numerical PDEs using the “Average Vector Field” method. J. Comput. Phys. 231, 6770–6789 (2012)MathSciNetCrossRefMATHGoogle Scholar
  14. 14.
    Chabassier, J., Chaigne, A., Joly, P.: Time domain simulation of a piano. Part 1: model description. M2AN. 48, 1241–1278 (2014)Google Scholar
  15. 15.
    Chabassier, J., Duruflé, M.: Energy Based simulation of a Timoshenko beam in non-forced rotation. Influence of the piano Hammer Shank flexibility on the sound. J. Sound Vib. 333, 7198–7215 (2014)CrossRefGoogle Scholar
  16. 16.
    Chabassier, J., Duruflé, M., Joly, P.: Time domain simulation of a piano. Part 2: numerical aspects. M2AN. 50, 93–133 (2016)Google Scholar
  17. 17.
    Chaigne, A., Askenfelt, A.: Numerical simulations of piano strings. I. A physical model for a struck string using finite difference methods. J. Acoust. Soc. Am. 95, 1112–1118 (1994)CrossRefGoogle Scholar
  18. 18.
    Chaigne, A., Askenfelt, A.: Numerical simulations of piano strings. II. Comparisons with measurements and systematic exploration of some Hammer-string parameters. J. Acoust. Soc. Am. 95, 1631–1640 (1994)CrossRefGoogle Scholar
  19. 19.
    Ghosh, M.: Experimental study of the duration of contact of an elastic Hammer striking a damped pianoforte string. Indian J. Phys. 7, 365–382 (1932)Google Scholar
  20. 20.
    Giordano, N.: Simple model of a piano soundboard. J. Acoust. Soc. Am. 102, 1159–1168 (1997)CrossRefGoogle Scholar
  21. 21.
    Giordano, N.: Mechanical impedance of a piano soundboard. J. Acoust. Soc. Am. 103, 2128–2133 (1998)CrossRefGoogle Scholar
  22. 22.
    Furihata, D.: Finite difference schemes for \(\frac{\partial u}{\partial t}=(\frac{\partial }{\partial x})^\alpha \frac{\delta G}{\delta u}\) that inherit energy conservation or dissipation property. J. Comput. Phys. 156, 181–205 (1999)MathSciNetCrossRefMATHGoogle Scholar
  23. 23.
    Furihata, D.: Finite difference schemes for nonlinear wave equation that inherit energy-conservation property. J. Comput. Appl. Math. 134, 37–57 (2001)MathSciNetCrossRefMATHGoogle Scholar
  24. 24.
    Furihata, D.: Finite difference schemes for nonlinear wave equation that inherit energy conservation property. J. Comput. Appl. Math. 134, 35–57 (2001)MathSciNetCrossRefMATHGoogle Scholar
  25. 25.
    Furihata, D., Matsuo, T.: A stable, convergent, conservative and linear finite difference scheme for the Cahn–Hilliard equation. Jpn. J. Indust. Appl. Math. 20, 65–85 (2003)MathSciNetCrossRefMATHGoogle Scholar
  26. 26.
    Furihata, D., Matsuo, T.: Discrete Variational Derivative Method: A Structure-Preserving Numerical Method for Partial Differential Equations. CRC Press, Boca Raton (2011)MATHGoogle Scholar
  27. 27.
    Gonzalez, O.: Time integration and discrete Hamiltonian systems. J. Nonlinear Sci. 6, 449–467 (1996)MathSciNetCrossRefMATHGoogle Scholar
  28. 28.
    Hairer, E., Lubich, C., Wanner, G.: Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations. Springer, New York (2006)MATHGoogle Scholar
  29. 29.
    Hairer, E.: Backward analysis of numerical integrators and symplectic methods. Ann. Numer. Math. 1, 107–132 (1994)MathSciNetMATHGoogle Scholar
  30. 30.
    Ishikawa, A., Yaguchi, T.: Geometric investigation of the discrete gradient method for the webster equation with a weighted inner product. JSIAM Lett. 7, 17–20 (2015)MathSciNetCrossRefGoogle Scholar
  31. 31.
    Izadbakhsh, A., McPhee, J., Birkett, S.: Dynamic modeling and experimental testing of a piano action mechanism with a flexible Hammer Shank. J. Comput. Nonlinear Dynam. 3, 031004 (2008)CrossRefGoogle Scholar
  32. 32.
    James, D.L., Barbić, J., Pai, D.K.: Precomputed acoustic transfer: output-sensitive, accurate sound generation for geometrically complex vibration sources. ACM Trans. Graph. 25, 987–995 (2006)CrossRefGoogle Scholar
  33. 33.
    Jay, L.: Symplectic partitioned Runge–Kutta methods for constrained Hamiltonian systems. SIAM J. Numer. Anal. 33, 368–387 (1996)MathSciNetCrossRefMATHGoogle Scholar
  34. 34.
    Langlois, T.R., An, S.S., Jin, K.K., James, D.L.: Eigenmode compression for modal sound models. ACM Trans. Graph. 33, 40 (2014)Google Scholar
  35. 35.
    Lele, S.K.: Compact finite difference schemes with spectral-like resolution. J. Comput. Phys. 103, 16–42 (1992)MathSciNetCrossRefMATHGoogle Scholar
  36. 36.
    Mamou-Mani, A., Frelat, J., Besnainou, C.: Numerical simulation of a piano soundboard under downbearing. J. Acoust. Soc. Am. 123, 2401–2406 (2008)CrossRefGoogle Scholar
  37. 37.
    Matsuo, T.: High-order schemes for conservative or dissipative systems. J. Comput. Appl. Math. 152, 305–317 (2003)MathSciNetCrossRefMATHGoogle Scholar
  38. 38.
    Matsuo, T.: New conservative schemes with discrete variational derivatives for nonlinear wave equations. J. Comput. Appl. Math. 203, 32–56 (2007)MathSciNetCrossRefMATHGoogle Scholar
  39. 39.
    Matsuo, T.: Dissipative/conservative Galerkin method using discrete partial derivative for nonlinear evolution equations. J. Comput. Appl. Math. 218, 506–521 (2008)MathSciNetCrossRefMATHGoogle Scholar
  40. 40.
    Matsuo, T., Furihata, D.: Dissipative or conservative finite difference schemes for complex-valued nonlinear partial differential equations. J. Comput. Phys. 171, 425–447 (2001)MathSciNetCrossRefMATHGoogle Scholar
  41. 41.
    Matsuo, T., Sugihara, M., Furihata, D., Mori, M.: Linearly implicit finite difference schemes derived by the discrete variational method. RIMS Kokyuroku. 1145, 121–129 (2000)MathSciNetMATHGoogle Scholar
  42. 42.
    Matsuo, T., Sugihara, M., Furihata, D., Mori, M.: Spatially accurate dissipative or conservative finite difference schemes derived by the discrete variational method. Jpn. J. Indust. Appl. Math. 19, 311–330 (2002)MathSciNetCrossRefMATHGoogle Scholar
  43. 43.
    McLachlan, R.I., Quispel, G.R.W., Robidoux, N.: Geometric integration using discrete gradients. Philos. Trans. R. Soc. A. 357, 1021–1045 (1999)MathSciNetCrossRefMATHGoogle Scholar
  44. 44.
    Nelson, C.A.: Design and dynamic simulation of a novel piano action mechanism. Proc. ASME Des. Eng. Technol. Conf. DETC2008-49167, 789–796 (2009)Google Scholar
  45. 45.
    Oledzki, A.: Dynamics of piano mechanisms. Mech. Machine Theory. 7, 373–385 (1972)CrossRefGoogle Scholar
  46. 46.
    Quispel, G.R.W., Turner, G.S.: Discrete gradient methods for solving ODEs numerically while preserving a first integral. J. Phys. A. 29, 341–349 (1999)MathSciNetCrossRefMATHGoogle Scholar
  47. 47.
    Reich, S.: Backward error analysis for numerical integrators. SIAM J. Numer. Anal. 36, 1549–1570 (1999)MathSciNetCrossRefMATHGoogle Scholar
  48. 48.
    Rimski-Korsakov, A.: The problem of a piano Hammer striking a string (parts 1 and 2). Zhurnal Tehnicheskoi Fiziki. 7, 43–74 (1937)Google Scholar
  49. 49.
    Rimski-Korsakov, A., Matveev, P.: Investigation of dynamical properties of the piano key action. SRIMI - collection of works. p. 159 (1938)Google Scholar
  50. 50.
    Sanz-Serna, J.M.: Symplectic integrators for Hamiltonian problems: an overview. Acta Numer. 1, 243–286 (1992)MathSciNetCrossRefMATHGoogle Scholar
  51. 51.
    Sanz-Serna, J.M., Calvo, M.P.: Numerical Hamiltonian Problems. Chapman and Hall, London (1994)CrossRefMATHGoogle Scholar
  52. 52.
    Smith, J.O.: Spectral Audio Signal Processing. W3K Publishing, New York (2011)Google Scholar
  53. 53.
    Stulov, A.: Experimental and computational studies of piano hammers. Acta Acust. United Acust. 91, 1086–1097 (2005)Google Scholar
  54. 54.
    Stulov, A.: Physical modelling of the piano string scale. Appl. Acoust. 69, 977–984 (2008)CrossRefGoogle Scholar
  55. 55.
    Testa, I., Evangelista, G., Cavaliere, S.: Physically inspired models for the synthesis of stiff strings with dispersive waveguides. EURASIP J. Adv. Signal Process. 2004, 964–977 (2004)CrossRefMATHGoogle Scholar
  56. 56.
    Trautmann, L., Rabenstein, R.: Digital Sound Synthesis by Physical Modeling Using the Functional Transformation Method. Kluwer Academic/Plenum Publishers, New York (2003)CrossRefMATHGoogle Scholar

Copyright information

© The Author(s) 2018

Open AccessThis article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

Authors and Affiliations

  1. 1.Department of Computational Science, Graduate School of System InformaticsKobe UniversityNada-kuJapan
  2. 2.Department of Computer Science, School of EngineeringStanford UniversityStanfordUSA

Personalised recommendations