Chapter 2 : Resistive Circuits

Pg: 74 Ex: 2.1

In [1]:
from __future__ import division
R_1=10#
R_2=20#
R_3=5#
R_4=15#
#We proceed through various combinations of resistances in series or parallel while we replace them with equivalent resistances  We start with R_3 and R_4.
R_eq_1=R_3+R_4#      #R_3 and R_4 in series
R_eq_2=1/((1/R_eq_1)+(1/R_2))#      #R_eq_1 and R_2 in parallel
R_eq=R_1+R_eq_2#      #R_1 and R_eq_2 in series
print 'Equivalent resistance = %0.2f ohms'%R_eq
Equivalent resistance = 20.00 ohms

Pg: 74 Ex: 2.2

In [2]:
from __future__ import division
V_s=90#      #source voltage
R_1=10#
R_2=30#
R_3=60#
R_eq_1=1/((1/R_2)+(1/R_3))#      #R_2 and R_3 in parallel
R_eq=R_1+R_eq_1#      #R_1 and R_eq_1 in series
i_1=V_s/R_eq#      #ohm's law
#i_1 flows clockwise through V_s,R_1 and R_eq_1
V_2=R_eq_1*i_1#      #voltage across R_eq_1
#As R_eq_1 is equivalent of parallel combination of R_2 and R_3, V_2 appears across both of them
i_2=V_2/R_2#      #ohm's law
i_3=V_2/R_3#      #ohm's law
#we can verify KCL, i_1=i_2+i_3
V_1=i_1*R_1#      #ohm's law
#we can verify KVL, V_s=V_1+V_2
P_s=-V_s*i_1#      #source power(-ve sign as V_s and i_1 have references opposite to passive configuration)
P_1=i_1**2*R_1#      #power for R_1
P_2=V_2**2/R_2#      #power for R_2
P_3=V_2**2/R_3#      #power for R_3
print 'FOR SOURCE'
print 'current = %0.2g amperes'%i_1
print 'power = %0.2f watts'%P_s
print 'FOR R1'
print 'current = %0.2f amperes'%i_1
print 'voltage = %0.2f volts'%V_1
print 'power = %0.2f watts'%P_1
print 'FOR R2'
print i_2,'current in amperes'
print 'current = %0.2f amperes'%i_2
print 'voltage = %0.2f volts'%V_2
print 'power = %0.2f watts'%P_2
print 'FOR R3'
print 'current = %0.2f amperes'%i_3
print 'voltage = %0.2f volts'%V_2
print 'power = %0.2f watts'%P_3
#we may verify that P_s+P_1+P_2+P_3=0
FOR SOURCE
current = 3 amperes
power = -270.00 watts
FOR R1
current = 3.00 amperes
voltage = 30.00 volts
power = 90.00 watts
FOR R2
2.0 current in amperes
current = 2.00 amperes
voltage = 60.00 volts
power = 120.00 watts
FOR R3
current = 1.00 amperes
voltage = 60.00 volts
power = 60.00 watts

Pg: 75 Ex: 2.3

In [3]:
from __future__ import division
V_total=15#
R_1=1*10**3#
R_2=1*10**3#
R_3=2*10**3#
R_4=6*10**3#
#By voltage-division priciple
V_1=R_1*V_total/(R_1+R_2+R_3+R_4)#      #voltage across R_1
V_4=R_4*V_total/(R_1+R_2+R_3+R_4)#      #voltage across R_4
print 'voltage across R_1 : %0.2f V'%V_1
print 'voltage across R_4 : %0.2f V'%V_4
voltage across R_1 : 1.50 V
voltage across R_4 : 9.00 V

Pg: 75 Ex: 2.4

In [4]:
from __future__ import division
V_s=100#      #source current
R_1=60#
R_2=30#
R_3=60#
R_x=1/((1/R_2)+(1/R_3))#      #R_2 and R_3 parallel
V_x=R_x*V_s/(R_1+R_x)#      #voltage across R_x(voltage-division principle)
i_s=V_s/(R_1+R_x)#      #ohm's law
i_3=R_2*i_s/(R_2+R_3)#      #current through R_3(current-division principle)
print " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook"
print 'voltage across R2 or R3 = %0.2f volts'%V_x
print 'source current = %0.2f amperes'%i_s
print 'current through R3 = %0.2f amperes'%i_3
 All the values in the textbook are approximated, hence the values in this code differ from those of Textbook
