## Simulanalog.org

State variable changes to avoid non computational issues

**Abstract**
fer function, like the grid of a triode. But the ideas we aregoing to expose will remain the same.

This paper is about the numerical simulation of nonlinearanalog circuits with ”switch” components, such as diodes.

A ”switch” component is an electrical device that may ormay not conduct, depending on the state of the circuit. Theproblem with ”switch” components is that the topology ofthe circuit is variable and so, apparently, it is not possibleto describe the system with a single differential equationand solve it using standard numerical methods. This papershows how to choose an appropriate state variable and over-come the above difficulties.

**A test example**
Let’s consider the following circuit.

*Figure 2: Nonlinear transfer function*
Let’s call

*id *the current flowing into the diodes and

*vd*
the voltage on the diode. A standard way to proceed intothe analysis of the circuit, is to take the current

*i *will be as
the state variable of the system. The equations of the systemwill become:
If the voltage on the diodes is below their threshold,
no current is flowing through the diodes and so no current
is flowing into the resistor and the capacitor; the circuit is
open. When the voltage gets higher than the diode thresh-
Where

*vc *is the voltage on the capacitor and

*vd *is the voltage
old, the circuit becomes a standard RC filter. We have just
on the diodes. Remembering that

*i *is the state variable, in
seen two different topologies that the same circuit can have,
order to be integrated, the above system should be written
The couple of diodes has a memory-less nonlinear trans-
fer function, like the one in figure 1. Note that the cur-

*i*(

*s*)

*ds − f −*1(

*i*) = 0
rent circuit is only an example and so, instead of diodes, wecould have other switch components with a different trans-
But this is not possible because

*id *=

*f *(

*vd*) is not invertible.

But actually, this is not a real issue. All we have to do is
the bilinear transform method. One of its main advantages
choosing another state variable. Taking

*vd*, the system can
is that it is a one step method but it has quadratic order of

*k−ek−*1

*−yk*+

