In [1]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv1 = 100;# in volts
rv2 = 50;# in volts
thetav1 = 0;# in degrees
thetav2 = 90;# in degrees
r1 = 25;# in ohm
R = 20;# in ohm
r2 = 10;# 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)
#The circuit diagram is shown in Figure 32.7. Following the above procedure:
#The network is redrawn with the 50/_90° V source removed as shown in Figure 32.8
#Currents I1, I2 and I3 are labelled as shown in Figure 32.8.
I1 = V1/(r1 + r2*R/(R + r2))
I2 = (r2/(r2 + R))*I1
I3 = (R/(r2 + R))*I1
#The network is redrawn with the 100/_0° V source removed as shown in Figure 32.9
#Currents I4, I5 and I6 are labelled as shown in Figure 32.9.
I4 = V2/(r2 + r1*R/(r1 + R))
I5 = (r1/(r1 + R))*I4
I6 = (R/(r1 + R))*I4
#Figure 32.10 shows Figure 32.9 superimposed on Figure 32.8, giving the currents shown.
#Current in the 20 ohm load,
I20 = I2 + I5
#Current in the 100/_0° V source
IV1 = I1 - I6
#Current in the 50/_90° V source
IV2 = I4 - I3
#Results
print "\n\n Result \n\n"
print "\n (a)current in the 20 ohm load is ",round(I20.real,2)," + (",round(I20.imag,2),")i A"
print "\n (b)Current in the 100/_0deg V source is ",round(IV1.real,2)," + (",round(IV1.imag,2),")i A"
print "\n (b)Current in the 50/_90deg V source is ",round(IV2.real,2)," + (",round(IV2.imag,2),")i A"
```

In [2]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
V1 = 12;# in volts
V2 = 20;# in volts
R1 = 5;# in ohm
R2 = 4;# in ohm
R3 = 2.5;# in ohm
R4 = 6;# in ohm
R5 = 2;# in ohm
#calculation:
#Removing the 20 V source gives the network shown in Figure 32.12.
#Currents I1 and I2 are shown labelled in Figure 32.12
Re1 = (R4*R5/(R4 + R5)) + R3
Re2 = Re1*R2/(Re1 + R2) + R1
I1 = V1/Re2
I2 = (R2/(Re1 + R2))*I1
#Removing the 12 V source from the original network gives the network shown in Figure 32.14.
#Currents I3, I4 and I5 are shown labelled in Figure 32.14.
Re3 = (R1*R2/(R1 + R2)) + R3
Re4 = Re3*R4/(Re3 + R4) + R5
I3 = V2/Re4
I4 = (R4/(Re3 + R4))*I3
I5 = (R1/(R1 + R2))*I4
#Superimposing Figure 32.14 on Figure 32.12 shows that the current flowing in the 4 ohm resistor is given by
Ir4 = I5 - I2
#Results
print "\n\n Result \n\n"
print "\ncurrent in the 4 ohm resistor of the network is ",round(Ir4,2)," A"
```