voltage across R2 or R3 = 25.00 volts
source current = 1.25 amperes
current through R3 = 0.42 amperes

Pg: 76 Ex: 2.5

In [5]:
from __future__ import division
i_s=15#      #source current
R_1=10#
R_2=30#
R_3=60#
R_eq=1/((1/R_2)+(1/R_3))#      #R_2 and R_3 in parallel
i_1=R_eq*i_s/(R_1+R_eq)#      #current through R_1(current-division principle)
print 'current through R1 = %0.2f amperes from resistance method'%i_1
#we can also do the above calculations using conductances as shown below.
#Conductances of respective resistances
G_1=1/R_1#
G_2=1/R_2#
G_3=1/R_3#
i_1=G_1*i_s/(G_1+G_2+G_3)#
print 'current through R1 = %0.2f amperes from conductance method'%i_1
print 'We get the same alue in both methods'
current through R1 = 10.00 amperes from resistance method
current through R1 = 10.00 amperes from conductance method
We get the same alue in both methods

Pg: 76 Ex: 2.7

In [6]:
from numpy import mat
print 'The matrix form is'
print 'G*V=I'
print 'where'
G=mat([[0.45,-0.25,0],[-0.25,0.85,-0.20],[0,-0.20,0.30]])
print 'G=\n',G
print 'V='
print 'transpose of [V_1,V_2,V_3]'
print 'and'
I=mat([[-3.5],[3.5],[2]])
print 'I=\n',I
The matrix form is
G*V=I
where
G=
[[ 0.45 -0.25  0.  ]
 [-0.25  0.85 -0.2 ]
 [ 0.   -0.2   0.3 ]]
V=
transpose of [V_1,V_2,V_3]
and
I=
[[-3.5]
 [ 3.5]
 [ 2. ]]

Pg: 77 Ex: 2.8

In [7]:
from __future__ import division
from numpy import mat
from numpy.linalg import solve
R=20#
G=mat([[0.35,-0.2,-0.05],[-0.2,0.3,-0.1],[-0.05,-0.1,0.35]])      #coefficient matrix
I=mat([[0],[10],[0]])      #current matrix
V=solve(G,I)#      #voltage matrix(from G=V*I)
i_x=(V[0]-V[2])/R#
print "All the values in the textbook are approximated,hence the values in this code differ from those of textbook"
print 'voltage at node1 = %0.2f volts'%V[0,0]
print 'voltage at node2 = %0.2f volts'%V[1,0]
print 'voltage at node3 = %0.2f volts'%V[2,0]
print 'value of current ix = %0.2f amperes'%i_x[0,0]
All the values in the textbook are approximated,hence the values in this code differ from those of textbook
voltage at node1 = 45.45 volts
voltage at node2 = 72.73 volts
voltage at node3 = 27.27 volts
value of current ix = 0.91 amperes

Pg: 80 Ex: 2.13

In [8]:
from __future__ import division
from numpy import mat
from numpy.linalg import solve
R=mat([[30, -10, -20],[-10, 22, -12],[-20 ,-12, 46]])   #coefficient matrix
V=mat([[70],[-42],[0]])      #voltage matrix
I=solve(R,V)#      #current matrix(from R*I=V)
print 'current in mesh1, i1=',I[0,0],"A"
print 'current in mesh2, i2=',I[1,0],"A"
print 'current in mesh3, i3=',I[2,0],"A"
current in mesh1, i1= 4.0 A
current in mesh2, i2= 1.0 A
current in mesh3, i3= 2.0 A

Pg: 81 Ex: 2.15

In [9]:
from __future__ import division
from numpy import mat
from numpy.linalg import solve

