In [1]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv = 200;# in volts
thetav = 0;# in degrees
R1 = 5000;# in ohm
R2 = 20000;# in ohm
R3 = -1j*120000;# in ohm
R4 = 150000;# in ohm
#calculation:
#voltage
V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)
#Initially the (150-i120)kohm impedance is removed from the circuit as shown in Figure 33.13.
#Note that, to find the current in the capacitor,
#only the capacitor need have been initially removed from the circuit.
#However, removing each of the components from the branch through
#which the current is required will often result in a simpler solution.
#From Figure 33.13,
#current, I1
I1 = V/(R1 + R2)
#The open-circuit e.m.f. E is equal to the p.d. across the 20 kohm resistor, i.e.
E = I1*R2
#Removing the V1 source gives the network shown in Figure 33.14.
#The impedance, z, looking in at the open-circuited terminals is given by
z = R1*R2/(R1 + R2)
#The Th´evenin equivalent circuit is shown in Figure 33.15, where current iL is given by
ZL = R3 + R4
IL = E/(ZL + z)
ILmag = abs(IL)
#current flowing in the capacitor
Ic = ILmag
#P.d. across the 150 kohm resistor,
Vr150 = ILmag*R4
#Results
print "\n\n Result \n\n"
print "\n(a)the current flowing in the capacitor is ",round(Ic*1000,2)," mA"
print "\n(b) the p.d. across the 150 ohm resistance is ",round(Vr150,2)," V"
```

In [2]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V1 = 20;# in volts
V2 = 10;# in volts
R1 = 2;# in ohm
R2 = 1.5;# in ohm
L = 235E-6;# in Henry
R4 = 3;# in ohm
f = 2000;# in Hz
#calculation:
#The impedance through which current I is flowing is initially removed from the network, as shown in Figure 33.17.
#From Figure 33.17,
#current, I1
I1 = (V1 - V2)/(R1 + R4)
#the open circuit e.m.f. E
E = V1 - I1*R1
#When the sources of e.m.f. are removed from the circuit,
#the impedance, z, ‘looking in’ at the break is given by
z = R1*R4/(R1 + R4)
#The Th´evenin equivalent circuit is shown in Figure 33.18, where inductive reactance,
XL = 2*math.pi*f*L
R3 = 1j*XL
#Hence current
I = E/(R2 + R3 + z)
#Results
print "\n\n Result \n\n"
print "\n the current I is ",round(I.real,2)," + (",round(I.imag,2),")i A"
```

In [3]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv = 50;# in volts
thetav = 0;# in degrees
R1 = -1j*400;# in ohm
R2 = 300;# in ohm
R3 = 144j;# in ohm
R4 = 48;# in ohm
#calculation:
#voltage
V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)
#The R3 and R4 impedance is initially removed from the network as shown in Figure 33.20.
#From Figure 33.20,
#current, I
i = V/(R1 + R2)
#the open circuit e.m.f. E
E = i*R2
#When the V is removed from the circuit, the impedance, z, ‘looking in’ at the break is given by
z = R1*R2/(R1 + R2)
#The Th´evenin equivalent circuit is shown in Figure 33.21 connected to R# and R4,
#Hence current
I = E/(R4 + R3 + z)
Imag = abs(I)
#the power dissipated in the 48 ohm resistor
Pr48 = R4*Imag**2
#Results
print "\n\n Result \n\n"
print "\n the power dissipated in the 48 ohm resistor is ",round(Pr48,2)," W"
```

In [4]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V = 100;# in volts
R1 = 5;# in ohm
R2 = 20;# in ohm
R3 = 46;# in ohm
R4 = 50;# in ohm
R5 = 15;# in ohm
R6 = 60;# in ohm
R7 = 16;# in ohm
R8 = 80;# in ohm
#calculation:
#One method of analysing a multi-branch network as shown in Figure 33.22
#is to use Th´evenin’s theorem on one part of the network at a time.
#For example, the part of the circuit to the left of AA may be reduced to a Th´evenin equivalent circuit.
#From Figure 33.23,
E1 = (R2/(R1 + R2))*V
z1 = R1*R2/(R1 + R2)
#Thus the network of Figure 33.22 reduces to that of Figure 33.24.
#The part of the network shown in Figure 33.24 to the left of BB may be reduced
#to a Th´evenin equivalent circuit, where
E2 = (R4/(R3 + R4 + z1))*E1
z2 = R4*(z1 + R3)/(R4 + z1 + R3)
#Thus the original network reduces to that shown in Figure 33.25.
#The part of the network shown in Figure 33.25 to the left of CC may be reduced
#to a Th´evenin equivalent circuit, where
E3 = (R6/(R5 + R6 + z2))*E2
z3 = R6*(z2 + R5)/(R5 + z2 + R6)
#Thus the original network reduces to that of Figure 33.26,
#from which the current in the 80 ohm resistor is given by
I = E3/(z3 + R7 + R8)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 80 ohm resistor is ",round(I,2)," A"
```

