Chapter 10 : Circuit Theory

Example 10.1,Page number 477

In [1]:
#Variable declaration
i1=4.           #current through r1(A)      
v3=3            #voltage(V)
v4=8            #voltage(V)
r3=3            #resistance(ohms)
r2=2            #resistance(ohms)
r4=4            #resistance(ohms)

#Calculations
i3=v3/r3                #current through r3(A)
i4=v4/r4                #current through r4(A)
i2=-(i3+i4-i1)/2        #current through r2(A)
v2=i2*r2                #voltage through r2(V)

#Result
print"v2 is",v2,"V"
v2 is 1.0 V

Example 10.2,Page number 478

In [3]:
#Variable declaration
v1=6                #current through r1(A)   
i2=2                #voltage through r3(V)
i3=4                #voltage through r4(V)
r3=2                #resistance(ohms)
v3=3                #voltage through r3(ohms)
r2=2                #resistance(ohms)
r4=3                #resistance(ohms)

#Calculations
v2=i2*r2                 #voltage through r2(ohms)
v3=i3*r3                 #voltage through r3(ohms)
v4=4*i2+v3-v2-v1         #voltage through r4(ohms)
i4=v4/r4                 #current through r4(A)

#Result
print"i4 is",i4,"A"
i4 is 2 A

Example 10.3,Page number 481

In [1]:
import numpy as np

#Calculations
a=np.array([[7,-3,-4],[-3,6,-2],[-4,-2,11]])  #solving three linear mesh equations
b=np.array([-11,3,25])
x=np.linalg.solve(a,b)
x
v=x[2]-x[1]                                  #voltage across 2mho conductance(V)

#Results
print"v is",v,"V"
v is 1.0 V

Example 10.4,Page number 483

In [1]:
import numpy as np

#Variable declaration
R=20                            #resistance across which voltage is to be calculated(ohms)

#Calculations
a=np.array([[35,-20],[-20,50]])  #solving two linear mesh equations
b=np.array([50,-100])
x=np.linalg.solve(a,b)
x
i=x[0]-x[1]           #current through 20 ohms resistor(ohms)
V=20*i                #voltage across 20 ohms(V)

#Results
print"i is",round(i,2)
print"voltage across 20 ohms is",round(V,1),"V"
i is 2.22
voltage across 20 ohms is 44.4 V

Example 10.5,Page number 484

In [20]:
#Variable declaration
Vs=16.              #source voltage(V)

#Calculations
#Part b
I=0                 #current through 10 V
Is=-4*(I-(Vs/32))   #current of current source(A)

#Part c
Is1=16              #current of current source(A)
I=0                 #current through 10 V
Vs1=(I+(Is1/4))*32  #source voltage(V)

#Results
print"Is is",Is,"A"
print"Vs1 is",Vs1,"V"
Is is 2.0 A
Vs1 is 128 V

Example 10.6,Page number 485

In [5]:
#Variable declaration
V=9                   #voltmeter of voltage(V)
i=9                   #ammeter current of 9V
r1=1                  #resistance(ohms)
r2=3                  #resistance(ohms)
r=5                   #resistance parallel to ammeter(ohms)

#Calculations
Isc=((i*r)-V)/(r1+r)       #short circuiting a and b and converting current source to a voltage source(A)
Ro=((r+r1)*r2)/((r+r1)+r2) #output resistance(ohms)

#Results
print"Isc is",Isc,"A"
print"Ro is",Ro,"ohms"
Isc is 6 A
Ro is 2 ohms

Example 10.7,Page number 495

In [2]:
import cmath
import math
from sympy import *
import sympy

#Variable declaration
t = symbols('t')           #symbol defined
et1 = complex(50,86.6)     #defining complex number

#calculations
et = (et1.real*sympy.sqrt(2)*sympy.cos(314*t))+et1.imag*sympy.sqrt(2)*sympy.cos(314*t+90)  #expression

#Result
print et
50.0*sqrt(2)*cos(314*t) + 86.6*sqrt(2)*cos(314*t + 90)

Example 10.9,Page number 506

In [6]:
import cmath
import math
from sympy import *
import sympy

#Variable declarations
V1, V2=symbols('V1 V2')

#Calculations
V = 0.3*V1                                               #voltage(V)
I1 = 0.007*V1                                           #current 
y11 = I1/V1                                             #y parameter

I2 = -V/40                                               #current     
y21 = I2/V1                                              #y parameter

I2 = V2/(((40+100)*200.)/((40+100)+200.))                #y parameter
y22 = I2/V2          #incorrect answer in textbook       #y parameter

I1 = (-I2*200)/300                     #current    
y12 = I1/V2                            #y parameter

#Results
print "y11+y12 is",round(y11+y12,5),"mho"
print "y22+y12 is",round(y22+y12,5),"mho"
print "y21-y12 is",round(y21-y12,5),"mho"
y11+y12 is -0.0011 mho
y22+y12 is 0.00405 mho
y21-y12 is 0.0006 mho

Example 10.10,Page number 508

In [1]:
#Variable declaration

#port 2 open circuited,port 1 excited
z11=1075+1075j                   #as z11=V1/I1=(1.52<45)/(10**-3<0)=1075+1075j
z21=2022-1075j                   #as z21=V2/I1=(2.29<-28)/(10**-3<0)=2022+1075j

#port 1 open circuited and port 2 excited
z12=-1075j                       #as z12=V1/I2=(1.075<-90)/(10**3<0)=-1075j
z22=751-1073j                    #as z22=V2/I2=(1.31<-55)/(10**-3<0)=751-j1073

#Calculations
z=z11-z12                        #parameters with reference to circuit
z1=z22-z12
z2=z21-z12

#Results
print"z11-z12(z) is",z
print"z22-z12(z1) is",z1
print"z21-z12(z2) is",z2
z11-z12(z) is (1075+2150j)
z22-z12(z1) is (751+2j)
z21-z12(z2) is (2022+0j)

Example 10.11,Page number 510

In [21]:
#Variable declaration
V2=6/7.                   #voltage source(V)

#Calculations                  
Rth=V2                     #thevinin resistance(ohms)
Zl=Rth                     #load resistance(ohms)

#Result
print"load resistance is",round(Zl,3),"ohms"
load resistance is 0.857 ohms