*yk−*1 = (
Now the equation has a valid analytic form.

And, after rearranging the terms, the equation becomes:

*−Af *(

*yk*)

*− K *=

*yk*
**Analysis of the solution**
The aim of this section is to give an example of how we can
study if the solution of (1) exist and is unique. First of all
(1) should be rewritten in differential form:

*K *=

*ek−*1

*− ek *+ (
We can easily see that there exist one and only one so-

*d *= 1 +

*f *(

*vd*)

*R*
Then we have to require that the second term of this equa-

*f *(

*yk*) =

*−A−*1(

*yk *+

*K*)
tion is continuous and satisfies the Lipschitz condition. Tohave continuity, the denominator should satisfy
we note that the solution is the intersection of the graph of

*y *=

*f *(

*x*) and the line

*y *=

*−A−*1(

*x *+

*K*), as shown in the

*|*1 +

*f *(

*vd*)

*R| >*
For ”clipping” transfer functions like the one of diodes, it is

*f *(

*vd*)

*≥ *0 and so 1 +

*f *(

*vd*)

*R ≥ *1.

Instead of Lipschitz condition, we could ask that
This is a stronger condition; if it is satisfied, then also Lips-chitz condition is satisfied. It is easy to see that in clippingdevices, with

*f *(

*vd*)

*≥ *0, the above condition is true if andonly if

*f ∈ C*1.

Considering that in real applications

*f *is not defined an-
alytically, but is often a regular function interpolating somemeasurement point, asking

*f ∈ C*1 does not limit the valid-ity of this technique.

**The numerical discretization**
Because the lines have a negative slew and the nonlinear
transfer function is monotone with a positive slew, there is
Now we are ready to study a numerical technique to solve
only one point of intersection, and so the solution is unique.

(1). Let’s consider a discretization step of

*h*, such that
A solution of (2) can be easily found with standard nu-
merical methods, like Newton-Raphson or bisection algo-
rithm, which globally converge thanks to the regularity and
We want to find a sequence

*{yk} *that approximates the real
monotonicity of the function. A little trick to improve the
speed of convergence is to use a ”hot start” at each itera-tion; this consists in initializing the iterative methods using
the solution at the previous discretization point, which is afirst order approximation of the new solution.

Starting from equation (1), we have to give a numerical
approximation of the integral. A common choice in the au-dio applications is the trapezoidal rule, that corresponds to

**Comparison with a simplified method ***age of 20V peak to peak. The solid line is the exact simula-*
*tion. The dotted line is the simulation with the approximated*
In the previous sections we studied a very simple example
like a model; but in spite of its simplicity, the analysis andthe computational models are not elementary. Generally, inpractical applications like the signal processing in the mu-sical field, simplified models are used instead of the one
presented here. Giving up the possibility to obtain an exact
simulation of the circuit, they are computationally cheaper
and easier to implement. For example, the circuit consid-
ered in the previous sections can be approximated by a one
pole high pass filter (with cutoff frequency at
lowed by a nonlinear waveshaper with the transfer function
of the diodes. This solution is commonly used into the DSP
models in tube preamplifier simulators. So we may ask if
such an approximation can give sufficiently good accuracy.

We are going to present the results of a numerical ex-
periment that can be quite illuminating. The experimentis based on the same circuit of the previous sections, tak-
ing

*R *= 10

*K*Ω,

*C *= 22

*nF *and the generator

*e *as a sinesource with a frequency of 60Hz. For this circuit both the

*Figure 5: Simulation of the circuit with an input volt-*
exact and the simplified models have been built. In the first

*age of 0.5V peak to peak. The solid line is the exact simula-*
simulation, the amplitude of the source signal was 20V peak

*tion. The dotted line is the simulation with the approximated*
to peak, so the signal was heavily clipped by the diodes. In
the second run, the same circuit has been simulated using aninput voltage of 0.5V peak to peak. Here are the graphicswith the results:

**Conclusions**
In the first case (

*figure 4*) the source signal is heavily
clipped; this means that the diodes are conducing in about
This paper would like to introduce, from an operative point
all the period of the signal, current is flowing through the
of view, some aspects of the simulation of circuits with
capacitor and so the RC network is behaving like the HPF
”switching” components. It would not to be a complete the-
of the approximated model. But in the second case (

*figure*
oretic treatment, but it would like to give a complete exam-

*5*), diodes are not conducing, so in the real case no current
ple of how to build models when switching components are
is flowing through the RC network and no filtering effect
present, how to analyze them and give a numerical method
is performed. This is a big difference between the approxi-
for the simulation. This treatment can be applied without
relevant changes to all the saturating components, like tran-sistor, tubes and saturating magnetic cores, which are al-most all the nonlinearities found in audio applications.

**Acknowledgment**
we would like to thank Gianpaolo Borin who inspired this
work and Pierre Richemond for his revision.

**References**
John, H. Mathews, ”Numerical Methods for Mathe-matics, Sience, and Engeneering”, Prentice Hall, 1992
Morgan Jones, ”Valve Amplifiers”, Newnes, Reed Ed-
ucational and Professional Publishing, 1995

*Figure 4: Simulation of the circuit with an input volt-*
Charles Rydel, ”Simulation of Electron Tubes withSpice” in Preprint no.3965 of AES 98th Convention1995
G. Borin, G. De Poli, D. Rocchesso, ”Elimination offree delay loops in discrete-time models of nonlinearacoustic systems”, IEEE Trans. on Speech and AudioProcessing, vol 8, issue 5, September 2000, pp.597-605
T. Serafini, ”Metodi per la simulazione numericadi sistemi dinamici non lineari, con applicazioni alcampo degli strumenti musicali elettronici”, Univer-sita’ di Modena e Reggio Emilia, Italy, 2001 (MS The-sis)
Foti Frank, ”Aliasing Distortion in Digital DynamicsProcessing, the Cause, Effect, and Method for Mea-suring It: The Story of ’Digital Grunge!’ ”, in Preprintno.4971 of AES 106th Convention 1999

Source: http://www.simulanalog.org/statevariable.pdf

Sisters come to help mother after father's death. LearnThe story of Charlie's freshman year of high school:finding new friends, love, pain, parties and familydrama. A thoughtful look at growing up and makingWriter, American, and Jewish immigrant tell storiesShort stories set in small town Americana in 1943 withStory of survival in Colorado after a flu pandemicBaseball writer covering opening

4/24/09 EGPE CLUB Meeting Notes STOCKs to Study : AXP / GE / JOYG / NE / EWBC; To Switch Sell: SGP Club web address: http://egpeclub.home.comcast.net Club Total Value YTD P&L 360 Switch SELL Current Cash Balance: * Economic Leading Indicators & Lagging Indicators 10 Leading indicators: (1) stock prices, (2) interest rate spread (10-yr Treasury note rate - Fed rate), (3