Starting from:

$30

EE2703-Assignment 2 Spice - Part 2 Solved

In the last assignment, we read a netlist file and parsed it. In this assignment, we will solve the circuits. We have n node voltages (say Vi ; i = 0 to n − 1) and k currents (say Iij) (the currents through the k voltage sources). The system of equations are:

1.    n KCL equations at the n nodes.

2.    k equations of the type   for nodes connected by voltage sources.

As long as a loop consisting purely of voltage sources or a node connected purely to current sources does not exist, a unique solution is possible. Write the equations in the form

                                                                                  A · V~ + B · I~ =~b                                                (7)

The node equations take the form

                                                                                                   (8)

where the first sum is over the passive branches, the second sum over voltage sources and the third sum is over current sources.

The auxiliary equations take the form

                                                                                         Vi − Vj = Eij                                                                           (9)

The dependent sources have similar equations that you can easily derive for yourself.

•    Explain how a loop consisting purely of voltage sources will result in the system of equations becoming inconsistent.

•    Explain how a node connected purely to current sources will result in the system of equations becoming inconsistent.

Now, write the equation 7 in the following form:

i.e.,
 
 
 
Mx = b
(10)
 a11

 ...

 an1



 ...





 ... ...
...

...

...

...

...

...
a1n

...

ann

...

...

...
b11

...

bn1

0

0

0
... ... ...

0

0

0
b1k  V1   I1 

...  ...   ...  bnk  Vn   In 

 I1  =  E1 

0 

0  ...   ... 

0                  Ik                             Ek
(11)
 
 
 
 
 
 
 
This matrix needs to be solved to obtain currents and voltages.

Note that this can be readily solved using the method specified in section 5.

7       Assignment
1.    Parse the netlist and create list(s) of different components. You may define class(es) for components and create objects for each component to store them nicely. Component name, connected nodes, value etc... can be the features of this(these) class(es). Remember that list elements can be class objects too.

2.    Create a table of distinct nodes present in the circuit. Assign numbers to the nodes so that they correspond to the rows (columns) of the incidence matrix. You may use a dictionary for doing this. You could then store the node number as the value with the node name as the key.

Note: You can assume that ground node is always named as GND. The ground node will add an extra equation:

                                                                                                            Vk = 0                                            (12)

where k is the node number of GND. You may keep it as V0 always.

3.    Construct matrices M and b using numpy arrays.

4.    Solve the equation Mx = b.

5.    Print all the unknowns. (All node volatges and current through voltage sources)

6.    Solve the following circuits with your program:

(a) A simple resistive circuit (use RL = 1,10 and 100Ω)

 

Figure 1: Resistive circuit

7. Can you use the same techniques to solve for ac circuits? We only have to interpret the impedance as complex numbers and the solution will follow. We will only work with circuits with single frequency at steady state.

Till now, we only had a single command in the netlist (.circuit ... .end). We now allow a new command .ac.

.ac V... frequency

This is a single line command. It will appear after the .circuit ... .end block and specify the frequency of a voltage source.

We will also modify the way voltage source and current values are given. We will use the following representations:

V... n1 n2 ac Vp−p
phase # ac voltage source
V... n1 n2 dc v
# dc voltage source
Similar representations will follow for current sources.

Solve the following circuits:

(a)    A band-pass filter for the current in the resistor

 

Figure 2: Band-pass filter

(b)   A low-pass filter, for the voltage across the load resistor

 

Figure 3: Low-pass filter

More products