The PhD thesis of A. Falaize is funded by UPMC, ED 130 (ÉDITE), Paris.

This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC-BY) license (http://creativecommons.org/licenses/by/4.0/).

We present a method that generates passive-guaranteed stable simulations of analog audio circuits from electronic schematics for real-time issues. On one hand, this method is based on a continuous-time power-balanced state-space representation structured into its energy-storing parts, dissipative parts, and external sources. On the other hand, a numerical scheme is especially designed to preserve this structure and the power balance. These state-space structures define the class of port-Hamiltonian systems. The derivation of this structured system associated with the electronic circuit is achieved by an automated analysis of the interconnection network combined with a dictionary of models for each elementary component. The numerical scheme is based on the combination of finite differences applied on the state (with respect to the time variable) and on the total energy (with respect to the state). This combination provides a discrete-time version of the power balance. This set of algorithms is valid for both the linear and nonlinear case. Finally, three applications of increasing complexities are given: a diode clipper, a common-emitter bipolar-junction transistor amplifier, and a wah pedal. The results are compared to offline simulations obtained from a popular circuit simulator.

The characteristic input-to-output behavior of analog audio circuits (timbre, transitory) rests on the possibly highly nonlinear components appearing in such systems. These components make the stability of the simulations difficult to guarantee. The motivation of this work stems from the following observations:

Analog circuits combine energy-storing components, dissipative components, and sources.

Storage components do not produce energy, and dissipative components decrease it.

In this sense, analog circuits can be considered as passive systems with external power supply. We shall exploit this passivity property by transposing it to the digital domain, ensuring the stability of the simulations (see [

The available approaches for the automated derivation of physical modeling and numerical simulation of audio circuits can be divided in two classes [

The class of KV methods for audio circuits encompasses nonlinear state-space representations [

In this paper, we consider the

The port-Hamiltonian structure is derived by applying the Kirchhoff’s laws to a given schematic, similarly to other existing approaches (e.g., WDF and K-method). Here, the advantage of the PHS formulation is the direct encoding of the underlying passive structure. This passivity property is transposed to the discrete-time domain by appropriate numerical methods, so as to ensure the numerical stability. For linear storage components (inductors and capacitors), the combination of the PHS structure with any of the trapezoidal rule or the mid-point rule yields the same numerical scheme that preserves the passivity in discrete-time. For nonlinear storage components, we propose the use of the

This paper is organized as follows.

First and foremost, we provide an introduction to the

Denote

The port-Hamiltonian approach is used to decompose such open physical systems in (i) a set of

Electronic circuit components are sorted as (or can be a combination of):

internal components that store energy

internal components that dissipate power

external ports that convey power

The behavior of each component is described by a relation between two

The energy

The power

The power instantaneously provided to the system through external port

The interconnection of the components is achieved by relating all the voltages and currents through the application of the Kirchhoff’s laws to the interconnection network (schematic). This defines a conservative interconnection, according to Tellegen’s theorem recalled below (see also [

A direct consequence of (

The above description of storage components, dissipative components, and source, along with the conservative interconnection stated by the Kirchhoff’s laws, constitute the minimal definition of a port-Hamiltonian system (PHS) (see [

Then,

expresses the conservative power exchanges between storage components (this corresponds to the so-called

expresses the conservative power exchanges between dissipative components;

expresses the conservative power exchanges between ports (direct connections of inputs to outputs);

expresses the conservative power exchanges between the storage components and the dissipative components;

expresses the conservative power exchanges between ports and storage components (input gain matrix);

expresses the conservative power exchanges between ports and dissipative components (input gain matrix).

The PHS (

We have

Consider the resistor-inductor-capacitor (RLC) circuit in

Applying Kirchhoff’s laws to this simple serial circuit yields

From the constitutive laws of components, this equation restores the form (

This work aims at simulating such passive systems by firstly generating Equation (

This section provides a method to translate the description of a circuit (components and interconnections) from a netlist in a Spice-style [

from a netlist (

from (

Step 1 is standard. The presentation focuses on convention choices and details our procedure. In step 2, we propose an algorithm that analyzes if Formulation (

Each line of a netlist describes an element of the corresponding schematic, with: identification label, list of connection nodes, type of element, and list of parameters. We divide netlists into two blocks: internal components (dissipative and storage) and external ports (supplies and ground). In the first block (components), each line includes a reference to the appropriate entry in the dictionary and a list of the parameters for the corresponding model. Each line of the second block (external ports) provides the label of the externalized node, the type of supply (voltage or current), and the symbol∼if the supply is modulated (typically, the input signal), or a value if constant (typically, a battery).

As an example, the netlist corresponding to the circuit in

A graph

More generally,

The graph corresponding to a given circuit is derived from its netlist description in two steps:

build the

introduce a reference node

Typically,

As an example, the construction of the graph in

We assign to each branch

As an example, the incidence matrix for the circuit described in

Since the reference potential

The PHS structure (

In

Suppose the control type of every edge is known, and the set of edges is split according to

This leads to a rewrite of the Kirchhoff laws (

From the relation on the voltages in (

The PHS (

From the invertibility condition on _{2} in Proposition 1, we state the following remark, which is used in the sequel to derive the

This section introduces an algorithm that selects the appropriate control type for each dissipative edge so that the partition

Consider the current-controlled edge

Then, a given graph is realizable if the type of each resistor can be selected so that the following set of constraints is fulfilled.

The potential on each node

Each Current-controlled edge

No edge imposes the reference potential

No voltage-controlled edge

Constraints (C1–C2) ensure that

Then the non-zero elements in

As an example, the realizability analysis for the system in

In steps 3–7, the set of edges

The realizability matrix after step 11 in Algorithm 1 is

After step 19, the algorithm concludes that the potential on node

This concludes the realizability analysis. To recover the associated port-Hamiltonian structure, we return to the incidence matrix Γ. With the new edges ordering

Finally, the structure (

This section is devoted to the discrete-time simulation of the algebraic-differential system (

First, we present the design of a numerical scheme that properly transposes the power balance (

To ensure the stable simulation of stable dynamical system

This is the case of the forward difference scheme, for which first order approximation of the differential applications

A discrete chain rule is indeed recovered

In this paper, we consider the class of the PHS composed of a collection of linear energy storing components, with quadratic Hamiltonian

Injecting the numerical scheme (

Given

In this paper, we use the Newton–Raphson algorithm, which iteratively approximates the nearest root of function

Finally, denoting by

In this section, the proposed approach (PHS structure combined with the discrete gradient method) is compared with two standard methods: the

First, notice that for quadratic Hamiltonian

As a consequence, these three methods induce the same frequency warping (see [

We focus on the nonlinear case. For comparison, we choose a simple nonlinear conservative system with state

In each case, the resulting implicit equations are solved by Python iterative solver (see [

This section is devoted to the simulation of three analog audio circuits by the application of Algorithms 1 and 2. Those circuits are a diode clipper, a common-emitter BJT audio amplifier, and a wah-pedal as a full device. Results obtained with (i) the method in

Diode clipper circuits can be found in several audio-distortion devices. They are made of one resistor and two diodes (

The simulation is performed according to Algorithm 2 at the sample rate

Common-emitter bipolar-junction transistor (BJT) amplifiers are widely used as amplification stages in analog audio processing. They are made of two capacitors (

The system is reduced according to

This section addresses the simulation of a full device (namely the Dunlop Cry-Baby wah pedal) to be used in real time. The circuit is given in Figure 9. It provides a continuously varying characteristic

The system is reduced according to

Secondly, a VST plugin [

We have established a method to automatically recast an analog audio circuit into PHS formalism, which guarantees passivity of the continuous time model. The generation of the PHS from a given schematic lies on two points:

the graph theory to describe the interconnection network of a given circuit’s schematic,

a dictionary of elementary components which are conformable with PHS formalism.

Then, we transposed this physical principle to the digital domain by properly defining the discrete gradient of the Hamiltonian, such that a discrete time version of the power balance is satisfied. The resulting stable numerical scheme is of second order (restoring the midpoint rule for linear systems). It has been shown that the K-method is always applicable to PHS (providing efficient implementations of the implicit relation due to the proposed numerical scheme).

Offline simulations are consistent with LT-Spice results. The whole method allows the automatic generation of

A first perspective on this work is to consider higher-order numerical schemes (namely, the class of Runge–Kutta schemes). Moreover, it would be possible to symmetrize the roles of the voltages and the currents at the interconnection by applying the

The authors acknowledge the members of the french National Research Agency project HaMecMoPSys for support in port-Hamiltonian theory. Also, the authors acknowledge Robert Piechaud and Mattia Bergomi for careful proofreading.

The scientific work has been achieved by both authors at IRCAM Laboratory, Paris, within the context of the French National Research Agency sponsored project HaMecMoPSys. Further information is available at

The authors declare no conflict of interest.

The dimension of system (

Defining

Indeed, matrix

The system (

The dictionary is given in

Dictionary of elementary components.

Inductance | |||||

Capacitance | |||||

Resistance | |||||

Conductance | |||||

PN Diode | |||||

NPN Transistor | |||||

Potentiometer |

Such components are defined by their storage function

The characteristics of dissipative components are algebraic relations on

PN junctions are modeled as voltage-controlled components by the Shockley equation:

NPN junctions are passive 3-ports, with dissipated power

Incidence matrices for 2-ports, potentiometer P, and transistor Q with conventions of

A generalization of the discrete gradient for multi-variate Hamiltonians such that Equations (

For mono-variate components, (

Resistor-inductor-capacitor (RLC) circuit (notations and orientations).

Schematic and corresponding graph of a simple bipolar-junction transistor (BJT) amplifier with feedback. The grey part corresponds to the components, and the outer elements correspond to the external ports, or sources (as in

Definitions and orientations for a single current-controlled edge

Simulation results and comparison of the methods in

Simulation (

Simulation (

Results for the common-emitter BJT amplifier with feedback (

Simulations of the Cry-Baby’s circuit of

Schematic of the Cry-Baby wah pedal. Note the IN/OUT terminals and the 9 V supply. The potentiometer

Example of a netlist corresponding to the circuit in

Line | Label | Node List | Type | Parameters |
---|---|---|---|---|

CapaLin | ||||

Resistor | ||||

NPN_ Type1 | ||||

Vcc | Voltage | 9 | ||

IN | Voltage | ∼ | ||

OUT | Current | 0 | ||

GRD | Voltage | 0 |

Sorting components according to their realizability.

Component type | Current-Controlled | Voltage-Controlled |
---|---|---|

storages | capacitor | inductor |

resistors | resistance | conductance |

nonlinear | diodes, transistors | |

sources | voltage source | current source |

Updates for the three methods considered in §4.3. PHS stands for port-Hamiltonian system.

Method | Update |
---|---|

Trapezoidal rule | |

Midpoint rule | |

PHS with discrete gradient |