In [1]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv1 = 30;# in volts
rv2 = 30;# in volts
thetav1 = 45;# in degrees
thetav2 = -45;# in degrees
R1 = 4;# in ohm
R2 = 4;# in ohm
R3 = 1j*3;# in ohm
R4 = -1j*10;# 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)
#The network is redrawn with V2 removed, as shown in Figure 32.17.
#Current I1 and I2 are shown in Figure 32.17. From Figure 32.17,
Re1 = R4*(R2 + R3)/(R4 + R3 + R2)
Re2 = Re1 + R1
#current
I1 = V1/Re2
I2 = (R4/(R2 + R3 + R4))*I1
#The original network is redrawn with V1 removed, as shown in Figure 32.18
#Currents I3 and I4 are shown in Figure 32.18. From Figure 32.18,
Re3 = R1*(R2 + R3)/(R1 + R3 + R2)
Re4 = Re3 + R4
I3 = V2/Re4
I4 = (R1/(R2 + R3 + R1))*I3
#If the network of Figure 32.18 is superimposed on the network of Figure 32.17,
#it can be seen that the current in the (4+i3) ohm impedance is given by
Ir4i3 = I2 - I4
#Results
print "\n\n Result \n\n"
print "current in (4 + i3) ohm impedance of the network is ",round(Ir4i3.real,2)," + (",round( Ir4i3.imag,2),")i A"
```

In [5]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
E1 = 5 + 0j;# in volts
E2 = 2 + 4j;# in volts
Z1 = 3 + 4j;# in ohm
Z2 = 2 - 5j;# in ohm
Z3 = 6 + 8j;# in ohm
#calculation:
#The original network is redrawn with E2 removed, as shown in Figure 32.20.
#Currents I1, I2 and I3 are labelled as shown in Figure 32.20.
Ze1 = Z3*Z2/(Z3 + Z2)
Ze2 = Ze1 + Z1
#current
I1 = E1/Ze2
I2 = (Z2/(Z3 + Z2))*I1
I3 = (Z3/(Z3 + Z2))*I1
#The original network is redrawn with E1 removed, as shown in Figure 32.22
#Currents I4, I5 and I6 are shown labelled in Figure 32.22
#with I4 flowing away from the positive terminal of the E2 source.
Ze3 = Z3*Z1/(Z3 + Z1)
Ze4 = Ze3 + Z2
I4 = E2/Ze4
I5 = (Z1/(Z3 + Z1))*I4
I6 = (Z3/(Z3 + Z1))*I4
#If the network of Figure 32.18 is superimposed on the network of Figure 32.17,
#it can be seen that the current in the (4+i3) ohm impedance is given by
i1 = I1 + I6
i2 = I3 + I4
i3 = I2 - I5
#magnitude
i1mag = abs(i1)
i2mag = abs(i2)
E1mag = abs(E1)
E2mag = abs(E2)
#phase
phi1 = cmath.phase(complex(i1.real,i1.imag))
phi2 = cmath.phase(complex(i2.real,i2.imag))
#voltage across the(6 + i8) ohm impedance
V6i8 = i3*Z3
V6i8m = abs(V6i8)
#power
P = (E1mag*i1mag*math.cos(phi1)) + (E2mag*i2mag*math.cos(phi2 - cmath.phase(complex(E2.real,E2.imag))))
#Results
print "\n\n Result \n\n"
print "\n(a)currents are: \n ",round(i1.real,2)," + (",round( i1.imag,2),")i A, \n ",round(i2.real,2)," + (",round(i2.imag,2),")i A \n and ",round(i3.real,2)," + (",round(i3.imag,2),")i A"
print "\n(b)current in the (6 + i8) ohm resistor of the network is ",round(V6i8m,2)," V"
print "\n(c)the total active power delivered to the network is ",round(P,2)," W"
```

In [1]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
rv1 = 50;# in volts
rv2 = 30;# in volts
thetav1 = 0;# in degrees
thetav2 = 90;# in degrees
R1 = 20;# in ohm
R2 = 5;# in ohm
R3 = -1j*3;# in ohm
R4 = 8;# in ohm
R5 = 8;# 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)
#The network is redrawn with the V2 source removed, as shown in Figure 32.26.
#Currents I1 to I5 are shown labelled in Figure 32.26.
#current
Re1 = R4*R5/(R5 + R4) + R3
Re2 = Re1*R2/(R2 + Re1)
I1 = V1/(Re2 + R1)
I2 = (Re1/(R2 + Re1))*I1
I3 = (R2/(Re1 + R2))*I1
I4 = (R4/(R4 + R5))*I3
I5 = I3 - I4
#The original network is redrawn with the V1 source removed, as shown in Figure 32.27.
#Currents I6 to I10 are shown labelled in Figure 32.27
Re3 = R1*R2/(R1 + R2)
Re4 = Re3 + R3
Re5 = Re4*R4/(Re4 + R4)
Re6 = Re5 + R5
I6 = V2/Re6
I7 = (Re4/(Re4 + R4))*I6
I8 = (R4/(Re4 + R4))*I6
I9 = (R1/(R1 + R2))*I8
I10 = (R2/(R1 + R2))*I8
#current flowing in the capacitor is given by
Ic = I3 - I8
#magnitude of the current in the capacitor
Icmag = abs(Ic)
i1 = I2 + I9
i1mag = abs(i1)
#magnitude of the p.d. across the 5 ohm resistance is given by
Vr5m = i1mag*R2
#Active power dissipated in the 20 ohm resistance is given by
i2 = I1 - I10
i2mag = abs(i2)
phii2 = cmath.phase(complex(i2.real,i2.imag))
Pr20 = R1*(i2mag)**2
#Active power developed by the V1
P1 = rv1*i2mag*math.cos(phii2)
#Active power developed by V2 source
i3 = I6 - I5
i3mag = abs(i3)
phii3 = cmath.phase(complex(i3.real,i3.imag))
P2 = rv2*i3mag*math.cos(phii3 - (thetav2*math.pi/180))
#Total power developed
P = P1 + P2
#Results
print "\n\n Result \n\n"
print "\n(a)the magnitude of the current flowing in the capacitor is ",round(Icmag,2)," A"
print "\n(b) the p.d. across the 5 ohm resistance is ",round(Vr5m,2)," V"
print "\n(c)the active power dissipated in the 20 ohm resistance is ",round(Pr20,0)," W"
print "\n(d)the total active power taken from the supply is ",round(P,1)," W"
```