from math import sqrt
#average load voltage,RMS load voltage ,Form factor and Ripple factor
#given data
f=1.0 #in kHz
t=1/f #in ms
d=0.3 #
v=200 #
vch=2 #in volts
vldc=(v-vch)*d #average load voltage in volts
print "part (a)"
print "average load voltage = %0.2f V" %vldc
print "part (b)"
vlrms=(v-vch)*sqrt(d) #RMS load voltage in volts
print "RMS load voltage = %0.1f V" %vlrms
print "part (c)"
FF=vlrms/vldc #
print "form factor = %0.4f or %0.2f %%"%(FF,FF*100)
print "part (d)"
rf=sqrt(FF**2-1) #
print "ripple factor = %0.3f or %0.2f %%"%(rf,rf*100)
#chooper efficiency,input resistance and average load current
#given data
r=10 #in ohms
f=1 #in kHz
t=1/f #in ms
d=0.3 #
v=200 #
vch=2 #in volts
Po=((v-vch)**2)*(d/r) #in watts
Pi=((d*v*(v-vch))/r) #in watts
cn=Po/Pi #chopper efficiency
print "part (a)"
print "chopper efficiency = %0.3f or %0.2f %%"%(cn,cn*100)
print "part (b)"
R1=r/d #
print "input resistance = %0.2f ohm " %R1
print "part (c)"
vldc=59.4 #V
r=10 #ohm
Ildc=vldc/r #amp
print "average load current = %0.2f A" %Ildc
#Duty Cycle,Average Load voltage and RMS Load Voltage
#given data
V=200 # in volts
T_on=500*10**-6
f=1*10**3 # in Hz
D=T_on*f
print "part (a)"
print "duty cycle =",D,"or",D*100,"%"
print "part (b)"
VL_dc=D*V
print "Average Load Voltage = %0.2f V" %(VL_dc)
print "part (c)"
VL_rms=sqrt(D)*V
print "RMS Load Voltage, VL_rms = %0.f V" %VL_rms
#part c answer is calculated wrong in book
#average load voltage and rms load voltage
#given data
from numpy import arange, nditer, array
Sr = arange(1,11)
d = arange(0,1.1,0.1)
vldc = d
def rms(d):
it = nditer([d, None])
for x, y in it:
y[...] = sqrt(x)
return it.operands[1]
vlrms = rms(d)
Z = vldc
U = vlrms
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(d,vlrms)
plt.plot(d,vldc)
plt.xlabel("DUTY CYCLE D")
plt.ylabel("Vldc & Vlrms Volts")
plt.title("Variation of Vldc and Vlrms with duty cycle D")
plt.text(0.5,0.4,'VLdc')
plt.text(0.3,0.7,'VLrms')
plt.show()
print "Sr.No\t\t\tDuty Cycle D\t\t\tAvg. Load Voltage\t\t\tRMS load voltage"
for i,d,z,u in nditer([range(1,12),d,Z,U]):
print ' ',i,'\t\t\t ',d,'\t\t\t\t\t',z,'\t\t\t\t %0.3f'%u
from numpy import arange, nditer, sqrt
#average load voltage and rms load voltage
#given data
D=arange(0.1,1.1,0.1)
def fun1(D):
it=nditer([D, None])
for x, y in it:
y[...] = 1/sqrt(x)*100
return it.operands[1]
FF = fun1(D)
def fun2(FF):
it = nditer([FF, None])
for x,y in it:
y[...] = sqrt((x/100)**2-1)*100
return it.operands[1]
RF = fun2(FF)
if D.any():
print "Duty Cycle D : ",
for d in D:
print d,'\t',
print ''
if FF.all():
print " FF % : ",
for ff in FF:
print round(ff,2),'\t',
print ''
if RF.any():
print " RF % : ",
for rf in RF:
print round(rf,2),'\t',
% matplotlib inline
import matplotlib.pyplot as plt
plt.plot(D,FF)
plt.plot(D,RF)
plt.xlabel("DUTY CYCLE D")
plt.ylabel("FF & RF (%)")
plt.title("Variation of FF and RF with duty cycle D")
plt.text(0.7,130,'FF %')
plt.text(0.7,70,'RF %')
plt.show()
from __future__ import division
#Average output voltage,RMS output voltage,chopper efficiency and Effective input resistance
#given data :
r=10 #in ohms
d=0.3 #
v=230 #
vch=1.5 #in volts
D=80/100 # duty cycle
V=220 # in volts
Vch=1.5 #in volts
VL_dc=D*(V-Vch)
print "part (a)"
print "Average output voltage, VL_dc = %0.2f V " %VL_dc
print "part (b)"
VL_rms=sqrt(D)*(V-Vch)
print "RMS output voltage, VL_rms = %0.2f V " %VL_rms
print "part (c)"
Po=((v-vch)**2)*(d/r) #in watts
Pi=((d*v*(v-vch))/r) #in watts
cn=Po/Pi #chopper efficiency
print "chopper efficiency = %0.4f or %0.1f %%"%(cn,cn*100)
print "part (d)"
D=80/100 # duty cycle
R=20 #in ohm
Ri=R/D
print "Effective input resistance, Ri = %0.2f ohm" %Ri
#average output voltage and current
#given data :
vs=120 #in volts
vb=1 #in volts
d=0.33 #
rl=10 #in ohms
f=200 #in Hz
Vldc=d*vs #
Ildc=round(Vldc)/rl #in amperes
print "average/DC output voltage = %0.f V" %round(Vldc)
print "average load current = %0.f A" %Ildc
#Average armature current
#given data :
V=200 # in volts
D=50/100 # duty cycle
VL_dc=V*D
Eb=75 # in volts
Ra=1 # in ohm
Ia=(VL_dc-Eb)/Ra
print "Average armature current, Ia = %0.2f A " %Ia
from numpy import exp, array, linalg
#minimum instantaneous load current,peak instantaneous current and maximum peak to peak ripple
v=220 #volts
r=10 #in ohms
l=15.5 #in mH
f=5 #in kHz
Eb=20 #in volts
d=0.5 #
x=exp((-(1-d)*r)/(f*10**3*l*10**-3)) #
y=(1-x)*(Eb/r) #
y1=(1-x)*((v-Eb)/r) #
A=array([[0.94, -0.94*0.94],[0.94, -1] ])
B=array([-0.94*0.125, -1.25] )
X=linalg.solve(A,B) #
print "part (a)"
print "minimum instantaneous current = %0.2f A" %X[0]
print "part (b)"
print "peak instantaneous current = %0.2f A" % X[1]
print "part (c)"
PP=X[1]-X[0]
print "maximum peak to peak ripple in the load current = %0.3f A" %PP
from __future__ import division
#inductance
v=220 #in volts
r=0.2 #in ohms
ia=200 #in amperes
f=200 #in hz
di=0.05*ia #in amperes
e=0 #in volts
d=0.5 #
l=((1-d)*v*d*(1/f))/di #
print "inductance = %0.2f mH" %(l*10**3)
from math import log, pi, sin
#load current is continuous or not,Average output current ,
#maximum and minimum steady state output current and RMS values of first and second harmonics of the load current
#given data :
V=220 #in volts
La=5 # in mH
Eb=24 #in volts
Ra=1 # in ohm
T=2 #in m-sec
D=0.6/2
D_dash=(La/(T*Ra))*log(1-((Eb/V)*(1-exp((T*Ra)/La))))
print "part (c)"
print "As D =",D,"% is greater then D_dash =",round(D_dash,3),"% so load current is continous."
print "part (d)"
Io=((D*V)-Eb)/Ra
print "Average output current,Io(A) = ",Io
I_max=(V/Ra)*((1-exp(-(D*T*Ra)/La))/(1-exp(-(T*Ra)/La)))-(Eb/Ra)
print "Maximum steady state putput current, I_max = %0.2f A " %I_max
I_min=(V/Ra)*((1-exp((D*T*Ra)/La))/(1-exp((T*Ra)/La)))-(Eb/Ra)
print "Minimum steady state output current, I_min = %0.2f A" %round(I_min)
print "part (e)"
C1_rms=((2*V)/(pi*sqrt(2)))*sin(pi*D) # in volts
C2_rms=((2*V)/(2*pi*sqrt(2)))*sin(2*pi*D) # in volts
Z1=((Ra**2+(2*pi*La*10**-3*(1/(T*10**-3)))**2)**(1/2)) #
Z2=((Ra**2+(2*2*pi*La*10**-3*(1/(T*10**-3)))**2)**(1/2)) #
Ifl=C1_rms/Z1 #in amperes
Ifl1=C2_rms/Z2 #in amperes
print "fundamental component of load current = %0.2f A" %Ifl
print "second harmonic component of load current = %0.2f A" %Ifl1
#value of current limiting resistor ,maximum and minimum duty cycle
#given data :
v=325 #in volts
eb=120 #in volts
r=0.2 #in ohms
ra=0.3 #in ohms
e=120 #in volts
rb=0.2 #in ohms
rl=0.3 #in ohms
d=60 #in percentage
i=20 #in amperes
vo=(d/100)*v #
R=((i*rl)-(v-eb)+(i*rb))/(-i) #
print "part (a)"
print "value of current limiting resistor = %0.2f ohm" %R
#value of current limiting resistor is calculated wrong in the textbook
print "part (b)"
p=15 #
R=9.45 #
vmax=v+(v*(p/100)) #
vmin=v-(v*(p/100)) #
Dmax=((i*R)/vmin)*100 #
Dmin=((i*R)/vmax)*100 #
print "maximum duty cycle = %0.2f %%" %Dmax
print "minimum duty cycle = %0.2f %%" %Dmin
# pulse width and output voltage
#given data :
v=220 #in volts
vo=660 #in volts
toff=100 #in micro seconds
ton=((vo*toff)/v)-toff #in micro secondsT=ton+toff #in micro seconds
T=ton+toff
f=(1/T) #in Hz
Vo=((v)/(1-(f*(ton/2)))) #in volts
print "pulse width (ton) = %0.f micro seconds"%ton
print "new output voltage = %0.f V" %Vo
#chopping frequency and new output voltage
#given data :
v=200 #in volts
vo=600 #in volts
ton=200 #in micro seconds
x=-((v/vo)-1) #
f=x/(ton*10**-6) #
ton1=ton/2 #
Vo=((v)/(1-(f*ton1*10**-6))) #in volts
print "chopping frequency = %0.2f Hz"%f
print "new output voltage = %0.2f V"%Vo