from numpy import array, nditer
from math import pi, cos
from __future__ import division
#plot the varaition of average load voltage with firing angle
alpha=array([0, 30, 60, 90]) #firing angle in degree
ea=array([(2/pi)*cos(pi/180*alpha[0]), (2/pi)*cos(pi/180*alpha[1]), (2/pi)*cos(pi/180*alpha[2]), (2/pi)*cos(pi/180*alpha[3])])
#############PLOT###########
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(alpha,ea) #
plt.ylabel("Average load voltage(in terms of Vm)")
plt.xlabel("Firing angle (alpha)")
plt.title("Variation of Ea Vs alpha for SAC")
plt.show()
from math import degrees, acos, sqrt, pi, cos
#IS_rms, I1_rms, FPF, PF and HF
#given data :
Vm=230 # in volts
Ia=12 # in A
Av=200 # average load voltage in volts
alfa = acos(Av*pi/Vm/sqrt(2)-1)*180/pi
Is_rms=Ia*sqrt((180-alfa)/180)
print "(1)for PAC : "
print "(a) Is_rms = %0.2f A" %Is_rms
I1_rms=((2*sqrt(2))/pi)*Ia*cos(alfa/2*pi/180)
print "(b) I1_rms = %0.2f A" %I1_rms
fi=alfa/2
FPF=cos(pi/180*fi)
print "(c) FPF = %0.4f lag" %FPF
CDF=I1_rms/Is_rms
print "(d) CDF = %0.4f "%CDF
PF=CDF*FPF
print "(e) PF = %0.4f lag" %PF
HF=sqrt((1/CDF**2)-1)
print "(f) HF = %0.4f "%HF
print "(2)for SAC : "
Vm=230 # in volts
Ia=12 # in A
Av=200 # average load voltage in volts
alfa = degrees(acos(Av*pi/2/sqrt(2)/Vm))
Is_rms=Ia*sqrt((180-(2*alfa))/180)
print "(a) Is_rms = %0.2f A" %Is_rms
I1_rms=((2*sqrt(2))/pi)*Ia*cos(alfa*pi/180)
print "(b) I1_rms = %0.2f A" %I1_rms
CDF=I1_rms/Is_rms
print "(c) CDF = %0.3f "%CD
fi=0 # degree
FPF=cos(pi/180*fi)
print "(d) FPF = %0.2f "%FPF
#in book CDF is mentioned as DF which is wrongly mentioned
PF=CDF*FPF
print "(e) PF = %0.3f lagging" %PF
HF=(sqrt((1/CDF**2)-1))*100
print "(f) HF = %0.2f %%" %HF
from __future__ import division
from math import sqrt, pi, cos
#average voltage
a1=30 #in degree
a2=75 #in degree
b1=60 #in degree
ia=10 #in amperes
vsrms=230 #in volts
b3=180-a1 #
a3=180-b1 #
b2=180-a2 #
alfa=0 #
vldc=((vsrms*sqrt(2))/pi)*(cos(pi/180*a1)-cos(pi/180*b1)+cos(pi/180*a2)-cos(pi/180*b2)+cos(pi/180*a3)-cos(pi/180*b3))
print "average voltage = %0.1f V" %vldc
Is_rms=ia*((1/180)*(b1-a1+b2-a2+b3-a3))**(1/2) #
print "Is_rms = %0.2f A" %Is_rms
I1_rms=((sqrt(2)*ia)/(pi))*(cos(pi/180*a1)-cos(pi/180*b1)+cos(pi/180*a2)-cos(pi/180*b2)+cos(pi/180*a3)-cos(pi/180*b3))
print "I1_rms = %0.2f A" %I1_rms
fi=alfa
FPF=cos(I1_rms*fi)
print "FPF = %0.2f"%FPF
DF=I1_rms/Is_rms
print "DF = %0.4f"%DF
PF=DF*FPF
print "PF = %0.4f lag" %PF
HF=sqrt((1/DF**2)-1)
print "HF = %0.2f %%" %(HF*100)
#IS_rms, I1_rms, PF and HF
#given data :
Vm=230 # in volts
Ia=10 # in A
alpha=pi/6 #degree
ea=((2*Vm*sqrt(2))/pi)*cos(alpha) #
print "average output voltage = %0.2f V" %ea
isrms=Ia*(1-(2*alpha)/pi)**(1/2) #
print "rms value of supply current = %0.2f A" %isrms
I1rms=((2*sqrt(2)*Ia*cos(alpha))/pi) #
print "rms value of fundamental component of supply current = %0.2f A" %I1rms
hf=((isrms/I1rms)**2-1)**(1/2) #
print "HF of supply current = %0.2f %%"%(hf*100)
PF=((sqrt(2))*(1+cos(alpha)))/((pi*(pi-alpha))**(1/2)) #
print "PF (lagging)of supply current = %0.2f %%"%PF
# Answer for HF is calculated wrong in the textbook.