In [5]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv = 24;# in volts
thetav = 0;# in degrees
R1 = -1j*3;# in ohm
R2 = 4;# in ohm
R3 = 3j;# in ohm
#calculation:
#voltage
V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)
#Current I1 shown in Figure 33.27 is given by
I1 = V/(R1 + R2 + R3)
#The Th´evenin equivalent voltage, i.e., the open-circuit voltage across terminals AB, is given by
E = I1*(R2 + R3)
#When the voltage source is removed, the impedance z ‘looking in’ at AB is given by
z = (R2 + R3)*R1/(R1 + R2 + R3)
#Thus the Th´evenin equivalent circuit is as shown in Figure 33.28.
#when (3.75 + i11) ohm impedance connected across terminals AB,
#the current I flowing in the impedance is given by
R = 3.75 + 11j;# in ohms
I = E/(R + z)
Imag = abs(I)
#the p.d. across the( 3.75 + i11)ohm impedance.
VR = I*R
VRmag = abs(VR)
#Results
print "\n\n Result \n\n"
print "\n (a) the current I flowing in the (3.75 + i11) impedance is given by is ",round(Imag,2)," A"
print "\n (b) the magnitude of the p.d. across the impedance is ",round(VRmag,2)," V"
```

In [6]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv = 16.55;# in volts
thetav = -22.62;# in degrees
R1 = 4;# in ohm
R2 = 1j*2;# in ohm
R3 = 1j*6;# in ohm
R4 = 3;# in ohm
R5 = 5;# in ohm
R6 = -1*1j*8;# in ohm
#calculation:
#voltage
V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)
#The capacitor is removed from branch AB, as shown in Figure 33.30.
#Impedance, Z
Z1 = R3 + R4 + R5
Z = R1 + (Z1*R2/(R2 + Z1))
I1 = V/Z
I2 = (R2/(R2 +Z1))*I1
#The open-circuit voltage, E
E = I2*R5
#If the voltage source is removed from Figure 33.30, the impedance, z, ‘looking in’ at AB is given by
z = R5*((R1*R2/(R1 + R2)) + R3 + R4)/(R5 + ((R1*R2/(R1 + R2)) + R3 + R4))
#The Th´evenin equivalent circuit is shown in Figure 33.31,
#where the current flowing in the capacitor, I, is given by
I = E/(z + R6)
Imag = abs(I)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the capacitor of the network is ",round(Imag,2)," A"
```

