# 9: Varying and alternating currents¶

## Example number 9.1, Page number 242¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
L=0.1;   #inductance(H)
R=10;   #resistance(ohm)
t1=0;   #time(sec)
t2=0.002;   #time(sec)
t3=0.04;   #time(sec)
E=5;   #voltage(V)

#Calculation
tow=L/R;   #time(sec)
a=E/R;
i1=a*(1-math.exp(-t1/tow));    #current for t=0 sec(A)
i2=a*(1-math.exp(-t2/tow));    #current for t=0.002 sec(A)
i3=a*(1-math.exp(-t3/tow));    #current for t=0.04 sec(A)
i4=a*(1-math.exp(-tow/tow));    #current for t=tow sec(A)

#Result
print "current for t=0 sec is",i1,"A"
print "current for t=0.002 sec is",round(i2,2),"A"
print "current for t=0.04 sec is",round(i3,2),"A"
print "current for t=tow sec is",round(i4,3),"A"

current for t=0 sec is 0.0 A
current for t=0.002 sec is 0.09 A
current for t=0.04 sec is 0.49 A
current for t=tow sec is 0.316 A


## Example number 9.2, Page number 243¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
L=0.5;   #inductance(H)
R=5;   #resistance(ohm)
E=2;   #voltage(V)
t=0.2;   #time(sec)

#Calculation
tow=L/R;   #time(sec)
a=E/R;
i=a*(1-math.exp(-t/tow));    #current(A)
dibydt=(E-(R*i))/L;       #rate of growth of current(A/s)
E=(1/2)*L*(i**2);     #energy stored by inductor(J)

#Result
print "rate of growth of current is",round(dibydt,2),"A/s"
print "energy stored by inductor is",round(E,2),"J"

rate of growth of current is 0.54 A/s
energy stored by inductor is 0.03 J


## Example number 9.3, Page number 244¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
L=10;   #inductance(H)
R=10;   #resistance(ohm)
E=10;   #voltage(V)
t1=0.3;   #time(sec)
t2=0.5;   #time(sec)
t3=1;   #time(sec)

#Calculation
tow=L/R;   #time(sec)
i0=E/R;
i1=i0*math.exp(-t1/tow);    #current for t=0.3 sec(A)
i2=i0*math.exp(-t2/tow);    #current for t=0.5 sec(A)
i3=i0*math.exp(-t3/tow);    #current for t=1 sec(A)

#Result
print "current for t=0.3 sec is",round(i1,2),"A"
print "current for t=0.5 sec is",round(i2,2),"A"
print "current for t=1 sec is",round(i3,2),"A"

current for t=0.3 sec is 0.74 A
current for t=0.5 sec is 0.61 A
current for t=1 sec is 0.37 A


## Example number 9.4, Page number 250¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
E=5;   #voltage(V)
C=2*10**-6;   #capacitor(F)
R=1*10**6;    #resistance(ohm)
t=1;   #time(sec)
v=40/100;     #decay value(%)

#Calculation
q=E*C*(1-math.exp(-t/(R*C)));     #charge on plates(C)
Vc=q/C;    #voltage drop across capacitor(V)
i0=E/R;
i=i0*math.exp(-t/(R*C));    #current in circuit(A)
V=i*R;    #voltage drop across resistor(V)
E=(1/2)*C*(Vc**2);     #energy stored by capacitor(J)
tow=R*C;     #time constant(sec)
t=2*math.log(1/v);     #time taken(sec)

#Result
print "voltage drop across capacitor is",round(Vc,2),"V"
print "current in circuit is",int(i*10**6),"micro A"
print "voltage drop across resistor is",int(V),"V"
print "energy stored by capacitor is",round(E*10**6,1),"*10**-6 J"
print "time constant is",tow,"sec"
print "time taken is",round(t,4),"sec"

voltage drop across capacitor is 1.97 V
current in circuit is 3 micro A
voltage drop across resistor is 3 V
energy stored by capacitor is 3.9 *10**-6 J
time constant is 2.0 sec
time taken is 1.8326 sec


## Example number 9.5, Page number 265¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
L=1*10**-3;    #inductance(H)
C=0.1*10**-6;   #capacitor(F)
R=1;    #resistance(ohm)

#Calculation
a=1/(L*C);
b=(R**2)/(4*(L**2));
omega=math.sqrt(a-b);    #angular frequency(per sec)
Q=omega*L/R;    #Q-factor

#Result
print "angular frequency is",round(omega),"per sec"
print "answer varies due to rounding off errors"
print "Q-factor is",round(Q)

angular frequency is 99999.0 per sec
answer varies due to rounding off errors
Q-factor is 100.0


## Example number 9.6, Page number 280¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
#v=7sin(314+pi/6)
v=7;
R=100;    #resistance(ohm)

#Calculation
Im=v/R;   #maximum current(A)
Irms=Im/math.sqrt(2);   #rms value of current(A)
Vrms=v/math.sqrt(2);
P=Vrms*Irms;     #average power(W)

