Chapter 2 : Circuit Concepts

Example 2.1 Page No : 21

In [6]:
%matplotlib inline
from matplotlib.pyplot import subplot,plot,xlabel,ylabel,suptitle
from numpy import linspace,arange,array,sin
from scipy.integrate import quad
import math 


# Given
#resistance used is 4 ohm")
#Current flow is i = 2.5*math.sin(w*t)")
#Angular frequency(w) = 500 rad/s")
R = 4;
iamp = 2.5
w = 500;
t = arange(0,0.012566+0.001,.001)
i = 2.5*sin(w*t)

# Calculation and Results
Vamp = iamp*R;
print "v = %d*math.sin%d*t)V)"%(Vamp,w)

pamp = iamp*iamp*R;
print "p = %d sin%d*t))**2W)"%(pamp,w)
p = pamp*sin(w*t)**2;

#On integrating p with respect to t
W = 25*(t/2-sin(2*w*t)/(4*w))

def f(t):
    return pamp*sin(w*t)**2
    
w1 = quad(f,0,2*math.pi/w)[0];


subplot(221)
plot(t,i)
suptitle ('i vs wt')
xlabel('wt')
ylabel('i ');

subplot(222)
plot(t,p)
suptitle('p vs wt')
xlabel('wt')
ylabel('p ');



subplot(223)
plot(t,W)
suptitle ('w vs wt')
xlabel('wt')
ylabel('w ');
v = 10*math.sin500*t)V)
p = 25 sin500*t))**2W)

Example 2.2 Page No : 25

In [7]:
%matplotlib inline

import math
from numpy import arange,sin,cos 
from matplotlib.pyplot import plot,subplot,xlabel,ylabel,suptitle
#Example 2.2")
# Given
#Inducmath.tance used is 30mH")
#Current flow is i = 10*math.sin(50*t)")
L = 30*10**-3;
iamp = 10;
t = arange(0,0.06283+0.01,0.01);
i = 10*sin(50*t)
#v = L*d/dt(i)
#d/dt(math.sin 50t) = 50*math.cos t
vamp = L*iamp*50;
v = vamp*cos(50*t)

#math.sinA*math.cosB = (math.sin(A+B)+math.sin(A-B))/2

pamp = vamp*iamp/2;
p = pamp*sin(100*t)
#On integrating 'p' w.r.t  t

wL = 0.75*(1-cos(100*t));


subplot(221)
plot(t,i)
suptitle ('i vs wt')
xlabel('wt')
ylabel('i');

subplot(222)
plot(t,v)
suptitle ('v vs wt')
xlabel('wt')
ylabel('c');


subplot(223)
plot(t,p)
suptitle ('p vs wt')
xlabel('wt')
ylabel('p');

subplot(224)
plot(t,wL)
suptitle ('wL vs wt')
xlabel('wt')
ylabel('wL');

Example 2.3 Page No : 30

In [10]:
%matplotlib inline

import math
from numpy import cos,arange,sin
from matplotlib.pyplot import plot,xlabel,ylabel,suptitle 

#Example 2.3")
# Given
#capacitance used is 20uF")
#Voltage is v = 50*math.sin(200*t)")
C = 20*10**-6;
# Given that v = 50*math.sin(200*t);
vamp = 50;
t = arange(0,0.015+0.001,0.001);
#q = C*v
qamp = vamp*C
q = qamp*sin(200*t)
#i = C*d/dt(v)
#d/dt(math.sin 200t) = 200*math.cos t
iamp = C*vamp*200;
i = iamp*cos(200*t)

#math.sinA*math.cosB = (math.sin(A+B)+math.sin(A-B))/2

pamp = vamp*iamp/2;
p = pamp*sin(400*t)

#On integrating 'p' w.r.t  t

wC = 12.5*(1-cos(400*t));

plot(t,wC)
suptitle ('wC vs wt')
xlabel('wt')
ylabel('wC (mJ)');

Example 2.4 Page No : 33

In [9]:
import math 


# Given
#Current through diode is 30mA")
#From the table the nearest value is at v = 0.74V
V = 0.74;
I = 28.7*10**-3;
R = V/I;
delV = 0.75-0.73

# Calculation
delI = 42.7*10**-3-19.2*10**-3
r = delV/delI
p = (V*I)*10**3

# Results
print "  Static resistance is %3.2fohm"%(R)
print "Dynamic resistance is %3.2fohm"%(r)
print "Power consumption is %3.2fmW"%(p)
  Static resistance is 25.78ohm
Dynamic resistance is 0.85ohm
Power consumption is 21.24mW

Example 2.5 Page No : 34

In [11]:
import math 

# Given
#a)")
#Current through diode is 10mA")
#From the table the  value is at v = 2.5V
V = 2.5;
I = 10*10**-3;
R = V/I;
delV = 3.-2
delI = 11.*10**-3-9*10**-3

# Calculation and Results
r = delV/delI
p = (V*I)*10**3
print "  Static resistance is %3.2fohm"%(R)
print "Dynamic resistance is %3.2fohm"%(r)
print "Power consumption is %3.2fmW"%(p)

#b)")
#Current through diode is 15mA")
#From the table the  value is at v = 5V
V = 5;
I = 15*10**-3;
R = V/I;
delV = 5.5-4.5
delI = 16*10**-3-14*10**-3
r = delV/delI
p = (V*I)*10**3
print "  Static resistance is %3.2fohm"%(R)
print "Dynamic resistance is %3.2fohm"%(r)
print "Power consumption is %3.2fmW"%(p)
  Static resistance is 250.00ohm
Dynamic resistance is 500.00ohm
Power consumption is 25.00mW
  Static resistance is 333.33ohm
Dynamic resistance is 500.00ohm
Power consumption is 75.00mW