from __future__ import division
from cmath import polar
from math import sin,cos,pi,sqrt
P_rot=900# #rotational losses
V_L=440*complex(cos(0),sin(0))#
R_s=1.2#
X_s=1J*2#
X_m=1J*50#
R_r_1=0.6#
R_r_2=19.4#
X_r=1J*0.8#
n_m=1746# #machine operating speed in rpm
W_m=n_m*2*pi/60# #speed in radians per second
n_s=1800# #synchronous speed for a four-pole monitor
s=(n_s-n_m)/n_s# #slip
Z_s=R_s+X_s+(X_m*(R_r_1+R_r_2+X_r))/(X_m+R_r_1+R_r_2+X_r)# #impedance seen by the source
Z_s_max=polar(Z_s)[0]
phi=polar(Z_s)[1]
Z_s_phi=(phi.real)# #removing negligible imaginary part(if any is there)
PF=cos(Z_s_phi)# #power factor
V_s=V_L# #phase voltage
I_s=V_s/Z_s# #phase current
I_s_max=polar(I_s)[0]
I_s_phi=polar(I_s)[1]
I_L=I_s_max*sqrt(3)# #line current
P_in=3*I_s*V_s*PF# #input power
V_x=I_s*(X_m*(R_r_1+R_r_2+X_r))/(X_m+R_r_1+R_r_2+X_r)#
I_r=V_x/(X_r+R_r_1+R_r_2)#
I_r_max=polar(I_s)[0]
I_r_phi=polar(I_r)[1]#
P_s=3*R_s*I_s_max**2# #copper loss in stator
P_r=3*R_r_1*I_r_max**2# #copper loss in rotor
P_dev=3*(1-s)*R_r_1*I_r_max**2/s# #developed power
#we may verify that P_in=P_dev+P_s+P_r to within rounding error
P_in=P_dev+P_s+P_r# #input power
P_o=P_dev-P_rot# #output power
T_o=P_o/W_m# #output torque
eff=P_o*100/P_in# #efficiency
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'Power factor : %0.2f'%PF
print 'line current = %0.2f amperes'%I_L
print 'output power = %0.2f watts'%P_o
print 'output torque = %0.2f Nm'%T_o
print 'efficiency percentage : %0.2f'%eff
from __future__ import division
from cmath import polar
from math import sin,cos,pi,sqrt
s=1# #slip for starting
V_L=440*complex(cos(0),sin(0))#
f=60#
R_s=1.2#
X_s=1J*2#
X_m=1J*50#
R_r_1=0.6#
R_r_2=19.4#
X_r=1J*0.8#
Z_eq=X_m*(R_r_1+X_r)/(X_m+R_r_1+X_r)# #equivalent impedance to the right in the figure in textbook
Z_s=R_s+X_s+Z_eq#
I_s=V_s/Z_s# #starting phase current
I_s_max=polar(I_s)[0]
phi=polar(I_s)[1]
I_L=sqrt(3)*I_s_max# #starting line current
#I_L here is almost six times larger than in previous example. It is a typical characteristic of induction motors.
P_ag=3*(Z_eq.real)*I_s_max**2# #power crossing air gap
W_s=2*pi*(60)#
T_dev=P_ag/(W_s/2)#
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'Starting line current = %0.2f A'%I_L
print 'Torque = %0.2f Nm'%T_dev
from __future__ import division
from math import pi,sqrt
V_L=220#
V_s=V_L/sqrt(3)# #phase voltage
I_s=31.87#
P_s=400# #total stator copper losses
P_r=150# #total rotoe copper losses
P_rot=500# #rotational losses
PF=0.75# #power factor
P_in=3*V_s*I_s*PF# #input power
P_ag=P_in-P_s# #air-gap power
P_dev=P_in-P_s-P_r# #developed power
P_o=P_dev-P_rot# #output power
eff=P_o*100/P_in# #efficiency
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'Power crossing the air gap = %0.2f watts'%P_ag
print 'developed power = %0.2f watts'%P_dev
print 'output power = %0.2f watts'%P_o
print 'effciency percentage : %0.2f'%eff #this value is given wrong in the textbook
from __future__ import division
from math import pi,sqrt,acos,sin,cos,atan,asin
P_dev_1=50*746# #developed power
V_L=480# #line voltage
PF=0.9# #power factor
f=60# #frequency
P=8# #number of poles
X_s=1.4# #synchronous reactance
#CASE a
n_s=120*f/P# #speed of machine in rpm
W_s=n_s*2*pi/60# #speed in radians per second
T_dev=P_dev_1/W_s# #developed torque
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'CASE a:'
print 'speed = %0.2f rpm'%n_s
print 'developed torque = %0.2f Nm'%T_dev
#CASE b
V_a=V_L# #phase voltage
I_a_max=P_dev_1/(3*V_a*PF)# #phase current
phi=acos(PF)#
I_a=I_a_max*complex(cos(phi),sin(phi))#
E_r=V_a-1J*X_s*I_a# #voltage induced by rotor
E_r_max=sqrt(((E_r.real)**2)+((E_r.imag)**2))#
E_r_phi=atan((E_r.imag)/(E_r.real))#
TA=-E_r_phi# #torque angle
print 'CASE b:'
print 'Phase current:'
print 'peak value = %0.2f amperes'%I_a_max
print 'phase angle = %0.2f degrees'%(phi*180/pi)
print 'Voltage induced by rotor:'
print 'peak value = %0.2f volts'%E_r_max
print 'phase angle = %0.2f degrees'%(E_r_phi*180/pi)
print 'torque angle = %0.2f degrees'%(TA*180/pi)
#CASE c
#excitation constant means the values of I_f, B_r and E_r are constant
P_dev_2=100*746#
sin_t=P_dev_2*sin(TA)/P_dev_1# #developed power is proportional to sin_t
t=asin(sin_t)#
E_r=E_r_max*complex(cos(-t),sin(-t))# #E_r is constant in magnitude
I_a=(V_a-E_r)/(1J*X_s)# #new phase current
I_a_max=sqrt(((I_a.real)**2)+((I_a.imag)**2))#
I_a_phi=atan((I_a.imag)/(I_a.real))#
PF=cos(I_a_phi)#
print 'CASE c:'
print 'Phase current:'
print 'peak value = %0.2f amperes'%I_a_max
print 'phase angle = %0.2f degrees'%(I_a_phi*180/pi)
print 'Voltage induced by rotor:'
print 'peak value = %0.2f volts'%E_r_max
print 'phase angle = %0.2f degrees'%(-t*180/pi)
print 'torque angle = %0.2f degrees'%(t*180/pi)
print 'power factor : %0.2f'%(PF)
from __future__ import division
from math import pi,sqrt,acos,sin,cos,atan,asin
from cmath import polar
V_a=480# #phase voltage
f=60# #frequency
P_dev=200*746# #developed power
PF=0.85# #power factor
I_f_1=10# #field current
X_s=1.4# #synchronous resistance
phi=acos(PF)#
I_a_1_max=P_dev/(3*V_a*PF)# #phase current
I_a_1_phi=-phi#
I_a_1=I_a_1_max*complex(cos(-phi),sin(-phi))#
E_r_1=V_a-1J*X_s*I_a_1# #rotor induced voltage
E_r_1_max=polar(E_r_1)[0]
E_r_1_phi=polar(E_r_1)[1]
#to achieve 100 percent power factor, increase I_a until it is in phase with V_a
I_a_2=P_dev/(3*V_a*cos(0))#
E_r_2=V_a-1J*X_s*I_a_2#
E_r_2_max=polar(E_r_2)[0]
E_r_2_phi=polar(E_r_2)[1]
I_f_2=I_f_1*E_r_2_max/E_r_1_max# #magnitude of E_r proportional to field current
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'The new field current to achieve 100%% power factor = %0.2f amperes'%I_f_2