In [7]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv1 = 5;# in volts
rv2 = 10;# in volts
thetav1 = 45;# in degrees
thetav2 = 0;# in degrees
R1 = 8;# in ohm
R2 = 5;# in ohm
R3 = 3j;# in ohm
R4 = 4;# in ohm
#calculation:
#voltage
V1 = rv1*math.cos(thetav1*math.pi/180) + 1j*rv1*math.sin(thetav1*math.pi/180)
V2 = rv2*math.cos(thetav2*math.pi/180) + 1j*rv2*math.sin(thetav2*math.pi/180)
#Current I1 shown in Figure 33.32 is given by
I1 = V2/(R2 + R3 + R4)
#Hence the voltage drop across the 5 ohm resistor is given by VX is in the direction shown in Figure 33.32,
Vx = I1*R2
#The open-circuit voltage E across PQ is the phasor sum of V1, Vx and V2, as shown in Figure 33.33.
E = V2 - V1 - Vx
#The impedance, z, ‘looking in’ at terminals PQ with the voltage sources removed is given by
z = R1 + R2*(R3 + R4)/(R2 + R3 + R4)
#The Th´evenin equivalent circuit is shown in Figure 33.34 with the 2 ohm resistance connected across terminals PQ.
#The current flowing in the 2 ohm resistance is given by
R = 2;# in ohms
I = E/(z + R)
Imag = abs(I)
#power P dissipated in the 2 ohm resistor is given by
Pr2 = R*Imag**2
#Results
print "\n\n Result \n\n"
print "\n power P dissipated in the 2 ohm resistor is ",round(Pr2,2)," W"
```

In [8]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv = 30;# in volts
thetav = 0;# in degrees
R1 = 15;# in ohm
R2 = 40;# in ohm
R3 = 20j;# in ohm
R4 = 20;# in ohm
R5 = 5j;# in ohm
R6 = 5;# in ohm
R7 = -1j*25;# in ohm
#calculation:
#voltage
V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)
#The R7 is initially removed from the network, as shown in Figure 33.36
Z1 = R1
Z2 = R2
Z3 = R3 + R4
Z4 = R5 + R6
#P.d. between A and C,
Vac = (Z1/(Z1 + Z4))*V
#P.d. between B and C,
Vbc = (Z2/(Z2 + Z3))*V
#Assuming that point A is at a higher potential than point B, then the p.d. between A and B is
Vab = Vac - Vbc
#the open-circuit voltage across AB is given by
E = Vab
#Point C is at a potential of V . Between C and A is a volt drop of Vac. Hence the voltage at point A is
Va = V - Vac
#Between points C and B is a voltage drop of Vbc. Hence the voltage at point B
Vb = V - Vbc
#Replacing the V source with a short-circuit (i.e., zero internal impedance)
#gives the network shown in Figure 33.37(a). The network is shown redrawn in Figure 33.37(b)
#and simplified in Figure 33.37(c). Hence the impedance, z, ‘looking in’ at terminals AB is given by
z = Z1*Z4/(Z1 + Z4) + Z2*Z3/(Z2 + Z3)
#The Th´evenin equivalent circuit is shown in Figure 33.38, where current I is given by
I = E/(z + R7)
Imag = abs(I)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the capacitor is ",round(Imag,2)," A in direction from B to A."
```

In [9]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V = 5;# in volts
R1 = 2;# in ohm
R2 = 3;# in ohm
R3 = -1j*3;# in ohm
R4 = 2.8;# in ohm
#calculation:
#The branch containing the R4 is short-circuited, as shown in Figure 33.48.
#The R2 in parallel with a short-circuit is the same as R2 in parallel with 0 ohm
#giving an equivalent impedance of
Z1 = R2*0/(R3 + 0)
#Hence the network reduces to that shown in Figure 33.49, where
Isc = V/R1
#If the Voltage source is removed from the network the input impedance, z, ‘looking-in’
#at a break made in AB of Figure 33.48 gives
z = R1*R2/(R1 + R2)
#The Norton equivalent network is shown in Figure 33.51, where current I is given by
I = (z/(z + R4 + R3))*Isc
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the capacitor is ",round(I.real,2)," + (", round(I.imag,2),")i A"
```

In [10]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V1 = 20;# in volts
V2 = 10;# in volts
R1 = 2;# in ohm
R2 = 1.5;# in ohm
R3 = 2.95j;# in ohm
R4 = 3;# in ohm
#calculation:
#The inductive branch is initially short-circuited, as shown in Figure 33.53.
#From Figure 33.53,
I1 = V1/R1
I2 = V2/R4
Isc = I1 + I2
#If the voltage sources are removed, the impedance, z, ‘looking in’ at a break made in AB is given by
z = R1*R4/(R1 + R4)
#The Norton equivalent network is shown in Figure 33.54, where current I is given by
I = (z/(z + R2 + R3))*Isc
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the inductive branch is ",round(I.real,2)," + (",round( I.imag,2),")i A"
```

