Chapter 3: AC Fundamentals

Example 2: pg 119

In [1]:
#pg 119
#calculate the max. current, frequency and instantaneous current
import math
# Given data
Im = 141.4;# in A
t = 3;# in ms
t = t * 10**-3;# in sec
#calculations
omega = 314;# in rad/sec
# omega = 2*%pi*f;
f = round(omega/(2*math.pi));# in Hz
T = 1/f;# in sec
i = 141.4 * math.sin(omega*t);# in A
#results
print "The maximum value of current in A is",Im
print "The frequency in Hz is",f
print "The time period in sec is",T
print "The instantaneous value in A is",round(i,2)
The maximum value of current in A is 141.4
The frequency in Hz is 50.0
The time period in sec is 0.02
The instantaneous value in A is 114.36

Example 3: pg 119

In [2]:
#pg 119
#calculate the current and time taken
# Given data
from math import sin,asin,pi
f = 60.;# in Hz
Im = 120.;# in A
t = 1/360.;# in sec
#calculations
omega = 2*pi*f;# in rad/sec
i = Im*sin(omega*t);# in A
print "The value of current after 1/360 sec in A is",round(i,2)
i = 96;# in A
# i = Im*sind(omega*t);
t = (asin(i/Im))/omega;# in sec
print "The time taken to reach 96 A for the first time in sec is",round(t,5)
The value of current after 1/360 sec in A is 103.92
The time taken to reach 96 A for the first time in sec is 0.00246

Example 4: pg 120

In [3]:
#pg 120
#calculate the average, RMS values of current. also find form and peak factors
from math import sqrt
# Given data
i1 = 0;# in A
i2 = 10.;# in A
i3 = 20.;# in A
i4 = 30.;# in A
i5 = 20.;#in A
i6 = 10.;# in A
n = 6.;# unit less
#calculations
Iav = (i1+i2+i3+i4+i5+i6)/n;# in A
print "The average value in A is",Iav
Irms = sqrt(( (i1**2) + (i2**2) + (i3**2) + (i4**2) + (i5**2) + (i6**2) )/n);# in A
print "The RMS value in A is",round(Irms,1)
k_f = Irms/Iav;# unit less
print "The form factor is",round(k_f,2)
Im = 30;# in A
k_p = Im/Irms;# unit less
print "The peak factor is",round(k_p,2)
The average value in A is 15.0
The RMS value in A is 17.8
The form factor is 1.19
The peak factor is 1.69

Example 5: pg 121

In [4]:
#pg 121
#calculate the phase difference
# Given data
theta1 = 60.;# in degree
theta2 = -45.;# in degree
#calculations
# phase difference 
phi = theta1-theta2;# in degree
#results
print "The phase difference in degree is",phi
The phase difference in degree is 105.0

Example 6: pg 121

In [5]:
#pg 121
#calculate the sum and difference
# Given data
import cmath,numpy
from math import cos,sin,atan,pi
V1= 60*(cos(0*pi/180) + 1j*sin(0*pi/180));# in V
V2= 40*(cos(-pi/3.) +1j*sin(-pi/3));# in V
#calculations
add_V= V1+V2;# in V
diff_V= V1-V2;# in V
#results
print "The sum of V1 and V2 is : "
print round(abs(add_V),3)," sin (theta",round(numpy.angle(add_V)*180/pi,2),") V"
print "The difference of V1 and V2 is : "
print round(abs(diff_V),3)," sin (theta+",round(numpy.angle(diff_V)*180/pi,3),") V"
The sum of V1 and V2 is : 
87.178  sin (theta -23.41 ) V
The difference of V1 and V2 is : 
52.915  sin (theta+ 40.893 ) V

Example 7: pg 121

In [6]:
#pg 121
#calculate the average, rms value of current and form factor
# Given data
import math,scipy
from scipy import integrate
from math import cos,sqrt,pi,sin
Vo= 1;# in V (assumed)
#calculations
fun1 = lambda theta:Vo*sin(theta)
fun2= lambda theta: Vo**2*(1-cos(2*theta))/2
Vav= scipy.integrate.quad(fun1,0,pi)[0]/(2*pi);
Vrms= sqrt(scipy.integrate.quad(fun2,0,pi)[0])*sqrt(1./(2*pi));
kf= Vrms/Vav;
#results
print "The average value of output voltage in volts is : ",round(Vav,3),"*Vo or Vo/pi"
print "The R.M.S value of output voltage in volts is :  ",Vrms,"*Vo or Vo/2"
print "The form factor is : ",round(kf,2)
The average value of output voltage in volts is :  0.318 *Vo or Vo/pi
The R.M.S value of output voltage in volts is :   0.5 *Vo or Vo/2
The form factor is :  1.57

Example 8: pg 123

In [7]:
#pg 123
#calculate the average and rms value of voltage
# Given data
from scipy import integrate
from math import sqrt
T = 0.3;# in sec
V = 20;# in V
#calculations
fun1 = lambda t:1
Vav = 1/T*V*integrate.quad(fun1,0,0.1)[0]
Vrms =sqrt(1/T*V**2*integrate.quad(fun1,0,0.1)[0]) 
#results
print "The average value of voltage in V is",round(Vav,2)
print "The R.M.S value of voltage in V is",round(Vrms,1)
The average value of voltage in V is 6.67
The R.M.S value of voltage in V is 11.5

Example 9: pg 123

