## Symbolic Circuit Analysis with Analog Insydes

To execute this notebook you need the add-on package Analog Insydes by ITWM (see copyright message at end of document).

### Introduction

Symbolic circuit analysis is known to yield extremely large
expressions even for small circuits. To cope with expression
complexity, Analog Insydes provides special functionality for calculating simplified symbolic formulas which are small and easy to understand. Approximated symbolic expressions are computed by dropping numerically insignificant terms from circuit equations or transfer functions. Consider, for example, the common-emitter small-signal amplifier shown below. We will compute a simplified symbolic transfer function that contains only those terms which have dominant influence on the passband voltage gain.

Common-Emitter Amplifier

### Netlist and Models

First, we write a netlist of the circuit, specifying both symbolic and numerical values for the circuit elements. The numerical values are needed later as reference values for deciding which terms are important and which ones can be neglected.
`In[1]:= <<AnalogInsydes``
In[2]:= ceamp =
Circuit[
Netlist[
{V1,{1, 0}, 1}, (* Unit signal at input *)
{VCC, {6, 0}, Type -> VoltageSource, Value -> 0},
{C1,{1, 2}, Symbolic -> C1, Value -> 1.*^-7},
{R1,{2, 6}, Symbolic -> R1, Value -> 1.*^5},
{R2,{2, 0}, Symbolic -> R2, Value -> 4.7*^4},
{RC, {6, 3}, Symbolic -> RC, Value -> 2.2*^3},
{RE, {4, 0}, Symbolic -> RE, Value -> 1.*^3},
{C2,{3, 5}, Symbolic -> C2, Value -> 1.*^-6},
{RL, {5, 0}, Symbolic -> RL, Value -> 4.7*^4},
{Q1,{2 -> B, 3 -> C, 4 -> E},
Model -> NPNTransistor, Selector -> ACdynamic,
RBN -> 1.*^3, CMN -> 1.*^-11, betaN -> 200.,
RON -> 1.*^4}],
Model[
Name -> NPNTransistor,
Selector -> ACdynamic,
Ports -> {B, C, E},
Parameters -> {RB, CM, beta, RO, RBN, CMN,
betaN, RON},
Definition ->
Netlist[
{RB, {X, E}, Symbolic -> RB, Value -> RBN},
{CM, {B, C}, Symbolic -> CM, Value -> CMN},
{CC, {B, X, C, E}, Symbolic -> beta, Value -> betaN},
{RO, {C, E}, Symbolic -> RO, Value -> RON} ] ] ]
//ExpandSubcircuits;

### Symbolic Calculations

If we compute the exact symbolic transfer function, we obtain an expression with more than 100 terms. This expression yields absolutely no insight into circuit behavior.
`In[3]:=ceampmna =`
CircuitEquations[ceamp, SymbolicValues -> True];
MatrixForm/@ceampmna
Out[3]=

In[4]:=

`vout=Together[V\$5 /. First[SolveCircuitEquations[ceampmna, V\$5]]]`
Out [4]=
`In[5]:= Length[Denominator[vout]]+Length[Numerator[vout]]`
`Out[5]= 105`

### Simplification before Generation

To find a simple expression for the passband voltage gain, we use Analog Insydes' symbolic approximation functionality to approximate the system of circuit equations with respect to a frequency point in the passband (here ) and the given numerical element values. We allow for a maximum approximation error of 10% in that point.
`In[6]:= designpoint=MakeDesignPoint[ceamp]`
In[7]:= dp2={Join[designpoint,
{s -> N[2 pi]*I * 10^3, MaxError -> 0.1}]}
In[8]:= approxceamp=ApproximateMatrixEquation[ceampmna, dp2, V\$5];
MatrixForm/@approxceamp
Out[8]=
`In[9]:= voutsimp =`
`V\$5/.First[SolveCircuitEquations[approxceamp, V\$5]]//Simplify`
Approximation yields a very simple expression for the voltage gain: . To see if this expression is valid, we compare it graphically with the exact expression.
`In[10]:= voutexactn[s_]=vout/.designpoint;`
`In[11]:= voutsimpn[s_]=voutsimp /.designpoint;`
```In[12]:= BodePlot[
{voutexactn[N[2 pi] I f], voutsimpn[N[2 pi] I f]},
{f, 1, 10^9},
MagnitudeDisplay -> Linear,
PlotRange -> {{0, 2.5}, Automatic},
PlotStyle -> {{RGBColor[1, 0, 0]},{RGBColor[0, 1, 0],```
`Dashing[{0.03, 0.03}]}}]`

`Out[12]= -GraphicsArray-`
The above Bode plot shows that the approximated expression matches the original transfer function well within 10% tolerance at . Indeed,  is the well known gain formula for this type of amplifier. With Analog Insydes you can extract this and other design formulas automatically.

### Simplification after Generation

While equation-based approximation (SBG) can reduce the complexity of a symbolic expression greatly, the result may still contain some insignificant terms. So it is generally a good idea to apply solution-based simplification (SAG) to such a transfer function as well in order to remove the remaining irrelevant contributions. The following example demonstrates the combination of SBG and SAG.

First, we use matrix approximation to compute a reduced-order transfer function of the amplifier that is valid for the passband and also for low frequencies. Therefore, we add a second reference point at  to the list of design points.

In[13]:= dp3={Join[designpoint, {s -> N[2 pi]*I * 10^3,
MaxError -> 0.1}],
Join[designpoint, {s -> N[2 pi]*I * 10^2, MaxError -> 0.1}]};

In[14]:= approxceamp2=
ApproximateMatrixEquation[ceampmna, dp3, V\$5];

In[15]:= voutsimp2 =
V\$5/.First[SolveCircuitEquations[approxceamp2, V\$5]]//Together

Now, we can apply solution based approximation to compute a simplified transfer function that is more compact than the SAG-only solution and valid over a larger frequency range than the first SBG result.
`In[16]:= voutsimp3=`
`ApproximateTransferFunction[voutsimp2,s,designpoint,0.1]//Simplify`
The above result is very useful because it allows for reading off approximate symbolic expressions for the poles. To calculate these explicitly, we must solve the denominator of the transfer function for s
`In[17]:= Solve[Denominator[voutsimp3]==0,s]`
Finally, we plot this simplified transfer function together with the original function to visualize the effects of our low-and-mid-frequency approximation. The Bode plot shows that the approximation is valid from zero frequency to the
upper end of the passband at about . High-frequency effects are not described because we did not specify a design point in the frequency region beyond the passband.
`In[18]:= voutsimp3n[s_]=voutsimp3 /.designpoint;`
In[19]:= BodePlot[
{voutexactn[N[2 pi] I f],voutsimp3n[N[2 pi] I f]},
{f, 1, 10^9},
MagnitudeDisplay -> Linear,
PlotRange -> {{0, 2.5}, Automatic},
PlotStyle -> {{RGBColor[1, 0, 0]},{RGBColor[0, 1, 0],
Dashing[{0.03, 0.03}]}}]

`Out[19]= -GraphicsArray-`

### Copyright © 1998 by ITWM e.V.

Written by Thomas Halfmann