from __future__ import division
from sympy import symbols, solve
#To Determine Motor Parameters of Series Motor rated at 220V
V=220 #Rated Voltage
N=1000 #Rated Speed
Ish=20 #Current without Armature being shunted
Ra=0.15 #Armature Resistance
Rf=0.2 #Field Resistance
Eb=V-(Ish*(Ra+Rf)) #Back EMF
K=Eb/(Ish*N) #Motor Constant
Rsh=20 #Shunt Resistance
#After Armature is shunted
x=symbols('x') #Field Current Variable Value
Ia=(Ish**2)/x #Armature Current #Since Torque is assumed constant
I20=(V-(x*Rf))/Rsh #Current Through the Shunt resistance
X=Ia+I20-x #Polynomial to find field Current
x=solve(X, x) #Numerical Value of Field Current
#Conditon to find the Positive Root
if abs(x[0]+x[1])==0:
x=x[1]
else:
x=x[0]
Ia=(Ish**2)/x #Armature when shunted
Ebsh=V-(Ia*Ra)-(x*Rf) #Back Emf when shunted
Nsh=Ebsh/(K*x) #Speed when armature is shunted
#When Load is not there, Ia = 0
If=V/(Rsh+Rf) #Field Current at No Load
Ebnl=V-(If*Rf) #Back Emf at No Load
Nnl=Ebnl/(K*If) #Speed at No Load
Rex=5 #External Resistance
#At Starting when Eb = 0
Is=V/(Rex+Rf+(Ra*Rsh/(Ra+Rsh))) #Supply Current
Ifs=Is #Field Current
Ias=Ifs*Rsh/(Rsh+Ra) #Armature Current At the Start
#Torque is directly proportional to square of Current
T20 = (Ish**2) #Torque at shunted condition
Tas= Ias*Ifs #Torque at start
RT=Tas/T20 #Ratio of Torques
print 'a) The Speed of Motor if the Load Torque remains constant & magnetic circuit is assumed unsaturated is %g RPM'%abs(Nsh )
print 'b) The No Load Speed of the Motor is %0.f RPM'%Nnl
print 'c) The Starting Torque represented in terms of torque corresponding 20A (without armature shunted) is %0.1f times'%RT
# Answer is not accurate for part 1 in the book.
#To Determine the resistance to be inserted for various cases
N1=1500 #Rated Speed
N2=1200 #Reduced Speed
rs=N2/N1 #Ratio of final speed to original speed
eff=80/100 #Efficiency
Pr=10*(10**3) #Power Rating
V=250 #Voltage supply
Il=Pr/(V*eff) #Full Load Current
Rf=110 #Field Resistance
Ra=0.25 #Armature Resistance
If=V/Rf #Field Current
Ia1=Il-If #Load Current
Eb=V-(Ia1*Ra) #Back EMF
Eb1200=Eb*rs #Back EMF for 1200 rpm
Res =lambda y:((V-Eb1200)/y) #Function to calculate the Resistance of various cases
#Torque directly proportional to current
Ia2=(rs)*Ia1 # Torque directly propostional to speed
Ia3=(rs**2)*Ia1 #Torque directly proportional to square of the speed
#Resistances for Various Cases
R1=Res(Ia1)-Ra
R2=Res(Ia2)-Ra
R3=Res(Ia3)-Ra
Pow = lambda y:((V-Eb1200)/y)*(y**2)/1000 #Function to Find Power Loss
#Power Lost in kW for various cases
P1=Pow(Ia1)
P2=Pow(Ia2)
P3=Pow(Ia3)
print 'The External Resistances to be connected and the power loss for '
print 'a) The Load Torque is independent of the speed : %0.f ohm and %0.2f kW respectively '%(R1,P1)
print 'b) The Load Torque is directly proportional to the speed : %0.2f ohm and %0.3f kW respectively '%(R2,P2)
print 'c) The Load Torque is directly proportional to square of the speed : %0.2f ohm and %0.3f kW respectively '%(R3,P3)
from sympy import symbols, diff, solve
from fractions import Fraction
#To determine the speed for which the torque is maximum
#In The Figure, The author has taken the resistance in series with the motor as 0.2 ohm, but in the figure it is given as 1 ohm
#This Doesn't Affect the calculation of the speed but it does affect the Maximum Torque
#So if we consider 1 ohm we get 0.8333 instead of 2.5
#The Equation for the Torque is found out to be 2.5*K2*(V**2)*(1.1-K1*w)/((76.1-(50*K1*w)))
w=symbols('w') #Variable Value of w
#Lets assume the value of 2.5*K2*(V**2) = 1 and K1 = 1 to particularly to calculate the co-effcients
T=2.5*(1.1-w)/((76.1-(50*w))**2) #Torque
#Maximum Torque is derivative of the above equation
X=diff(T, w) #Polynomial to find the value co - effcient of w
w=solve(X, w)
w=w[0] #We Choose value less than 1 to suit the differenciation process
Tmax=2.5*(1.1-w)/((76.1-(50*w))**2) #Maximum Torque Co-Efficient
print 'The Speed at which the torque is Maximum is (%g/K1) rad/sec'%w
print 'The Maximum Torque is (K2*(V**2)*%g*10**-4) Nm '%(Tmax/(10**-4))
from sympy import symbols, solve
#To Determine the slip at maximum torque and at full load
from math import floor
from __future__ import division
Tl=1 #Assume that the Full Load torque is unity
Tst=125*Tl/100 #Starting Torque
Tmax=275*Tl/100 #Maximum Torque
si=1 #At the Start
RT=Tst/Tmax #Ratio of Starting Torque and Maximum Torque
#R1 is negligible, elminating the terms with R1 and hence formulating the starting torque and Maximum Torque we get
# Tst/Tmax = 2*sTmax*s/((sTmax**2)+(s**2))
#Where sTmax is the Slip at Maximum Torque and s is the slip at the start
sTmx=symbols('sTmx') #Variable Value of slip at Maximum Torque
X=RT-(2*sTmx*si/((sTmx**2)+(si**2))) #Polynomial to find sTmax
sTmx = solve(X, sTmx)
#Condition to find the value of sTmax less than 1
if floor(sTmx[0])==0:
sTmx=sTmx[0]
else:
sTmx=sTmx[1]
s=symbols('s') #Variable value of slip for Starting torque at full load
Y=(Tl/Tmax)-(2*sTmx*s/((sTmx**2)+(s**2))) #Polynomial to find s
s=solve(Y, s) #Numerical Value of s
#Condition to find the value of s less than 1
if floor(s[0])==0 :
s=s[0]
else:
s=s[1]
print 'i) The Slip at Maximum Torque is %0.2f'%(sTmx)
print 'ii) The Slip at Full Load is %0.3f'%(s)
#To Determine the Maximum Torque as ratio of nominal value of voltage
from math import sqrt
#Resistances and Reactance for Nomrmal Value of Volttage and Frequency
w=50 #Frequency of supply
V=1 #Assumed Voltage
R1=0.05
R2=0.05
x1=0.3
x2=0.3
#Resistance and reactance at half voltage and half frequency
wh=50/2 #Frequency of supply
Vh=1/2 #Assumed Voltage
R1h=0.05
R2h=0.05
x1h=0.3/2
x2h=0.3/2
#Function to Determine the Maximum Torque
Max = lambda a,b,c,d,e:(3*(a**2))/(2*b*(c+(sqrt((c**2)+((d+e)**2)))))
#Function to Determine to the Starting Torque
Start =lambda a,b,c,d,e,f:(3*(a**2)*f)/(b*(((c+f)**2)+((d+e)**2)))
#Maximum Torques and Starting Torques at
#Normal Voltage And Frequency
Tm=Max(V,w,R1,x1,x2)
Tst=Start(V,w,R1,x1,x2,R2)
#Half Voltage and Half Frequency
Tmh=Max(Vh,wh,R1h,x1h,x2h)
Tsth=Start(Vh,wh,R1h,x1h,x2h,R2h)
#Ratio of torques as fraction of its normal value
R1=Tmh/Tm
R2=Tsth/Tst
print 'i)The Maximum Torque at the reduced value of supply as a fraction of its normal value is %0.4f'%R1
print 'ii)The Starting Torque at the reduced value of supply as a fraction of its normal value is %0.2f'%R2
#To Determine the starting torque and starting current for various starters
from math import pi
V=400 #Rated Voltage #Phase Voltage #Delta Connected
Pr=50*735.5 #Rated Power
N=750 #Rated Speed
s=4.5/100 #Full load Slip
Il=50 #Full Load Current
Z=2.5 #Impedance per phase
w=2*pi*N/60 #Angular Frequency
Tl=Pr/w #Full Load Torque
Ist=V/Z #Starting Current
Isl=sqrt(3)*Ist #Line Current
#DOL Starter
Tstd=((Isl/Il)**2)*s*Tl #Starting Torque
#Star - Delta Starter
Tsts=Tl*((1/sqrt(3))**2) #Starting Torque
#Autotransformer
tap=70/100 #Tapping
Tsta=(tap**2)*Tl #Starting Torque
print 'The Starting Current for all the three starter are the same that is %0.2f A'%Isl
print 'The Starting torque for: '
print 'i) D.O.L Starter : %0.2f Nm '%(Tstd)
print 'ii) Star -Delta Starter : %0.2f Nm '%(Tsts)
print 'ii) Auto Transformer with 70 percent tapping : %0.2f Nm '%(Tsta)
#To Detemine Minimum Starting Current drawn from the supply
from math import exp, pi, acos, degrees, sin
from sympy import symbols, solve
TR=0.5 #Torque Ratio, Tst:Tl
V=400 #Supply Voltage
Pr=30*735 #Power Rating
N=500 #Rated Speed
eff=0.85 #Efficieny
pf=0.88 #Power Factor
Is=150 #Short Circuit Current
s=5/100 #Full load Slip
pfs=0.25 #Power Factor of the Short Cicuit Current
Il=Pr/(sqrt(3)*V*eff*pf) #Full Load Current
#Case 1
x=symbols('x') #Tapping Percent
X=TR-(((Is/Il)**2)*(x**2)*s) #Polynomial to determine the 'x'
x=solve(X, x)
x=x[0] #Taking the Postive Root
Ist1=Is*x*x #Starting Current numerical Value
#Case 2
Ist2=sqrt((TR*(Il**2)/s)) #Starting Current for Full Voltage
Z1=V/(sqrt(3)*Ist2) #impedance for the starting current at full voltage
Z2=complex((V/(sqrt(3)*Is))*pfs,(V/(sqrt(3)*Is))*sin(acos(pfs))) #Phasor form of the Impedance of for the short cicuit current
R=sqrt((Z1**2)-(Z2.imag**2))
Rs=R-Z2.real #Resistance to be connected the stator circuit
print 'i) The Tapping of the Transformer is %0.1f percent and the starting Current is %0.2f A\n'%(abs(x*100),Ist1)
print 'ii) The Starting Current is %0.2f A and the Resistance to be added to the stator circuit is %0.4f ohm\n'%(Ist2,Rs)
# Answer in the textbook is not accurate.
#To Determine the value of resistor connected in series to run the fan at a particular speed
Pf=100*(10**3) #Power rating of the fan
f=50 #Supply Frequency
V=400 #Supply Line Voltage
V1=V/sqrt(3) #Phase Voltage
SR=1.4 #Ratio of stator to rotor turns
Rr=0.03 #Rotor Resistance per phase
R2=SR*SR*Rr #Rotor Resistance referred to the stator
N=240 #Rated Speed
w=2*pi*N/60 #Angular Frequency
P=24 #number of poles
Ns=120*f/P #Synchronous Speed
ws=2*pi*Ns/60 #Synchronous angular Frequency
s=(Ns-N)/Ns #Slip
T=Pf/w #Full Load Torque
X2=symbols('X2') #Reactance of Rotor referred to stator, Variable Value
X=T-(3*(V1**2)*R2/(ws*s*(((R2/s)**2)+(X2**2)))) #Polynomial Expression to find X2
X2=solve(X, X2) #Numerical Value of Rotor Resistance
X2=X2[0]
N1=180 #Speed of the fan
s1=(Ns-N1)/Ns #Slip
T1=T*((N1/N)**2) #Torque
R21=symbols('R21') #Variable Value
Y=T1-(3*(V1**2)*R21/(ws*s1*(((R21/s1)**2)+(X2**2)))) #Polynomial Expression to find R21
R21=solve(Y, R21) #Numerical Value
#R21 = 0.7545054 and 0.0100813
#We have to choose the value of R21 such that it is greater than R2
R21=R21[1]
Rex=(R21-R2)/(SR*SR) #External Resistance
print 'The Value of Resistance to be connected in series so that teh fan runs at 180 rpm is %0.3f ohm'%Rex
from math import pi, sqrt
#To Determine the time taken to start the motor
from sympy.mpmath import quad
HP=746 #According to the TextBook
P=150*HP #Power Rating
Lim=1.5 #Limited Current Factor
Eshp=5000 #energy stored per hp
N=750 #Rated Speed
w=N*2*pi/60 #Angular Frequency
Es=Eshp*P/HP #Total Energy Stored
Tfl=P/w #Full Load Torque
Ts=Tfl*Lim #Starting Torque
Ta=Ts-Tfl #Torque Available for acceleration
I=2*Es/(w**2) #Moment of Inertia
a=Ta/I #Angular Accleration
#Intergrating wrt angular frequency
f = lambda x : 1/a # function for integration
t=quad(f,[0,w]) #Time Taken to start #Angular Acceleration is constant
print '''The time taken to start the motor if the load torque is equal to full load torque,
during the starting period,
& the current is limited to 1.5 times the full load current is %0.2f seconds '''%(t)
from __future__ import division
#To time taken and the number of revolutions made before the motor is stopped
from sympy.mpmath import quad
P=50*735.5 #Power Rating
V=400 #Rated Voltage
N=750 #Rated Speed
w=N*pi*2/60 #Angular Frequency
I=20 #Moment Inertia
pf=0.95 #Full Load power factor
eff=90/100 #Overall Efficiency
Rb=2 #Braking Resistor
Tm=P/w #Full Load Torque
Ifl=P/(sqrt(3)*V*eff*pf) #Full Load Current
Ilb=V/(sqrt(3)*Rb) #The Line Current at the start of braking
Te=Tm*Ilb/Ifl #Torque for electric braking
Tb=Te+Tm #Total Braking torque
K=Te/w #Motor constant
B=Tb/I #Retardation
f1 = lambda x:(I/(Tm+(K*x))) # function for integration
ts=quad(f1,[0,w]) #Time Taken for the motor to stop
f2 = lambda t:(((Tm+(K*w))*exp(-1*K*t/I))-Tm) # function for integration
NoR=(1/(2*pi*K))*quad(f2,[0,ts]) #Number of Revolutions
#Note The answer in the textbook is wrong, Calculation error
print 'The Time Taken for the Motor to stop is %0.2f seconds\n'%ts
print 'The Number of revolutions undergone before it stops is %0.2f revolutions which is approx %g revolutions\n'%(NoR,round(NoR))
#To Determine the 30 mins rating of motor
from math import exp
Pr=100 #Power Rating in horse power
Tc=90*3600 #Time Constant
Tr=30*3600 #Time to determine the rating
theta=50 #Temperature Rise
theta1=50 #Temperature rise for the new case
P=symbols('P') #Power rating for 30min variable value
#Loss Corresponding to 30 mins
P30=(P/Pr)**2 # Times the Power loss corresponding to the 100 hp motor
theta2=theta*P30 #Final Temperature rise if run continuously
X=theta1-(theta2*(1-exp(-1*Tr/Tc))) #Polynominal to find the 30min rating
P=solve(X, P) #Numerical Value
#We Consider the Positive Real Value of the root
P=P[0] #Power Rating of the 1/2 Hr
print 'The 1/2 Hr Power Rating is %0.1f hp'%abs(P )
#To Determine the Continous Rating of the Motor for Suitable Conditions
from sympy.mpmath import quad
T=120 #Total Time
t1=0 #Power Rise to 1050
t2=15 #Constant Power of 600
t3=85 #Regenerative Breaking at 200
t4=95 #Motor At Rest
t5=120 #End
#Note Power Rating are in Horse Power
HP1=1050 #First Rise
T1=(t2-t1) #Time for Rise of the Horse Power
HP2=600 #Constant Power
T2=(t3-t2) #Time For which the power is constant
HP3=200 #Braking Initial Point
T3=(t4-t3) #Time Period of Breaking
#Different Intergration
f1 = lambda t:((HP1/T1)*t)**2 # function for integration
I1=quad(f1,[t1,t2])
f2 = lambda t:(HP2**2) # function for integration
I2=quad(f2,[t2,t3])
f3 = lambda t:((HP3/T3)*t)**2 # function for integration
I3=quad(f3,[0,T3])
HPrms=sqrt((I1+I2+I3)/120)
HPav=(((HP1*T1/2)+(HP2*T2)+(HP3*T3/2))/T)
print 'i) The H.P Rating according to the RMS Value of loading is %g hp\n'%HPrms
print 'ii) The H.P Rating according to the Average Value of Loading is %0.f hp\n'%HPav
#To estimate the final temperature of the machine and its time constant
Eff=90/100 #Efficiency
P=15*735.5 #Power Rating in W
D=75*(10**-2) #Cylinder Diameter
L=120*(10**-2) #Length of the Cylinder
OSHD=12 #Outer Surface Heat Dissipation
A=pi*L*D #Curved Surface Area
M=450 #Motor Weight
SH=700 #Specific Heat
HTC=M*SH/(A*OSHD*3600) #The Heating Time Constant
Loss=(P/Eff)-P #Loss in Motor
print 'Loss in Motor = %0.1f W'%Loss
FT=Loss/(A*OSHD) #Final Temperature
OSHD2=20 #Semi Closed Cooling Capacity
LossSC=FT*A*OSHD2 #Loss in Semi Closed System
print 'Final Temperature = %0.2f degree C'%FT
L2=symbols('L2') #Variable Load Value
X=(L2/(L2+LossSC)-Eff) #Polynomial to Calculate L2
L2=solve(X, L2) #Numerical Value of The Load
print 'The Final Temperature of the Machine & its Heating Time Constant is %0.2f degree Celsius and %0.2f Hrs respectively'%(FT,HTC)
print 'The Load which could be delivered is %0.f W '%(L2[0])
Rating = L2[0]/736 # hp
print 'Rating = %0.f h.p.'%Rating
#To Determine the Moment of intertia for a slip of 8 percent
from math import log
Tl=900 #load Torque
To=0
s=8/100 #Slip
t=15 #time period for which the load torque was applied
Tm=675 # Limited motor Torque
N=600 #No Load Speed
Wo=2*pi*N/60 #Angular Frequency
K=s/Tm #Motor Constant
I=(t/(Wo*K*log((Tl-To)/(Tl-Tm)))) #Moment of Inertia
print 'The Moment of inertia of the flywheel is %g Kg m**2'%I
#Please Note the Calculation Mistake in the book. (Power of e)
#To determine the Moment of intertia of the flywheel
Pi=100*(10**3) #Power Rating
P=6 #Poles of the Machine
N=950 #Rated Speed
Wo=2*pi*N/60 #Angular Frequency
Ta=3000 #Additional Torque
Tmin=600 #Constant Load Torque
Tm=Pi*60/(2*pi*N) #Rated Torque
Tmax=2*Tm #Maximum Torque
Tl=Tmin+Ta #Total Torque
tp=15 #Time for which the additional torque is applied
#Assuming Slip Characteristic to Be a Straight line
s=0.05
K=s/Tm #Motor Load Constant
I=tp/(Wo*K*log((Tl-Tmin)/(Tl-Tmax))) #Moment Of intertia
Tm1=1500 #Trasistion Torque
t=I*Wo*K*log((Tmax-Tmin)/(Tm1-Tmin)) #Time Taken to become 1500 Nm
print 'a) The Moment of intertia of the flywheel for Maximum Torque to be twice the rated torque is %0.1f Nm'%I
print 'b) The Time Taken after the removal of additional load before the motor torque becomes 1500 Nm is %0.2f seconds '%t
#To determine the speed and torque of a single phase full converter
from math import cos
P=5*735.5 #Power Rating
Vr=220 #Rated Voltage
N=1500 #Rated Speed
Ra=0.25 #Armature Resistance
Ia=20 #Rated Armature Current
Vs=250 #Supply Voltage
Kaphi=0.0278 #Motor Voltage Constant
a=30 #Firing Angle
Va=2*sqrt(2)*Vs*cos(a*pi/180)/pi #Armature Voltage
Eb=Va-(Ia*Ra) #Back EMF
w=Eb/(Kaphi*60) #Angular Frequency in Radians per second
Ta=Kaphi*Ia*60 #Torque
print 'The Speed and Torque of the Single Phase Full Converter are %0.1f rad/s and %g Nm respectively '%(w,Ta)
#To Determine the motor current and torque for a particular firing angle
P=15*735.5 #Power Rating of the Motor
Raw=0.2 #Combined Armature and Field winding resistance
N=1000 #Speed
K=0.03 #Motor Constant
a=30 #Firing Angle
E=250 #Supply Voltage
#Semi Converter
w=2*pi*N/60 #Angular Frequency
Vas=sqrt(2)*E*(1+cos(a*pi/180))/pi
Ias=Vas/(Raw+(K*w)) #Armature Current
Tas=K*(Ias**2) #Motor Torque
#FullConverter
Vaf=2*sqrt(2)*E*cos(a*pi/180)/pi
Iaf=Vaf/(Raw+(K*w)) #Armature Current
Taf=K*(Iaf**2) #Motor Torque
#Accurate Caclculation, Rounding Off not done.
print 'The Motor Current And Motor Torque for:'
print 'i) Semi Converter : %0.2f A and %0.2f Nm'%(Ias,Tas)
print 'ii) Full Converter : %0.2f A and %0.2f Nm'%(Iaf,Taf)
#To determine the pulse width for a particular average value of back EMF
E=220 #DC Supply
Raw=0.2 #Combined Armature and Field Winding Resistance
Ia=25 #Average Current
f=200 #Chopper Frequency
Eb=100 #Average Value of Back EMF
Eav=(Ia*Raw)+Eb #Average Load Voltage
Ton=Eav*1000/(E*f) # Pulse Width in m sec
print 'The Pulse Width for the 100V back EMF is %0.2f m seconds'%Ton
#To determine the range of speed control and duty cycle
E=220 #DC supply voltage
Ra=0.2
Kaphi=0.08 # Motor Constant
Ia=25 #Average Current
Eav=Ia*Ra #Voltage Drop
#Eav = lamda * E
#For Maximum Speed, lamba =1
lamda=Eav/E
lamda1=1 #Maximum Speed
Eb= (E*lamda1)-(Ia*Ra) #Back EMF
Speed = Eb/Kaphi # Maximum Speed
print 'i) The Range of speed control is 0<N<%0.f '%(Speed)
print 'ii) The Range of duty cycle is %g<lamda<%g'%(lamda,lamda1)