#KVL over the supermesh, we get eqn-1   -20+4(i1)+8(i2)=0
#Vx=2(i2)   ohm's law
#writing an expression for the source current in terms of mesh currents and substituting Vx from above, we get eqn-2   (1/2)i2=i2-i1
#Putting eqn-1 and eqn-2 in standard form   4(i1)+8(i2)=20 and i1-(1/2)i2=0
#solving for currents in matrix method(Ax=b)
A=mat([[4,8],[1,-1/2]])      #coeffcient matrix
b=mat([[20],[0]])#      #constant matrix
x=solve(A,b)#      #solution
print 'Value of i1 =',x[0,0],'amperes'
print 'Value of i2 =',x[1,0],'amperes'
Value of i1 = 1.0 amperes
Value of i2 = 2.0 amperes

Pg: 81 Ex: 2.16

In [10]:
from __future__ import division
V_s=15#      #source voltage
R_1=100#
R_2=50#
#Analysis with an open circuit to find V_t
i_1=V_s/(R_1+R_2)#      #closed circuit with R_1 and R_2 in series
V_oc=R_2*i_1#      #open-circuit voltage across R_2
V_t=V_oc#      #thevenin voltage
#Analysis with a short-circuit to find i_sc
i_sc=V_s/R_1#      #R_2 is short-circuited
R_t=V_oc/i_sc#      #thevenin resistance
print " All the values in the textbook are approximated, hence the values in this code differ from those of textbook"
print 'Thevenin voltage for given circuit = %0.2f volts'%V_t
print 'Thevenin voltage for given circuit = %0.2f ohms'%R_t
 All the values in the textbook are approximated, hence the values in this code differ from those of textbook
Thevenin voltage for given circuit = 5.00 volts
Thevenin voltage for given circuit = 33.33 ohms

Pg: 82 Ex: 2.17

In [11]:
from __future__ import division
V_s=20#      #source voltage
i_s=2#      #source current
R_1=5#
R_2=20#
#after zeroing the sources which includes replacing voltage source with short circuit and current source with open circuit, we get R_t
R_eq=1/((1/R_1)+(1/R_2))#      #R_1 and R_2 are in parallel combination
R_t=R_eq#      #Thevenin resistance
#short-circuit analysis to find i_sc
i_2=0#      #voltage across R_2 is 0
i_1=V_s/R_1#
i_sc=i_1+2-i_2#      #short-circuit current(KCL at junction of R_2 and I_s)
V_t=R_t*i_sc#      #thevenin voltage
print 'short-circuit current = %0.2f amperes'%i_sc
print 'thevenin resistance = %0.2f ohms'%R_t
print 'thevenin voltage = %0.2f volts'%V_t
#thevenin equivalent can be made of V_t and R_t.
short-circuit current = 6.00 amperes
thevenin resistance = 4.00 ohms
thevenin voltage = 24.00 volts

Pg: 82 Ex: 2.18

In [12]:
from __future__ import division
V=10#
R_1=5#
R_2=10#
#Open-circuit anlaysis
#let V_oc be the open circuit voltage
#Current equation at node1   3(i_x)=(1/10)V_oc
#i_x=(10-V_oc)/5   ix in terms of V_oc
V_oc=2/((1/5)+(1/30))#      #open-circuit voltage(from above two equations)
V_t=V_oc#      #thevenin voltage
#short-circuit analysis
i_x=V/R_1#
i_sc=3*i_x#      #short-circuit current
R_t=V_oc/i_sc#
print " All the values in the textbook are approximated, hence the values in this code differ from those of textbook"
print 'Thevenin voltage = %0.2f volts'%V_t
print 'Thevenin resistance = %0.2f ohms'%R_t
 All the values in the textbook are approximated, hence the values in this code differ from those of textbook
Thevenin voltage = 8.57 volts
Thevenin resistance = 1.43 ohms

Pg: 83 Ex: 2.19

In [13]:
from __future__ import division
R1= 20 #Ohms
R2= 15 #ohms
vs= 15 #V
R3= 5 #Ohms
k= 0.25
#/CALCULATIONS
voc= (R2/R1)/((1/R1)+(1/(R2+R3))+(k/4))
isc= vs/R1
Rf= voc/isc
#RESULTS
print 'Rf = %.2f ohms'%Rf
Rf = 6.15 ohms