In [1]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V = 10;# in volts
R1 = 1;# in ohm
R2 = 4;# in ohm
R3 = 4;# in ohm
R4 = -2j;# in ohm
#calculation:
Isc = V/R3
z = 1/(1/R2 + 1/R3 + 1/R4)
I = (z/(R1 + z))*Isc
pd1 = abs(I)*R1
#Results
print "\n\n Result \n\n"
print "\n the magnitude of the p.d. across the 1 ohm resistor is ",round(pd1, 2),"V"
```

In [12]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv = 20;# in volts
thetav = 0;# in degrees
R1 = 2;# in ohm
R2 = 4;# in ohm
R3 = 3j;# in ohm
R4 = -1j*3;# in ohm
#calculation:
#voltage
V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)
#Terminals AB are initially short-circuited, as shown in Figure 33.61.
#The circuit impedance Z presented to the voltage source is given by
Z = R1 + R4*(R2 + R3)/(R2 + R3 + R4)
#Thus current I in Figure 33.61 is given by
I = V/Z
Isc = ((R2 + R3)/(R2 + R3 + R4))*I
#Removing the voltage source of Figure 33.60 gives the network Figure 33.62 of Figure 33.62.
#Impedance, z, ‘looking in’ at terminals AB is given by
z = R4 + R1*(R2 + R3)/(R2 + R3 + R1)
#The Norton equivalent network is shown in Figure 33.63.
R = 5;# in ohms
#Current IL
IL = (z/(z + R))*Isc
ILmag = abs(IL)
#the power dissipated in the 5 ohm resistor is
Pr5 = R*ILmag**2
#Results
print "\n\n Result \n\n"
print "\n the power dissipated in the 5 ohm resistor is ",round(Pr5,2)," W"
```

In [13]:

```
from __future__ import division
import math
import numpy
import cmath
#initializing the variables:
rv1 = 5;# in volts
rv2 = 10;# in volts
thetav1 = 45;# in degrees
thetav2 = 0;# in degrees
R1 = 8;# in ohm
R2 = 5;# in ohm
R3 = 3j;# in ohm
R4 = 4;# in ohm
#calculation:
#voltage
V1 = rv1*math.cos(thetav1*math.pi/180) + 1j*rv1*math.sin(thetav1*math.pi/180)
V2 = rv2*math.cos(thetav2*math.pi/180) + 1j*rv2*math.sin(thetav2*math.pi/180)
#Terminals PQ are initially short-circuited, as shown in Figure 33.65.
#Currents I1 and I2 are shown labelled. Kirchhoff’s laws are used.
#For loop ABCD, and moving anticlockwise,
#I1*(R2 + R3 + R4) + I2*(R3 + R4) = V2
#For loop DPQC, and moving clockwise,
#R2*I1 - R1*I2 = V2 - V1
#Solving Equations by using determinants gives
d1 = [[V2, (R3 + R4)],[(V2 - V1), -1*R1]]
D1 = numpy.linalg.det(d1)
d2 = [[(R2 + R3 + R4), V2],[R2, (V2 - V1)]]
D2 = numpy.linalg.det(d2)
d = [[(R2 + R3 + R4), (R3 + R4)],[R2, -1*R1]]
D = numpy.linalg.det(d)
I1 = D1/D
I2 = D2/D
#the short-circuit current Isc
Isc = I2
#The impedance, z, ‘looking in’ at a break made between P and Q is given by
z = R1 + R2*(R3 + R4)/(R2 + R3 + R4)
#The Norton equivalent circuit is shown in Figure 33.66, where current I is given by
R = 2;#in ohm
I = (z/(z + R))*Isc
Imag = abs(I)
#Results
print "\n\n Result \n\n"
print "\n the magnitude of the current flowing 5 ohm resistor is ",round(Imag,2)," A"
```