#Result
print "maximum current is",Im,"A"
print "rms value of current is",round(Irms,2),"A"
print "average power is",round(P,3),"W"

maximum current is 0.07 A
rms value of current is 0.05 A
average power is 0.245 W


## Example number 9.7, Page number 283¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
#V=7sin(314t+pi/6)
v=7;
omega=314;
L=0.05;   #inductance(H)

#Calculation
XL=omega*L;
betaL=1/XL;    #susceptance(per ohm)
i=v*betaL;     #current through inductor
Im=i;
Irms=Im/math.sqrt(2);    #rms current(A)
P=0;     #power loss

#Result
print "susceptance is",round(betaL,4),"per ohm"
print "current through inductor is",round(i,2),"sin(314t-math.pi/3)"
print "rms current is",round(Irms,2),"A"
print "power loss is",P

susceptance is 0.0637 per ohm
current through inductor is 0.45 sin(314t-math.pi/3)
rms current is 0.32 A
power loss is 0


## Example number 9.8, Page number 286¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
#V=7sin(314t+pi/6)
v=7;
omega=314;
C=0.05*10**-6;   #capacitance(F)

#Calculation
XC=1/(omega*C);    #value of XC
i=v/XC;     #current through capacitor
Im=i;
Irms=Im/math.sqrt(2);    #rms current(A)
P=0;     #power loss

#Result
print "value of XC is",round(XC/10**3,1),"K ohm"
print "current through capacitor is",i*10**3,"*10**-3 sin(314t+2*math.pi/3)"
print "rms current is",int(Irms*10**6),"micro A"
print "power loss is",P

value of XC is 63.7 K ohm
current through capacitor is 0.1099 *10**-3 sin(314t+2*math.pi/3)
rms current is 77 micro A
power loss is 0


## Example number 9.9, Page number 294¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
V1=110;      #voltage(V)
P=40;    #power(W)
V2=230;      #voltage(V)

#Calculation
RB=V1**2/P;    #resistance of bulb(ohm)
i=V1/RB;    #electric current through bulb(A)
Z=V2/i;    #series resistance(ohm)
R=Z-RB;    #pure resistance(ohm)
XL=math.sqrt((Z**2)-(RB**2));
L=XL/314;      #inductance(H)

#Result
print "pure resistance is",R,"ohm"
print "inductance is",round(L,3),"H"

pure resistance is 330.0 ohm
inductance is 1.769 H


## Example number 9.10, Page number 311¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
C=10**-6;    #capacitance(F)
L=10*10**-3;    #inductance(H)
R=1*10**3;    #resistance(ohm)

#Calculation
fr=1/(2*math.pi*math.sqrt(L*C));       #resonant frequency(Hz)
Z=L/(C*R);       #impedence(ohm)

#Result
print "resonant frequency is",round(fr/10**3,3),"KHz"
print "impedence is",Z,"ohm"

resonant frequency is 1.592 KHz
impedence is 10.0 ohm


## Example number 9.11, Page number 312¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
C=5*10**-6;    #capacitance(F)
R=10;    #resistance(ohm)
new=50;    #frequency(Hz)

#Calculation
omega=2*math.pi*new;
L=1/(C*(omega**2));       #self inductance(H)

#Result
print "self inductance is",round(L,3),"H"

self inductance is 2.026 H


## Example number 9.12, Page number 312¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
C=0.1*10**-6;    #capacitance(F)
L=1*10**-3;    #inductance(H)
R=10;    #resistance(ohm)

#Calculation
d=R/L;    #difference between two half power points
cosphi=R/R;    #power factor at resonance

#Result
print "power factor at resonance is",cosphi

resonant frequency is 1.0 *10**5 rad/sec
power factor at resonance is 1.0


## Example number 9.13, Page number 313¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
C=0.1*10**-6;    #capacitance(F)
L=10*10**-3;    #inductance(H)
R=10;    #resistance(ohm)

#Calculation
Z=L/(C*R);       #impedence at resonance(ohm)

#Result
print "impedence at resonance is",Z/10**4,"*10**4 ohm"

impedence at resonance is 1.0 *10**4 ohm


## Example number 9.14, Page number 313¶

In :
#importing modules
import math
from __future__ import division

#Variable declaration
C=5*10**-6;    #capacitance(F)
L=10*10**-3;    #inductance(H)
R=10*10**3;    #resistance(ohm)

#Calculation
omegar=1/math.sqrt(L*C);       #resonant frequency(Hz)
omegar=round(omegar/10**3,1);
delta_omega=1/(R*C);      #bandwidth(Hz)
Q=omegar*10**3/delta_omega;     #Q-factor

#Result
print "resonant frequency is",omegar,"*10**3 Hz"
print "bandwidth is",delta_omega,"Hz"
print "Q-factor is",Q

resonant frequency is 4.5 *10**3 Hz
bandwidth is 20.0 Hz
Q-factor is 225.0