Pg: 83 Ex: 2.20

In [14]:
from __future__ import division
V_s_1=20#      #voltage source
R_1=5#
R_2=10#
i_s_1=1#      #current source
#Method 1: To transform current source and R_2 into a voltage source in series with R_2
V_s_2=i_s_1*R_2#      #source transformation
i_1=(V_s_1-V_s_2)/(R_1+R_2)#      #clockwise KVL
i_2=i_1+i_s_1#      #KCL at top node of original circuit
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'By current source to voltage source transformation:'
print 'current i1 = %0.2f amperes'%i_1
print 'current i2 = %0.2f amperes'%i_2
#Method 2: To transform voltage source and R_1 into a current source in parallel with R_1
i_s_2=V_s_1/R_1#      #source transformation
i_t=i_s_2+i_s_1#      #total current
i_2=R_1*i_t/(R_1+R_2)      #current-division principle
i_1=i_2-i_s_1#      #KCL at top node of original circuit
print 'By voltage source to current source transformation:'
print 'current i1 = %0.2f amperes'%i_1
print 'current i2 = %0.2f amperes'%i_2
print 'In any method we get the same answers.'
 All the values in the textbook are approximated hence the values in this code differ from those of Textbook
By current source to voltage source transformation:
current i1 = 0.67 amperes
current i2 = 1.67 amperes
By voltage source to current source transformation:
current i1 = 0.67 amperes
current i2 = 1.67 amperes
In any method we get the same answers.

Pg: 84 Ex: 2.21

In [15]:
from __future__ import division
V_s=50#
R_1=20#
R_2=5#
#Zeroing the voltage source
R_eq=1/((1/R_1)+(1/R_2))#      #R_1 and R_2 in parallel
R_t=R_eq#      #thevenin resistance
#open-circuit analysis
V_oc=V_s*R_2/(R_1+R_2)#      #open-circuit voltage
V_t=V_oc#      #thevenin voltage
R_L=R_t#
P_L_max=V_t**2/(4*R_t)
print 'load resistance for maximum power transfer = %0.2f ohms'%R_L
print 'maximum power = %0.2f watts'%P_L_max
load resistance for maximum power transfer = 4.00 ohms
maximum power = 6.25 watts

Pg: 85 Ex: 2.22

In [16]:
from __future__ import division
V_s=15#      #voltage source
R_1=10#
R_2=5#
i_s=2#      #current source
#Analysis with only voltage source active
V_1=R_2*V_s/(R_1+R_2)#      #voltage-division principle
#Analysis with only current source active
R_eq=1/((1/R_1)+(1/R_2))#      #R_1 and R_2 in parallel
V_2=i_s*R_eq#      #ohm's law
V_T=V_1+V_2#      #total response
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'VT i.e., voltage across R2 = %0.2f volts'%V_T
 All the values in the textbook are approximated hence the values in this code differ from those of Textbook
VT i.e., voltage across R2 = 11.67 volts

Pg: 85 Ex: 2.23

In [17]:
from __future__ import division
R_1=1*10**3#
#case (a)
print 'case a:'
R_2=10*10**3#
R_3=732#
R_x=R_2*R_3/R_1#      #wheatstone bridge condition
print 'Value of Rx = %0.2f ohms'%R_x
#case (b)
print 'case b:'
#R_x is maximum when both R_2 and R_3 are maximum
R_2_max=1*10**6#
R_3_max=1100#
R_x_max=R_2_max*R_3_max/R_1#      #wheatstone bridge condition
print 'Maximum value of Rx = %0.2f ohms'%R_x_max
#case(c)
print 'case c:'
#increment in R_x is scale factor times increment in R_3
R_2=1*10**6#
R_3_inc=1#      #increment in R_3
R_x_inc=R_2*R_3_inc/R_1#      #increment in R_x from bride balance condition
print 'Increment between values of Rx = %0.2f ohms for the bridge to be balanced'%R_x_inc
case a:
Value of Rx = 7320.00 ohms
case b:
Maximum value of Rx = 1100000.00 ohms
case c:
Increment between values of Rx = 1000.00 ohms for the bridge to be balanced