In [14]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
E1 = 12;# in volts
E2 = 24;# in volts
Z1 = 3;# in ohm
Z2 = 2;# in ohm
R1 = 4j;# in ohm
R2 = 1.8;# in ohm
#calculation:
Z3 = R1 + R2
#For the branch containing the E1 source, conversion to a Norton equivalent network gives
Isc1 = E1/Z1
#For the branch containing the E2 source, conversion to a Norton equivalent circuit gives
Isc2 = E2/Z2
#Thus Figure 33.73 shows a network equivalent to Figure 33.72. From Figure 33.73,
#the total short-circuit current
Isc = Isc1 + Isc2
#the total impedance is given by
z = Z1*Z2/(Z1 + Z2)
#Thus Figure 33.73 simplifies to Figure 33.74.
#The open-circuit voltage across AB of Figure 33.74, E
E = Isc*z
#the impedance ‘looking in’ at AB,is z
#the Th´evenin equivalent circuit is as shown in Figure 33.75.
R = 1.8 + 4j;# in ohm
#when R impedance is connected to terminals AB of Figure 33.75, the current I flowing is given by
I = E/(z + R)
Imag = abs(I)
#Results
print "\n\n Result \n\n"
print "\n the magnitude of the current flowing (1.8 + i4) ohm resistor is ",round(Imag,2)," A"
```

In [15]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V1 = 5;# in volts
V2 = 10;# in volts
i = 0.001;# in Amperes
R1 = 1000;# in ohm
R2 = 4000;# in ohm
R3 = 2000;# in ohm
R4 = 200;# in ohm
R5 = -1j*4000;# in ohm
#calculation:
#For the branch containing the V1 source, conversion to a Norton equivalent network gives
Isc1 = V1/R1
z1 = R1
#For the branch containing the V2 source, conversion to a Norton equivalent circuit gives
Isc2 = V2/R2
z2 = R2
#Thus the circuit of Figure 33.76 converts to that of Figure 33.77.
#The above two Norton equivalent networks shown in Figure 33.77 may be combined,
#since the total short-circuit current is
Isc = Isc1 + Isc2
#the total impedance is given by
Z1 = z1*z2/(z1 + z2)
#Both of the Norton equivalent networks shown in Figure 33.78 may be converted to Th´evenin equivalent circuits.
#Open-circuit voltage across CD is
Ecd = Isc*Z1
#the impedance ‘looking in’ at CD is Z1
#Open-circuit voltage across EF
Eef = i*R3
#the impedance ‘looking in’ Figure 33.79 at EF
Z2 = R3
#Thus Figure 33.78 converts to Figure 33.79.
#Combining the two Th´evenin circuits gives e.m.f.
E = Ecd - Eef
#impedance z
z = Z1 + Z2
#the Th´evenin equivalent circuit for terminals AB of Figure 33.76 is as shown in Figure 33.80.
Z3 = R4 + R5
#If an impedance Z3 is connected across terminals AB, then the current I flowing is given by
I = E/(z + Z3)
Imag = abs(I)
#Results
print "\n\n Result \n\n"
print "\n the current in the capacitive branch is ", Imag*1000,"mA"
```

In [16]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V = 5;# in volts
i = 0.004;# in Amperes
R1 = 2000;# in ohm
R2 = 1000j;# in ohm
#calculation:
#Converting the Th´evenin circuit to a Norton network gives
Isc1 = V/R2
#Thus Figure 33.81 converts to that shown in Figure 33.82.
#The two Norton equivalent networks may be combined, giving
Isc = Isc1 + i
z = R1*R2/(R1 + R2)
#This results in the equivalent network shown in Figure 33.83.
#Converting to an equivalent Th´evenin circuit gives open circuit e.m.f. across AB,
E = Isc*z
#Thus the The´venin equivalent circuit is as shown in Figure 33.84.
R = 600 - 800j;# in ohms
#When a R impedance is connected across AB, the current I flowing is given by
I = E/(z + R)
Imag = abs(I)
#the power dissipated in the R resistor is
PR = R.real*Imag**2
#Results
print "\n\n Result \n\n"
print "\n the power dissipated in the (600 - i800) ohm resistor is ",round(PR*1000,2),"mW"
```