Chapter 12: Resistance and DC Circuits

Example 12.1, Page 237

In [1]:
#Initialization
i1=8                                 #current in Amp
i2=1                                #current in Amp
i3=4                                #current in Amp

#Calculation
i4=i2+i3-i1                                #current in Amp

#Results
print'Magnitude, I4 = %d A'%i4
Magnitude, I4 = -3 A

Example 12.2, Page 239

In [ ]:
#Initialization
e=12                   #EMF source in volt
v1=3                   #node voltage
v3=3                   #node voltage

#Calculation
v2=v1+v3-e                   #node voltage

#Results
print'V2 = %d V'%v2

Example 12.4, Page 242

In [11]:
import numpy as np

#We have used method II for solving our problem by using simultaneous equations

a = np.array([[25,-2],[400,-8]]) 
b = np.array([[50],[3200]])
c=np.linalg.solve(a,b)

print'Voc = %d V'%c[0]
print'R = %d ohm'%c[1]
    
Voc = 10 V
R = 100 ohm

Example 12.5, Page 244

In [2]:
#Initialization
r1=100                  #Resistance in Ohm
r2=200                 #Resistance in Ohm
r3=50                 #Resistance in Ohm
v1=15                 #voltage source
v2=20                 #voltage source

#Calculation
#Considering 15 V as a source & replace the other voltage source by its internal resistance,
r11=(r2*r3)*(r2+r3)**-1              #resistance in parallel
v11=v1*(r11/(r1+r11))               #voltage
#Considering 20 V as a source & replace the other voltage source by its internal resistance,
r22=(r1*r3)*(r1+r3)**-1              #resistance in parallel
v22=v2*(r22/(r2+r22))               #voltage

#output of the original circuit
v33=v11+v22



#Results
print'Voltage, V = %.2f'%v33
Voltage, V = 7.14

Example 12.6, Page 246

In [4]:
#Initialization
r1=10                  #Resistance in Ohm
r2=5                  #Resistance in Ohm
v2=5                 #voltage source
i=2                 #current in Amp

#Calculation
#Considering 5 V as a source & replace the current source by its internal resistance,
i1=v2*(r1+r2)**-1                   #current using Ohms law
#Considering current source & replace the voltage source by its internal resistance,
r3=(r1*r2)*(r1+r2)**-1              #resistance in parallel
v3=i*r3                         #voltage using Ohms law
i2=v3*r2**-1                   #current using Ohms law
i3=i1+i2                       #total current

#Results
print'Output Current, I = %.2f A'%i3
Output Current, I = 1.67 A

Example 12.8, Page 251

In [22]:
import numpy as np
r=25                    #resistance in ohm

#We have used for solving our problem by using simultaneous equations

a = np.array([[(-13*60**-1),(1*20**-1)],[(1*60**-1),(-9*100**-1)]]) 
b = np.array([[-5],[-100*30**-1]])
c=np.linalg.solve(a,b)
i1=c[1]/r                        #required current

print'V2 = %.2f V'%c[0]          #wrong answer in textbook
print'V3 = %.2f V'%c[1]          #wrong answer in textbook
print'Current, I1 = %.2f A'%i1
    
V2 = 33.04 V
V3 = 43.15 V
Current, I1 = 1.73 A

Example 12.9, Page 253

In [34]:
import numpy as np
re=10                 #resistance in ohm

#We have used for solving our problem by using simultaneous equations

a = np.array([[(-160),(20), (30)],[(20),(-210), (10)], [(30),(10), (-190)]]) 
b = np.array([[-50],[0],[0]])
c=np.linalg.solve(a,b)
ve=re*(c[2]-c[1])

print'I1 = %d mA'%(c[0]*10**3)             #current I1
print'I2 = %d mA'%(c[1]*10**3)              #current I2
print'I3 = %d mA'%(c[2]*10**3)              #current I3
print'Voltage, Ve = %.3f V'%ve
    
I1 = 326 mA
I2 = 33 mA
I3 = 53 mA
Voltage, Ve = 0.197 V
In [ ]: