M. Ducceschi, S. Bilbao and C. Webb

Real-time simulation of the struck piano string with geometrically exact nonlinearity via a scalar quadratic energy method

S. Bilbao and M. Ducceschi

Fast explicit algorithms for Hamiltonian numerical integration

10th European Nonlinear Dynamics Conference (ENOC 2020 in 2022)
After some first initial developments (see this DAFx paper), Stefan and I have spent some effort attempting to improve the accuracy and the performance of the ``quadratised'' schemes. These are part of a new class of schemes of recent development, based on the idea of ``quadratisation'': when the nonlinear potential energy is non-negative, it can be written as the square of an auxiliary function. This leads to schemes for which the update is computable as the solution of a linear system, thus sidestepping the machinery of iterative root finders (these are needed for the update of classic fully-implicit schemes). Besides the obvious computational advantage, existence and uniqueness of the computed solution are proven by inspection of the update matrix alone. We wrote a couple of papers for the ENOC conference, held in Lyon, France, July 2022.

In the first one, we have a look at Hamiltonian systems, with the following Hamiltonian
Transverse_DispRel

Here, ψ = √2V, and the (nonlinear) potential is constrained such that V≥0. The resulting equations are

Transverse_DispRel
Hamilton's equations for a system with generalised coordinates q and momenta p. These are N×1 vectors. The potential V(q) is here supposed to be bounded from below. M is the N×N mass matrix, supposed here diagonal for simplicity.

Above, the intermediate variable g=∇ψ has been introduced. Note that the Hamiltonian is composed of quadratic terms only (kinetic, linear potential and nonlinear potential energy components). Note as well that the auxiliary variable ψ is here a scalar: this kind of quadratisation is inherently different from the one that we have been using so far, e.g. for collisions, and for the nonlinear string (see also [1,2,3]).



A (VERY!) FAST ENERGY-CONSERVING INTEGRATOR
Integration of the above system may be performed as follows.

Transverse_DispRel
Scheme update, defined for qn+1, pn+1/2, ψn+1/2 approximating q(t) (at the time t=kn), p(t) and ψ(t) (at the time t=k(n+1/2)), where k is the time step.

This scheme conserves a discrete energy-like quantity (sometimes called a pseudoenergy) [4]:

DispRelCFLvsEXP

Note that the pseudoenergy is here of indefinite sign, as a consequence of the explicit discretisation of the linear part. However, the nonlinear energy is clearly non-negative, since it is proportional to ψ2. Non-negativity of the energy can therefore be inferred from inspection of the linear part alone, leading to the following stability condition

Transverse_DispRel
Stability condition. Here M1/2 is the positive matrix square root of the diagonal mass matrix, and λmax is the largest eigenvalue.

This suffices to conclude that the scheme above is energy-stable. At a first glance, the scheme above looks implicit, and requiring the solution of a full linear system! On the surface, this looks considerably worse than the sparse update obtained with a vector ψ (like here). This is true, but here the update equation lends itself naturally to a fast inversion. Rewriting the terms above, one gets

DispRelCFLvsEXP

Here, An, bn are, respectively, a matrix and a vector of known coefficients. An is in the form of a rank-1 perturbation to the diagonal mass matrix M, which can be inverted in O(N) operations using the Sherman-Morrison formula:

DispRelCFLvsEXP

These schemes are really, really fast ... also, they can be applied to a vast class of problems, so long as the potential energy is bounded from below. Most problems in mechanics (and musical acoustics) are of this kind. One such system is the von Karman plate. Here, we managed to get compute times in Matlab of the same order as a fully explicit (but not energy-stable) scheme! This is pretty amazing ...

DispRelCFLvsEXP
Output displacement of a von Karman plate, under initial conditions of increasing amplitude. Compute times of the fast scheme above are of the same order of a fully explicit scheme, but here the discrete (positive) energy is conserved to machine accuracy, ensuring stability even under large initial conditions.
DispRelCFLvsEXP
Compute times in Matlab comparing the proposed scheme against the explicit Stormer-Verlet scheme, and an energy-conserving scheme from [6]. Note that Stormer-Verlet becomes unstable for high input amplitudes, as opposed to the proposed scheme which is energy-stable. Times indicated are run-times for 1 s of output.



THE GEOMETRICALLY EXACT NONLINEAR STRING (AGAIN!)
In the second paper, we had a look at the geometrically exact nonlinear string. This is a long-time favourite ... You can read all about it here (see also [2,3,5]). As mentioned before, here we are performing a different kind of quadratisation with respect to our previous work: the auxiliary state function ψ is here a scalar, not a distributed quantity. We kind of went a bit further here, in that the model not only does it include the string, but also the hammer striking it (this is described by a highly nonlinear model, see here).
Here, the state vector is [uT,vT,U]T, where u is the N×1 vector including the transverse displacements at the grid points; v is the N×1 vector of longitudinal displacements, and U is the displacement of the hammer. In continuous time, the equations of motion can be written as

