VOL. 2, NO. 4, DECEMBER 2 Nonlinear audio transformer simulation using approximation of differential equations Jaromir Macak Department of Telecommunications FEEC, Brno University of Technology Email: jaromir.macak@phd.feec.vutbr.cz Abstract Digital simulation of audio transformers based on an approximation of differential equations is discussed in this paper. A simplified model of the audio transformer without leakage inductance is designed. The model is described using nonlinear differential equations and state-space approach with memoryless nonlinearity. The transformer core is modeled by Jiles-Atherton and Frohlich models. The whole system is approximated in order to reduce computational complexity. Introduction Transformers are inseparable part of many electronic devices used by musicians. They can be found for instance in several amplifiers, audio effects, etc. The transformers are often a part of power supply circuits and therefore, they can be mostly neglected in simulations of these electronic devices. However, there are situation where the transformers are connected directly in an audio path. This is case of input and output stages of some electronic devices where the transformers are used as asymmetrical to symmetrical or symmetrical to asymmetrical converters. These types of transformers can be also found in tube power amplifiers where their main function is to match high output impedance of used tubes to low input impedance of a loudspeaker. Although designers of the audio transformers try to minimize distortion effect of the transformers in order to get the transparent signal path, presence of the transformer can be often heard and even sometimes it is required by musicians and audio engineers. The main reason for this is the characteristic nonlinear distortion caused by soft saturation of the transformer core when a large magnetization occurs. However, the saturation effect is not the only one that manifests in the output signal, hysteresis effect and frequency properties also have to be included in the simulation. Several papers deals with the nonlinear simulation of transformers. However, most of them discusses the power transformers. Highly simplified audio transformer models were used in [, 2, 3] where vacuum-tube power amplifiers were simulated. An ideal transformer (linear, without losses and frequency distortion) is used in []. A linear transformer model with primary and secondary winding inductances and a primary leakage was used in [2] and the complete model of a linear transformer was implemented using wave digital filters (WDF) in [3]. The complete nonlinear model of a vacuum-tube amplifier output transformer is described in [4]. This model is implemented using nonlinear WDF and is based on the gyrator-capacitor model [5] that is extended by using nonlinear capacitor and resistor that model core permeance and hysteresis losses. The paper also discusses parameter fitting for specified transformers. In this paper, a simplified nonlinear transformer model described in time domain is discussed. The transformer is described using nonlinear differential equations. In order to simulate nonlinear behavior of the audio transformer, nonlinear Frohlich and Jiles-Atherton core models are used [6, 7]. The differential equations are discretized by backward Euler method and discrete state-space approach with memoryless nonlinearity that has been recently applied for simulation of several analog audio effects [8, 9,, ]. The main advantage of K-method family is reduction of necessary equations only to number of nonlinear equations in the system, which can be useful when the simulated system contains more inputs (signal inputs, state variables) than number of nonlinear equations. Considering real-time simulation, the technique for precomputation and approximation of the solution of a nonlinear dynamic system can be used in order to reduce computational cost of the simulation algorithm (see e.g. [2]). 2 Transformer Model Input stages of the most of the professional audio equipment contain transformers used as converters from a symmetrical to an asymmetrical signal. This type of the audio transformer consists of two primary windings and one secondary winding. The circuit schematic of the transformer connected with two voltage sources, which represent the symmetrical signal, is shown in figure. The resistors R p and represent the primary coil resistance, the resistor R s is a series combination of the secondary coil resistance and the load resistance. Symbols N p, N p2 and N 3 are numbers of turns of the windings. A leakage inductance as well as a capacitance of the windings are neglected in this model. However, the audio transformers should be designed in that way that the in- 22
VOL. 2, NO. 4, DECEMBER 2 R p U p I p N p I s R s dt = N s S, (8) U in U in2 I p2 N p2 U p2 Figure : Transformer connected with a symmetrical voltage signal source. fluence of the leakage inductance and the capacitance does not manifest in the audible region. 2. Differential equations for transformer An ideal transformer is considered to be an impedance divider that transforms input voltages U p and currents I p to output and I s according to U p = N p N s = I p I s. () However, a real transformer is far away from the ideal one. For an accurate simulation, losses caused by hysteresis and core saturation have to be considered and therefore, magnetic circuit has to be taken into account. According to Amper s law, the magnetizing force H is i H = N ii i (2) l mag where l mag is the length of the induction path. In this case, the term (2) can be expanded into Hl mag = N p I p N p2 I p2 I s. (3) The flux density B for the secondary winding is computed from Farraday s law dt = N s S where S is the transformer core cross-section. The circuit schematic in figure contains five unknown variables U p, U p2,, B and H. Therefore, the following five equations are necessary for the solution of the system Hl mag = N p U in U p R p + N p2 U in2 U p2 (4) R s, (5) dt = U p N p S, (6) dt = U p2 N p S, (7) B = µh. (9) The first equation is obtained from (3) where the currents I p and I p2 are computed using Ohm s law from input voltages U in and U in2. Equations (6), (7) and (8) are obtained using Farraday s law for different voltages and equation (9) describes the transformer core behavior. If the model operates with small signals, then permeability µ is considered as a constant and the whole system is linear. However, permeability µ varies with magnetizing force H and flux density B for large signals and a nonlinear model of the core has to be used in order to describe this nonlinear behavior. 2.2 Transformer core models The well-known nonlinear relation B = µh can be implemented using several algorithms [3, 4, 5, 6, 7, 8]. The Frohlich equation [6] provides a simple approximation of transformer core permeability. The Frolich equation is given by H B = () c + b H where c, b are parameters derived from material properties from equations c = µ i µ () and b = µi B SAT (2) where µ i is initial relative permeability, µ is free space permeability and B SAT is saturation flux density. The B- H curve of the Frohlich model for parameters µ i = 2e 3, B SAT =.3 is shown in figure 2. As can be seen, the Frohlich model allows simulation of the core saturation but does not support simulation of the hysteresis loop. When simulating hysteresis, one can use e.g. Jiles- Atherton model [7]. Unfortunately, direct usage of this model sometimes leads to generation of minor loops with nonphysical behavior [9]. Therefore, a J-A model modified in [9] can be used in order to remove the nonphysical minor hysteresis loops. Magnetization M of the core is obtained from dm dh = δ M an M M + c dm an kδ dh (3) where M an is anhysteretic curve given by Langevin function ( ) ) H + αm a M an = M s (coth (4) a H + αm and parameter δ is obtained from δ = sign(dh/dt). (5) 23
VOL. 2, NO. 4, DECEMBER 2.5 3 Discretization using backward Euler method To implement the transformer model in the digital domain, the set of differential equations (5), (6), (7), (8) and (9) has to be discretized. This can be made using e.g. backward Euler formula y[n] = y[n ] + f(y[n]) (7).5 3 2 2 3 H [Am ] Figure 2: B-H curve of the Frohlich model. Parameters M s, α, a, c and k are derived from material properties and their identification can be found e.g. in [2, 2]. Parameter δ M = when the nonphysical minor loop is going to be generated alternatively δ M = [9]. Flux density is obtained from B = µ (M + H). (6) The B-H curve of the Jiles-Atherton model for parameters from table is shown in figure 3..5 where n denotes the time index and is sample period. Then, the discretized equations with the Frohlich model are H[n]l mag = N p U in [n] U p [n] R p + + N p2 U in2 [n] U p2 [n] [n] R s, (8) B[n] = B[n ] + U p [n] N p S, (9) B[n] = B[n ] + U p2 [n] N p S, (2) B[n] = B[n ] + [n] N s S, (2) B[n] = H[n] c + b H[n]. (22) The solution of this system can be transfered into a root finding problem and subsequently, a numerical algorithm, e.g. Newton-Rahpson algorithm, can be used. If the J- A model is used, the equation (22) is replaced by (6). However, the J-A model requires computation of derivate of magnetizing force H in (3). Therefore, the equation (6) is modified into form B[n] = µ {f JA (H[n], H[n ], M[n ]) + H[n]} (23).5 3 2 2 3 H [Am ] Figure 3: B-H curve of J-A model. Table : Parameters for the Jiles-Atherton model of the transformer core. M s a α c k. 6 8.56 8.82 5.4 5.65 where function f JA (H[n], H[n ], M[n ]) is the equation (3) and is solved numerically using algorithm presented in [22]. Value H[n ] is magnetizing force in the last sample period and M[n ] is magnetization of the transformer core in the last sample period. However, the magnetization M[n ] can be derived from flux density B[n ]. For the real-time implementation, the system of difference equations (8), (9), (2), (2) and (22) can be pre-computed and subsequently approximated according to the algorithm presented in [2]. If the Frohlich model is used, the transformer model has five unknown variables and three input values U in [n], U in2 [n] and B[n ]. The input voltages U in [n], U in2 [n] in (8) can be merged into one input current I in resulting in H[n]l mag = I in N p U p [n] R p N p2 U p2 [n] [n] R s (24) 24
VOL. 2, NO. 4, DECEMBER 2 where I in = N p U in [n] R p + N p2 U in2 [n]. (25) Consequently, the system can be considered as a system with two inputs. The solution is numerically pre-computed for different values of input variables and stored in lookup tables. Then, an approximating function of two input variables can be designed and used for obtaining of output values. Consequently, the simulation algorithm consist of the output signal computation given by [n] = f approx (I in [n], B[n ]) (26) and from the state update function given by B[n] = f approx2 (I in [n], B[n ]) (27) where n is the time index. If the J-A model is used, two state variables are required. The model consists of following equations and [n] = f approx (I in [n], B[n ], H[n ]), (28) B[n] = f approx2 (I in [n], B[n ], H[n ]) (29) H[n] = f approx3 (I in [n], B[n ], H[n ]). (3) The function f approx, f approx2 or f approx3 can be any approximating function, e.g. spline approximation or linear interpolation. During the implementation of the algorithm, bounding values of input variables have to be determined as well as a step of input variables. The bounding values of input variables are derived from maximal values. The bounding values of input current are determined according to a concrete usage of the algorithm. The bounding values of state variables are determined on the base of preceding numerical solutions of the equations for minimal and maximal values of input voltages. The step of input variables can be empirically determined from maximal allowed numerical error between approximated solution and numerical solution of the given system. The simulated system was pre-computed and approximated for values of circuit elements listed in table 2. The Frohlich model was chosen because pre-computation using the Jiles-Atherton model brought problems with numerical solution for certain combination of values of input variables. Furthermore, usage of the Frohlich model provides lower computational complexity and lower memory demands. The solution of the system for different values of flux density is shown in figure 4 where flux density B <.3,.3 > T. u s [V] 3 2 2 B =.3 T B =.3 T 3 2 5 5 5 5 2 u in [V] Figure 4: Solution of the system for different values of the flux density. Subsequently, the solution in figure 4 was approximated using combination of spline approximation and linear interpolation. The details about this approximation can be found in [2]. The splines were used for approximation of I in, relation and linear interpolation was used for interpolation between the splines computed for different values of flux density B. Finally, the spline coefficients for different I in and B values were stored in look-up tables. The step, minimal and maximal values of the input variables are specified in table 3. For the Frohlich model, the look-up table is 2D table containing 2 rows and 3 columns and each cell contains cubic spline coefficients. The total size of the look-up table is 24924 coefficients and approximately 9 kb. Table 3: Look-up table for the approximated solution of the simulated system. Variable Min. Max. Step Intervals I in [A] 2 2.2 2 B[T]. 3 4 State-space approach with memoryless nonlinearity The main principle of the state-space approach with memoryless nonlinearity is separation of the linear dynamic part and memoryless nonlinear part of the simulated system. This method was developed by Borin [23] and is known as a K-method. The simulated system is described by equations ẋ = ax + bu + ci, (3) Table 2: Schematic values of the simulated circuit. R p,2 [Ω] N p,2 R s [Ω] N s S[cm 2 ] l mag [cm] 8 5 26 3 i = f(v), (32) V = dx + eu + fi (33) 25
VOL. 2, NO. 4, DECEMBER 2 where x is vector of state variables, u is vector of inputs and i is contribution of the nonlinear functions. Matrices a, b and c are coefficient matrices. Equation (32) represents memoryless nonlinear function and V is vector of inputs to the nonlinear function. Matrices d, e and f are again coefficients matrices. The output vector y is obtained from y = a o x + b o u + c o i (34) where a o, b o and c + o are coefficient matrices. The next step is discretization of differential equation (3). The process of discretization can be found in [8]. However, it is also possible discretizate time derivations at first and then build coefficient matrices of the K-method this approach is known as DK-method [8]. Both approaches lead to final implicit nonlinear equations = p + Kf(V) V (35) where p is input vector and K coefficient matrix derived in [8]. These equations have to be solved numerically. During derivation of coefficient matrices, first of all the time derivative is replaced by time difference dt = B[n] B[n ] (36) Then the unknown voltages U p,u p2, are isolated from equations (9), (2) and (2) and substituted into (8), which leads to equation ( H[n] = N p 2 S N p2 2 S R p l mag l mag B[n] B[n ] + + N p U in [n] R p l mag + N p2 U in2 [n] l mag. 2 S R s l mag ) (37) The magnetizing force H is input of the nonlinear function, vector of state variables is x = [B[n ]] (38) The coefficient matrices a, b and c are derived from (36) as ] a = [ Ts, (43) b = [], (44) [ c = ], (45) and coefficient matrices a o, b o and c o are obtained from (2) as [ a = N ] ss, (46) and b = [], (47) [ ] Ns S c = Finally, equation (35) is in form where (48) = p + K f(h[n]) H[n] (49) p = dx + eu, (5) K = f (5) and the nonliner function f(h[n]) is given by Frohlich model (). The solution of (49) for unknown magnetic flux B can be precomputed for different values of parameter p and stored in -D look-up table 4. The solved nonlinear function is shown in figure 5..5 and input vector is e = [ Uin [n] U in2 [n] ] (39).5 The coefficient matrices d, e and f are derived by comparing equations (37) and (33) as [( 2 Np S d = + N p2 2 S + N s 2 ) ] S, (4) R p l mag l mag R s l mag [ e = N p R pl mag ] N p2 l mag, (4) [( f = N p 2 S N p2 2 S 2 ) ] S. (42) R p l mag l mag R s l mag 2.5.5 2 p [ ] x 5 Figure 5: Solution of nonlinear function (49) for different values of parameter p. The range of parameter p is p < p max, p max > where p max = max + eu inmax. (52) 26
VOL. 2, NO. 4, DECEMBER 2 Table 4: Look-up table for the approximated solution of DK-method Variable Min. Max. Step Intervals p[ ] 2 2 2 4. Sensitivity to coefficient variation The designed algorithm from previous chapter works properly with a given sampling frequency but cannot be used with different sampling frequencies because the coefficient matrices depend on the value of the sampling frequency. Therefore, the solution must be precomputed for each particular sampling frequency, which brings higher memory demands for storing of approximation coefficients. To cope with this problem, the solution of the system for different values of the sampling frequency was compared (see figure 6 where the solution for sampling frequencies f s = 48 khz and f s = 96 khz is shown). It was found that the shape of the function is very similar and has only different scaling. This is due to fact that the nonlinear function is the same and only weighing coefficients are changed with value of the sampling frequency. Therefore, the nonlinear function can be approximated only once and the other nonlinear functions can be obtained using different scaling factor. This property significantly reduces memory demands of the algorithm while the computational cost remains almost the same (only one extra multiply mathematical operation). In case of figure 6, the scaling factor was.5 for sampling frequency 2-times higher. 5 Simulation Results The implemented algorithm was tested using several types of the input signals harmonic signal, log-sweep signal and musical signal. Because the main aim is to simulate nonlinear behavior, the input signals that cause the full saturation of the transformer core were chosen. Figure 7 shows the input signal and signals on the primary and secondary windings for the direct differential equation approximation. The input signal was a sinewave signal with a frequency of 5 Hz, an amplitude of 2 V and a samplerate of 48 khz. The time dependence of flux density is also shown in figure 7. One can see the saturation of the transformer core. The algorithm was also tested using a log sweep-signal with an amplitude of 2 V. The logarithmic spectrogram of the output signal is shown in figure 9. The nonlinear distortion of the output signal occurs in the area of low frequencies. The output signals for the same system simulated using state-space approach with memoryless nonlinearity are shown in figure 8. The numerical solution without the approximation of both models is shown in figure. Although the influence of the hysteresis effect is observable, one can see that both models provide very similar results, even when the transformer core is fully saturated, and therefore, the model without hysteresis can be used for the transformer simulation. The difference between approximated solution and numerical solution depends on the chosen grid of approximating function. In this case, the error of output signal was about. V. f s = 48 khz 2 U in.5 f s = 96 khz U p U [V].5 3 2 p [ ] 2 3 x 5 2.2.4.6.8. t [s].5 f s = 48 khz f s = 96 khz scaled.5.5.5.2.4.6.8. t [s] 3 2 2 3 p [ ] x 5 Figure 6: Solution of nonlinear function (49) for different values of parameter p and different sampling frequencies. Figure 7: Output signal for input sinewave signal with a frequency of 5 Hz and an amplitude of 2 V. The input signal, the signal on primary and secondary windings (top) and the time dependence of the flux density (bottom) are shown. 27
VOL. 2, NO. 4, DECEMBER 2 2 2 U in U in 5 U p 5 U p JA JA U p Frohlich Frohlich 5 5 U [V] 5 5 5 5 2.2.4.6.8..2 U [ ] 2..2.3.4.5.6.7 t [s] Figure 8: Output signal of state-space approach for input sinewave signal with a frequency of 5 Hz and an amplitude of 2 V. f [Hz] 248 24 52 256 28 64 32 6 8 4.5 2 2.5 3 t [s] Figure 9: Spectogram of the output signal for input log sweep-signal with an amplitude of 2 V. The FFT window size is 248 samples. 6 Conclusion The simplified nonlinear model of the audio transformer was implemented in this paper. The transformer consists of two primary windings and one secondary winding. Two different methods were used for the simulation direct solution of differential equations and state-space approach with memoryless nonlinearity. The main advantage of state-space approach is reduction of necessary inputs into the system. Thus, smaller look-up tables can be used with this method, which is related to lower computation demands. However, this method requires memoryless nonlinearity, which is not the case of Jiles-Atherton model. The Frohlich and Jiles-Atherton nonlinear core models were used in method based on direct solution of differential equations. The Jiles-Atherton model is more accurate. However, it requires higher computational complexity and higher memory demands. Foremost the pre-computation of the solution brings problems with stability of the nu- 2 2 4 6 8 Figure : The comparison of the simulation using the Frohlich and Jiles-Atherton model. The input signal was a sinewave signal with a frequency of 5 Hz and an amplitude of 2 V. merical solution. Therefore, only the Frohlich model was chosen for the implementation. The designed algorithm was tested in real-time using several input signals. The usage of the pre-computation and approximation of the solution of the system provides low and constant computational complexity and also stability of the algorithm because the are no iterations of a numerical method inside the algorithm. The algorithm is capable to work in real time. The algorithm also shows the behavior expected for nonlinear transformer model. 7 Acknowledgments This paper was supported by project no. FR-TI/495 of the Ministry of Industry and Trade of the Czech Republic. Literatura [] J. Macak and J. Schimmel, Real-time guitar tube amplifier simulation using approximation of differential equations, in Proceedings of the 3th International Conference on Digital Audio Effects DAFx, Graz, Austria, Sep. 6-, 2. [2] I. Cohen and T. Helie, Real-time simulation of a guitar power amplifier, in Proceedings of the 3th International Conference on Digital Audio Effects DAFx, Graz, Austria, Sep. 6-, 2. [3] J. Pakarinen, M. Tikander, and M. Karjalainen, Wave digital modeling of the output chain of a vacuum-tube amplifier, in Proc. of the Int. Conf. on Digital Audio Effects (DAFx-9), Como, Italy, Sept. 4, 29. [4] R. C. D. de Paiva, J. Pakarinen, V. Välimäki, and M. Tikander, Real-time audio transformer emulation 28
VOL. 2, NO. 4, DECEMBER 2 for virtual tube amplifiers, EURASIP Journal on Advances in Signal Processing, vol. 2, pp. 5, 2. [5] D. C. Hamill, Gyrator-capacitor modeling: a better way of understanding magnetic components, in Proceedings of the 9th Annual Applied Power Electronics Conference and Exposition (APEC 94), Feb. 994, pp. 326 332. [6] S. E. Zocholl, A. Guzman, and D. Hou, Transformer modeling as applied to differential protection, Tech. Rep., Schweitzer Engineering Laboratories, Inc. Pullman, Washington, 999. [7] D. C. Jiles and D. L. Atherton, Ferromagnetic hysteresis, IEEE Transactions on Magnetics,, no. 5, pp. 283 285, 983. [8] D.T. Yeh, J.S. Abel, and J.O. Smith, Automated physical modeling of nonlinear audio circuits for realtime audio effects - part i: Theoretical development, Audio, Speech, and Language Processing, IEEE Transactions on, vol. 8, no. 4, pp. 728 737, may 2. [9] T. D. Yeh and J. O. Smith, Simulating guitar distortion circuits using wave digital and nonlinear statespace formulations, in Proc. Digital Audio Effects (DAFx-8), Espoo, Finland, Sept. -4 28. [] M. Holters and U. Zölzer, Physical modelling of a wah-wah effect pedal as a case study for application of the nodal dk method to circuits with variable parts, in Proc. Digital Audio Effects (DAFx-), Paris, France, Sept. 9-23 2. [] K. Dempwolf, M. Holters, and U. Zölzer, Discretization of parametric analog circuits for real-time simulations, in Proc. Digital Audio Effects (DAFx-), Graz, Austria, Sept. 6-2. [2] J. Macak and J. Schimmel, Real-time guitar preamp simulation using modified blockwise method and approximations, EURASIP Journal on Advances in Signal Processing, vol. 2, pp., 2. [3] E. Sarospataki and M. Kuczmann, Realization of the jiles-atherton hysteresis model applying the labview and matlab software package, Electrical Engineering, vol. 57, pp. 4 43, August 26. [4] CH. Wong, A dynamic hysteresis model, IEEE Transactions on Magnetics, vol. 24, pp. 966 968, MArch 988. [5] M. L. Hodgdon, Applications of a theory of ferromagnetic hysteresis, IEEE Transactions on Magnetics, vol. 24, no., pp. 28 22, January 988. [6] M. L. Hodgdon, Mathematical theory and calculations of magnetic hysteresis curves, IEEE Transactions on Magnetics, vol. 24, no. 6, pp. 28 22, November 988. [7] S. R. Naidu, Simulation of the hysteresis phenomenon using preisach s theory, IEEE Proceedings, vol. 37, no. 2, pp. 73 79, March 99. [8] K. H. Carpenter, A differential equation approach to minor loops in the jiles-atherton hysteresis model, IEEE Transactions on Magnetics, vol. 27, no. 6, pp. 444 446, November 99. [9] P. Kis, Jiles-Atherton Model Implementation to Edge Finite Element Method, Ph.D. thesis, Budapest University of Technology and Economics, 2. [2] D. C. Jiles, J. B. Thoelke, and M. K. Devine, Numerical determination of hysteresis parameters for the modeling of magnetic properties using the theory of ferromagnetic hysteresis, IEEE Transactions on Magnetics, vol. 28, no., pp. 27 35, 992. [2] D. C. Jiles and J. B. Thoelke, Theory of feromagnetic hysteresis: Determination of model parameters from experimental hysteresis loops, IEEE Transactions on Magnetics, vol. 25, no. 5, pp. 3928 393, September 989. [22] N. Chiesa, Power Transformer Modeling for Inrush Current Calculation, Ph.D. thesis, Norwegian University of Science and Technology, 2. [23] G. Borin, G. De Poli, and D. Rocchesso, Elimination of delay-free loops in discrete-time models of nonlinear acoustic systems, IEEE Speech Audio Process, vol. 8, no. 5, pp. 597 65, September 2. 29