In [8]:
#pg 123
#calculate the polar and rectangular form of voltage
# Given data
import cmath,numpy
from math import pi,sqrt,cos,sin
Vm = 100;# in V
phi = pi/6;# in degree
#calculations
Vrms = Vm/(sqrt(2.));# in V
# Rectangular form of the voltage 
RectForm= Vrms*(cos(phi) + 1j*sin(phi))
#results
print "Rectangular form of the voltage in V is : ",round(RectForm.real,2),"+1j*",round(RectForm.imag,2)
print "Polar form of the voltage :"
print "Magnitude of voltage in V is : ",round(abs(RectForm),4)," V"
print "Angle is : ",round(numpy.angle(RectForm)*180/pi,3)," degree"
Rectangular form of the voltage in V is :  61.24 +1j* 35.36
Polar form of the voltage :
Magnitude of voltage in V is :  70.7107  V
Angle is :  30.0  degree

Example 10: pg 123

In [10]:
#pg 123
#calculate the rms value 
# Given data
import cmath,math,scipy
from scipy.linalg import expm
from math import sqrt,pi
from cmath import exp
V1= 100/sqrt(2)*exp(1j*0.*pi/180);# in V
V2= 200/sqrt(2)*exp(1j*60.*pi/180);# in V
V3= 50/sqrt(2)*exp(1j*-90.*pi/180);# in V
V4= 150/sqrt(2)*exp(1j*-45.*pi/180);# in V
#calculations
# The R.M.S. value of the resultant 
V_R= V1.real+V2.real+V3.real+V4.real;# in V
#results
print "The R.M.S. value of the resultant in volts is : ",round(V_R,2)
The R.M.S. value of the resultant in volts is :  216.42

Example 11: pg 124

In [11]:
#pg 124
#calculate the current and time
from math import pi,sin,asin
# Given data
Im = 15.;# in A
f = 60.;# in Hz
#calculations
omega = 2*pi * f;# in rad/sec
t = 1/200.;# in sec
i = Im*sin(omega*t);# in A
i = 10;# in A
# i = Im*sind(omega*t);
print "The value of current after 1/200 sec in A is",i
t = (asin(i/Im))/omega;# in sec
t = t * 10**3;# in ms
print "The time to reach 10 A in ms is",round(t,4)
Iav = Im*0.637;# in A
print "The average value in A is",Iav
The value of current after 1/200 sec in A is 10
The time to reach 10 A in ms is 1.9357
The average value in A is 9.555

Example 12: pg 125

In [12]:
#pg 125
#calculate the current, frequency, form factor
# Given data
from math import sqrt,pi,sin
Im = 42.42;# in A
omega = 628;# in rad/sec
t = 1/6.977;# in sec assumed 
#calculations
i = Im*sin(omega*t/180*pi);# in A
print "The maximum value of current in A is",round(i,2)
# omega = 2*%pi*f;
f = omega/(2*pi);# in Hz
print "The frequency in Hz is",round(f)
Irms = Im/(sqrt(2));# in A
print "The rms value in A is",round(Irms)
Iav = (2*Im)/pi;# in A
print "The average value in A is",round(Iav)
k_f = Irms/Iav;
print "The form factor is",round(k_f,2)
The maximum value of current in A is 42.42
The frequency in Hz is 100.0
The rms value in A is 30.0
The average value in A is 27.0
The form factor is 1.11

Example 13: pg 125

In [13]:
#pg 125
#calculate the power factor, rms value and frequency
# Given data
from math import cos,pi,sqrt
phi = pi/6;
#calculations
# Power factor
powerfactor = cos(phi);# in lag
print "The power factor is",round(powerfactor,3)
Im = 22.;# in A
# The R.M.S value of current 
Irms = Im/sqrt(2);# in A
print "The R.M.S value of current in A is",round(Irms,4)
omega = 314;# in rad/sec
# omega = 2*%pi*f;
f = omega/(2*pi);# in Hz
print "The frequency in Hz is",round(f)
The power factor is 0.866
The R.M.S value of current in A is 15.5563
The frequency in Hz is 50.0

Example 14: pg 126

In [14]:
#pg 126
#calculate tghe form factor, average and rms value of current
# Given data
from math import sqrt,sin,cos,pi
from scipy import integrate
Im= 100.;# in A
#calculations
fun1 = lambda theta:1-cos(2*theta)
Irms= sqrt(Im**2/2*integrate.quad(fun1,0,pi)[0]/pi);# in A
print "The R.M.S value of current in A is : ",round(Irms,4)
fun2 = lambda theta:sin(theta)
Iav= Im*integrate.quad(fun2,0,pi)[0]/pi;# in A
print "The average value of current in A is : ",round(Iav,4)
# The form factor 
kf= Irms/Iav;
print "The form factor is : ",round(kf,2)
The R.M.S value of current in A is :  70.7107
The average value of current in A is :  63.662
The form factor is :  1.11

Example 15: pg 127

In [15]:
#pg 127
# Given data
from math import sqrt
from scipy import integrate
A= 2*10;# area under curve for a cycle
B= 2;# base of half cycle
#calculations
Vav= 1./2*A/B;# in V
# For line AB
y1= 0;
y2= 10.;
x1= 0;
x2= 1.;
m_for_AB= (y2-y1)/(x2-x1);
# For line BC
y1= 10.;
y2= 0;
x1= 1;
x2= 2;
m_for_BC= (y2-y1)/(x2-x1);
fun1=lambda t:(m_for_AB*t)**2
fun2= lambda t:(m_for_BC*t+20)**2
Vrms= sqrt((integrate.quad(fun1,0,1)[0]+integrate.quad(fun2,1,2)[0])/2.);# in V
kf= Vrms/Vav;
print "The form factor is : ",round(kf,3)
The form factor is :  1.155