Chapter 3 - Inductance and Capacitance

Pg: 109 Ex: 3.1

In [1]:
from __future__ import division
from numpy import arange,array
%matplotlib inline
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show

C=1*10**-6#
#t in micro seconds
t_1=[];t_2=[];t_3=[]
for x in arange(0,2+0.001,0.001):
    t_1.append(x)
for x in arange(2.001,4+0.001,0.001):
    t_2.append(x)
for x in arange(4.001,5+0.001,0.001):
    t_3.append(x)
tt=t_1+t_2+t_3

#t=array(t)
#corresponding voltage variations
V_1=[]
for t in t_1:
    V_1.append(5*t)
    
V_2=[]
for t in t_2:
    V_2.append(0*t+10)
V_3=[]
for t in t_3:
    V_3.append(-10*t+50)


#charge q=C*V
q_1=[]
for v in V_1:
    q_1.append(C*v*10**6)

q_2=[]
for v in V_2:
    q_2.append(C*v*10**6)

q_3=[]
for v in V_3:
    q_3.append(C*v*10**6)
q=q_1+q_2+q_3


subplot(121)
plot(tt,q)
title('charge vs time')
xlabel('time in Ms')
ylabel('charge in Mc')      #M-micro(10**-6)
#current i=C*dV/dt*10**6, for above equations we get
i_1=[];i_2=[];i_3=[]
for t in t_1:
    i_1.append(10**6*(0*t+C*(5)))
for t in t_2:
    i_2.append(10**6*0*t)
for t in t_3:
    i_3.append(10**6*(0*t+C*(-10)))
i=i_1+i_2+i_3
subplot(122)
plot(tt,i)
title('current vs time')
xlabel('time in Ms')
ylabel('current in amperes')      #M-micro(10**-6)   
show()

Pg: 110 Ex: 3.2

In [2]:
from __future__ import division
from numpy import arange,array
%matplotlib inline
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show
from math import pi,sin,cos
C=0.1*10**-6#
#symbolic integration cannot be done in scilab
t=arange(0,pi*10**-4+0.001*10**-3,0.001*10**-3)
i=[]
for tt in t:
    i.append(0.5*sin((10**4)*tt))
#on integrating 'i' w.r.t t
q=[]
for tt in t:
    q.append(0.5*10**-4*(1-cos(10**4*tt))*10**6)
C=10**-7#
V=[]
for qq in q:
    V.append(qq/C)
subplot(311)
plot(t,q)
title('charge vs time')
xlabel('time in seconds')
ylabel('charge in Mc')      #Mc=micro coulombs(10**-6)
subplot(312)
plot(t,i)
title('current vs time')
xlabel('time in seconds')
ylabel('current in amperes')      #Mc=micro coulombs(10**-6)
subplot(313)
title('voltage vs time')
xlabel('time in seconds')
ylabel('voltage in volts')
plot(t,V)
show()

Pg: 111 Ex: 3.3

In [3]:
from __future__ import division
from numpy import arange,array
%matplotlib inline
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show
from math import pi,sin,cos
C=10*10**-6#
t_1=arange(0,1+0.001,0.001)
t_2=arange(1.001,3+0.001,0.001)
t_3=arange(3.001,5+0.001,0.001)
t=[]
for x in t_1:
    t.append(x)
for x in t_2:
    t.append(x)
for x in t_3:
    t.append(x)
    #voltage variations
V_1=[];V_2=[];V_3=[]
for tt in t_1:
    V_1.append(1000*tt)
for tt in t_2:
    V_2.append(0*tt+1000)
for tt in t_3:
    V_3.append(500*(5-tt))
#current i=C*dv/dt, for above equations we get
i_1=[];i_2=[];i_3=[]
for tt in t_1:
    i_1.append(C*(0*tt+1000))
for tt in t_2:
    i_2.append(C*(0*tt))
for tt in t_3:
    i_3.append(C*(0*tt-500))
i=i_1+i_2+i_3
#power delivered, P=V*i
P_1=[];P_2=[];P_3=[]
for tt in t_1:
    P_1.append(C*(10**6*tt))
for tt in t_2:
    P_2.append(C*(0*tt+1000))
for tt in t_3:
    P_3.append(C*(-25*10**4*(5-tt)))
P=P_1+P_2+P_3
#energy stored, W=(1/2)*C*V**2
W_1=[];W_2=[];W_3=[]
for vv in V_1:
    W_1.append((1/2)*C*vv**2)
for vv in V_2:
    W_2.append((1/2)*C*vv**2)
for vv in V_2:
    W_3.append((1/2)*C*vv**2)
W=[]
for x in W_1:
    W.append(x)
for x in W_2:
        W.append(x)
for x in W_3:
    W.append(x)
subplot(311)
plot(t,[ii*10**3 for ii in i])
title('current vs time')
xlabel('time in seconds')
ylabel('current in mA')      #mA-milli amperes(10**-3)
subplot(312)
plot(t,P)
title('power delivered vs time')
xlabel('time in seconds')
ylabel('power in watts')
subplot(313)