DispRelCFLvsEXP

where

DispRelCFLvsEXP

and these are completed by the time derivative of ψ:

DispRelCFLvsEXP

Here, M, C, K are, respectively, the (diagonal) mass matrix, the loss matrix (also diagonal), and the stiffness matrix, obtained from a finite difference spatial discretisation (but note that any other kind of discretisation would work too, like finite elements).
The interesting thing is that now all the nonlinearities are consolidated into the single scalar function ψ: these include the string inherent nonlinearity, and the hammer-string interaction. This is one reason why this method is so powerful: you can include pretty much anything in the definition of ψ, so long as the overall potential energy is non-negative. Here are some snapshot of the resulting dynamics

DispRelCFLvsEXP
Snapshots of the string-hammer system, for a D2 piano string (parameters from here). Times indicated are in milliseconds.

In the absence of losses, the scheme is conservative:

DispRelCFLvsEXP

Here are some output spectra under various hammer's initial velocities. Note the change in brightness, as well as the appeareance of ``phantom partials''.

DispRelCFLvsEXP



EXAMPLE SOUNDS
Here are example sounds. The grid spacing is chosen at the limit of stability of the longitudinal waves, so that h=k√E/ρ. This requires significant temporal oversampling, compared to audio rate. The sounds below are obtained using a sample rate of 12·48 kHz. What you are listening to below is the output velocity, taken at two output points along the string for stereo effect. The string parameters are taken from here. The examples below are a little too crude for realistic sound synthesis: most notably, there is no soundboard. However, the change in brightness and spectral content with increasing striking velocity is evident.

D2, V0= 1 m/s
D2, V0= 2.5 m/s
D2, V0= 5 m/s
D3, V0= 1 m/s
D3, V0= 2.5 m/s
D3, V0= 5 m/s

Here is a ``convergence'' test for the C2 string, using increasing values of the oversampling factor. An oversampling of at least 12 is usually needed for good resolution within the audio band, because of the large numerical dispersion in the transverse direction due to the choice of the large grid spacing.

C2, Oversampling factor (OF) = 8
C2, Oversampling factor (OF) = 12
C2, Oversampling factor (OF) = 16

Finally, compute times. This is one of the most important results of this work: when coded properly in C++, the compute times for typical strings fall below real-time ... this is a huge accomplishment! Here, we are talking of systems with more than 200 nonlinearly coupled degrees of freedom. The speedup of the fast Sherman-Morrison scheme coded in C++, compared to a Matlab realisation of the iterative scheme, is around 350 times at OF = 12 ... this is absolutely huge!

DispRelCFLvsEXP
Runtime/real time ratios, for the D3 string. Here ICA_IT and ICA_NIT are the schemes presented in [3] (realised in Matlab); LU_NIT is the block LUD decomposition from here [2]; SM_MTL is the Matlab realisation of the fast Sherman-Morrison presented above; and SM_C++ is the same scheme, coded in C++. OF indicates the oversampling factor for a base sample rate of 48 kHz. M is the number of grid points of the finite difference scheme. Mlong is the number of longitudinal modes for LU_NIT. The system size is 2M-2 for all schemes, except for LU_NIT for which is it M-1+Mlong. Below-real-time simulations are highlighted.
REFERENCES
  1. M. Ducceschi, S. Bilbao, S. Willemsen, S. Serafin, Linearly-implicit schemes for collisions in musical acoustics based on energy quadratisation, Journal of the Acoustical Society of America, Vol. 149(5):3502–3516, 2021
  2. M. Ducceschi, S. Bilbao. Non-iterative, conservative schemes for geometrically exact nonlinear string vibration, Proceedings of the International Congress on Acoustics (ICA2019), Aachen, Germany, 2019
  3. M. Ducceschi and S. Bilbao. Simulation of the Geometrically Exact Nonlinear String via Energy Quadratisation, Journal of Sound and Vibration, in press, 2022
  4. F. Marazzato, A. Ern, C. Mariotti, and L. Monasse. An explicit pseudo-energy conserving time-integration scheme for Hamiltonian dynamics, Computer Methods in Applied Mechanics and Engineering, vol. 347, pp. 906–927, 2019.
  5. J. Chabassier, P. Joly, Energy preserving schemes for nonlinear Hamiltonian systems of wave equations: Application to the vibrating piano string, Computer Methods in Applied Mechanics and Engineering, Vol. 199(45):2779–2795, 2010
  6. S. Bilbao, Numerical Sound Synthesis, John Wiley and Sons, Chichester, UK, 2009