plot(t[:-1],W)
title('energy stored vs time')
xlabel('time in seconds')
ylabel('work in joules')
show()

Pg: 111 Ex: 3.4

In [4]:
from __future__ import division
L=10*10**-2#      #length
W=20*10**-2#      #width
d=0.1*10**-3#      #distance between plates
A=L*W#      #area
E_o=8.85*10**-12#      #dielectric constant of vacuum
#dielectric is air
E_r=1#      #relative dielectric constant of air
E=E_r*E_o#      #dielectric constant
C=E*A/d#      #capacitance
print 'When the dielectric is air, capacitance = %0.2f pF'%(C*10**12)    #pF-pico Farad(10**-12)
#dielectric is mica
E_r=7#      #relative dielectric constant of mica
E=E_r*E_o#      #dielectric constant
C=E*A/d#      #capacitance
print 'When the dielectric is mica, capacitance = %0.2f pF'%(C*10**12)      #pF-pico Farad(10**-12)
When the dielectric is air, capacitance = 1770.00 pF
When the dielectric is mica, capacitance = 12390.00 pF

Pg: 112 Ex: 3.5

In [5]:
from __future__ import division
C_1=1*10**-6#
C_2=1*10**-6#
#Before the switch is closed
V_1=100#
V_2=0#
W_1=(1/2)*C_1*V_1**2#
W_2=0#      #V_2=0
W_t_1=W_1+W_2#      #total energy stored by both the capacitors before switch is closed
q_1=C_1*V_1#
q_2=0#
#After the switch is closed
q_eq=q_1+q_2#      #charge on equivalent capacitance
C_eq=C_1+C_2#      #C_1 and C_2 in parallel
V_eq=q_eq/C_eq#
V_1=V_eq#      #parallel combination
V_2=V_eq#      #parallel combination
W_1=(1/2)*C_1*V_eq**2#
W_2=(1/2)*C_2*V_eq**2#
W_t_2=W_1+W_2#      #total energy stored by both the capacitors after switch is closed
print 'Total energy stored by both the capacitors before switch is closed = %0.2f mJ'%(W_t_1*10**3)      #mJ-milli Joules(10**-3)
print 'Total energy stored by both the capacitors after switch is closed = %0.2f mJ'%(W_t_2*10**3)      #mJ-milli Joules(10**-3)
Total energy stored by both the capacitors before switch is closed = 5.00 mJ
Total energy stored by both the capacitors after switch is closed = 2.50 mJ

Pg: 113 Ex: 3.6

In [6]:
from __future__ import division
from numpy import arange,array
%matplotlib inline
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show

L=5#      #inductance
t_1=arange(0,2+0.001,0.001)
t_2=arange(2.001,4+0.001,0.001)
t_3=arange(4.001,5+0.001,0.001)
t=[]
for x in t_1:
    t.append(x)
for x in t_2:
    t.append(x)
for x in t_3:
    t.append(x)

#corresponding current variations
i_1=[];i_2=[];i_3=[]
for tt in t_1:
    i_1.append((1.5)*tt)
for tt in t_2:
    i_2.append(0*tt+3)
for tt in t_3:
    i_3.append((-3*tt)+15)
#voltage V=L*(di/dt)
V_1=[];V_2=[];V_3=[]
for tt in t_1:
    V_1.append(L*(0*tt+(1.5)))
for tt in t_2:
    V_2.append(L*(0*tt))
for tt in t_3:    
    V_3.append(L*(0*tt-3))
V=[]
for x in V_1:
    V.append(x)
for x in V_2:
    V.append(x)
for x in V_3:
    V.append(x)
#stored energy W=1/2*L*i**2
W_1=[];W_2=[];W_3=[]
for ii in i_1:
    W_1.append((1/2)*L*ii**2)
for ii in i_2:
    W_2.append((1/2)*L*ii**2)
for ii in i_3:
    W_3.append((1/2)*L*ii**2)

W=[]
for x in W_1:
    W.append(x)
for x in W_2:
        W.append(x)
for x in W_3:
    W.append(x)

P_1=[];P_2=[];P_3=[]    
#power P=V*i
for tt in t_1:
    P_1.append(L*tt*(1.5**2))
for tt in t_2:
    P_2.append(0*tt)
for tt in t_3:    
    P_3.append(-3*L*(-3*tt+15))
P=[]
for x in P_1:
    P.append(x)
for x in P_2:
    P.append(x)
for x in P_3:
    P.append(x)

    
subplot(311)
plot(t,V)
title('voltage vs time')
xlabel('time in seconds')
ylabel('voltage in volts')
subplot(312)
plot(t,W)
title('energy vs time')
xlabel('time in seconds')
ylabel('energy in joules')
subplot(313)

plot(t,P)
title('power vs time')
xlabel('time in seconds')
ylabel('power in watts')
show()