import math
#initialisation of variables
# To calculate harmanic factor for stator
S=36.0 #no of slots
q=3.0 #no of phases
p=4.0 #no of poles
m=S/(q*p) #slots/pole/phase
g=180*p/S #gamma elec
#Calculations
def bfctr(n):
k=math.sin(math.radians(m*n*g/2))/(m*math.sin(math.radians(n*g/2)))
return k
K_b=bfctr(1)
print(K_b,'K_b(fundamental)')
K_b=bfctr(3.0)
#Results
print(K_b,'K_b(third harmonic)')
K_b=bfctr(5.0)
print(K_b,'K_b(fifth harmonic)')
import math
#initialisation of variables
# to find the frequency and phase and line voltages
n=375.0 #speed in rpm
p=16.0 #no of poles
f=n*p/120.0
print(f,'freq(Hz)')
S=144.0 #no of slots
c=10.0 #no of conductors/slot
#Calculations
t=S*c/2 #no of turns
ph=3
N_ph=t/ph #no of turns/ph
g=180*p/S #slots angle
m=S/(p*ph) #slots/pole/phase
K_b=math.sin(math.radians(m*g/2.0))/(m*math.sin(math.radians(g/2))) #breadth factor
phi=0.04 #flux per pole
E_p=4.44*K_b*f*N_ph*phi
#Results
print(E_p,'phase voltage(V)')
E_l=math.sqrt(3)*E_p
print(E_l,'line voltage(V)')
import math
#initialisation of variables
# to find the phase and line voltages
f=50 #freq
n=600 #speed in rpm
p=120*f/n
ph=3
m=4 #slots/pole/ph
S=p*ph*m #slots
t=12 #turns per coil
#Calculations
N_ph=S*t/ph
g=180*p/S
K_b=math.sin(math.radians(m*g/2.0))/(m*math.sin(math.radians(g/2))) #breadth factor
cp=10 #coil pitch
pp=S/cp #pole pitch
theta_sp=(pp-cp)*g #short pitch angle
K_p=math.cos(math.radians(theta_sp/2))
phi=.035
E_p=4.44*K_b*K_p*f*N_ph*phi
#Results
print(E_p,'phase voltage(V)')
E_l=math.sqrt(3)*E_p
print(E_l,'line voltage(V)')
import math
#initialisation of variables
# to calculate flux/pole
S=42
p=2
ph=3
m=S/(p*ph) #slots/pole/phase
g=180*p/S #slots angle
#Calculations
K_b=math.sin(math.radians(m*g/2.0))/(m*math.sin(math.radians(g/2))) #breadth factor
cp=17
pp=S/p
theta_sp=(pp-cp)*g #short pitch angle
K_p=math.cos(math.radians(theta_sp/2))
N_ph=S*2/(ph*p*2) #2 parallel paths
E_p=2300/math.sqrt(3)
phi=E_p/(4.44*K_b*K_p*f*N_ph)
#Results
print(phi,'flux/pole(Wb)')
import math
#initialisation of variables
# to calculate useful flux/pole and ares of pole shoe
p=1500*1000.0 #power
v=600.0
I_a=p/v
cu=25*1000 #copper losses
#Calculations
R_a=cu/I_a**2
E_a=v+I_a*R_a
n=200
Z=2500
p=16
A=16
phi=E_a*60*A/(p*n*Z)
print(phi,'flux/pole(Wb)')
fd=0.85 #flux density
a=phi/fd
#Results
print(a,'area of pole shoe(m*m)')
import math
#initialisation of variables
# To calculate em power developed,mech power fed, torque provided by primemover
phi=32*10**-3 #flux/pole
n=1600 #speed in rpm
Z=728 #no of conductors
p=4
A=4
#Calculations
E_a=phi*n*Z*(p/A)/60
I_a=100
P_e=E_a*I_a
print(P_e,'electromagnetic power(W)')
P_m=P_e
print(P_m,'mechanical power(W) fed')
w_m=2*math.pi*n/60
T=P_m/w_m
#Results
print(T,'primemover torque(Nm)')
import math
#initialisation of variables
# To determine peak value of fundamental mmf
f=50.0
n_s=300.0
p=120*f/n_s
P=400*1000.0 #power
V=3300.0
#Calculations
I_L=P/(math.sqrt(3)*V)
I_P=I_L
I_m=math.sqrt(2)*I_P #max value of phase current
S=180.0
g=180*p/S
ph=3
m=S/(p*ph) #slots/pole/phase
K_b=math.sin(math.radians(m*g/2.0))/(m*math.sin(math.radians(g/2))) #breadth factor
c=8 #conductors/1 coil side
N_ph=S*c/(ph*2) #turns/phase
F_m=(4/math.pi)*K_b*(N_ph/p)*I_m
F_peak=(3.0/2)*F_m
#Results
print(F_peak,'peak mmf(AT/pole)')
import math
#initialisation of variables
# (a)to calculate field current and flux/pole(b)to calculate open ckt ph and line voltages
# (c)to caculate field current
B_peak=1.65
g=.008
u_o=4*math.pi*10**-7
P=4
K_b=.957
N_field=364.0/2
#Calculations
I_f=B_peak*math.pi*g*P/((4*u_o)*(K_b*N_field))
print(I_f,'field current(A)')
l=1.02 #rotor length
r=.41/2 #rotor radius
phi=(4/P)*B_peak*l*r
print(phi,'flux/pole(Wb)')
N_ph=3*11*P/2
ga=60/3 #slot angle
m=3
f=50
K_b=math.sin(math.radians(m*g/2.0))/(m*math.sin(math.radians(g/2))) #breadth factor
E_ph=math.sqrt(2)*math.pi*K_b*f*N_ph*phi
print(E_ph,'E_ph(V)')
E_line=math.sqrt(3)*E_ph
#Results
print(E_line,'E_line(V)')
I_fnew=.75*I_f
print(I_fnew,'I_f(new)(A)')
import math
#initialisation of variables
# to find fundamental mmf wave,speed and its peak value
p=4.0
S=60.0
g=180*p/S
ph=3
m=S/(p*ph) #slots/pole/phase
#Calculations
K_b=math.sin(math.radians(m*g/2.0))/(m*math.sin(math.radians(g/2))) #breadth factor
I_L=48
I_P=I_L/math.sqrt(3)
I_Pmax=I_P*math.sqrt(2)
c=24 #conductors
N_ph=S*c/(ph*2) #turns/phase
F_m=(4/math.pi)*K_b*(N_ph/p)*I_Pmax
print(F_m,'F_m(AT/pole)')
F_peak=(3/2)*F_m
#Results
print(F_peak,'F_peak(AT/pole)')
n=120*f/P
print(n,'speed(rpm)')
import math
#initialisation of variables
# to calculate resultant air gap flux/pole
F1=400.0
F2=850.0
a=123.6
#Calculations
Fr=math.sqrt(F1**2+F2**2+2*F1*F2*math.cos(math.radians(a)))
P=1.408*10**-4 #permeance/pole
phi_r=P*Fr
#Results
print(phi_r,'air gap flux/pole(Wb)')
import math
#initialisation of variables
#To calculate resultant AT/pole and peak air gap flux density, rotor AT/pole, stator AT and its angle with the resultant AT, stator currrent
ph=3.0
S=36.0
c=8.0*2
p=4.0
f=50.0
N_ph=S*c/(ph*2) #turns/phase
ga=180.0*p/S
m=S/(p*ph) #slots/pole/phase
#Calculations
K_b=math.sin(math.radians(m*g/2.0))/(m*math.sin(math.radians(g/2))) #breadth factor
V_L=400
V_ph=V_L/math.sqrt(3)
phi_r=V_ph/(4.44*K_b*f*N_ph)
print(phi_r,'phi_r(Wb/pole)')
D=.16
l=0.12
PA=math.pi*l*D/4 #pole area
B_rav=phi_r/PA
B_rpeak=(math.pi/2)*B_rav
g=2*10**-3
u_o=4*math.pi*10**-7
F_r=g*B_rpeak/u_o
print(F_r,'F_r(AT/pole)')
T=60 #torque(Nm)
d=26
F2=T/((math.pi/2)*(p/2)**2*phi_r*math.sin(math.radians(d)))
print(F2,'F2(AT/pole)')
F1=math.sqrt(F2**2+F_r**2-2*F2*F_r*math.sin(math.radians(d)))
print(F1,'F1(AT/pole)')
w=math.degrees(math.acos((F1**2+F_r**2-F2**2)/(2*F1*F_r)))
print(w,'angle(deg)')
K_w=K_b
I_a=F1/((3/2)*(4*math.sqrt(2)/math.pi)*K_w*(N_ph/p))
#Results
print(I_a,'I_a(A)')
import math
#initialisation of variables
#to determine in F2,peak rotor AT, max torque, ele i/p at max torque(motoring mode),open ckt voltage(generating mode)
print('motoring mode')
K_w=.976
N_pole=746
p=4
I_f=20
#Calculations
F2=(4/math.pi)*K_w*(N_pole/p)*I_f
print(F2,'F2(AT)')
B_r=1.6
D=.29
l=.35
T_max=(p/2)*(math.pi*D*l/2)*F2*B_r
print(T_max,'T_max')
f=50
w_m=4*math.pi*f/p
P_in=T_max*w_m
print(P_in,'P_in(W)')
print('generating mode')
m=S/(3*p)
ga=180*p/S
K_b=math.sin(math.radians(30))/(3*math.sin(math.radians(15.0/2)))
K_w=K_b
u_o=4*math.pi*10**-7
phi_r=((2*D*l/p)*(u_o/g))*F2
N_ph=20*p*4/2
E_ph=4.44*K_b*f*N_ph*phi_r
E_l=math.sqrt(3)*E_ph
#Results
print(E_l,'E_l(V)')
import math
#initialisation of variables
# to find motor speed
n=1500.0 #speed of sync generator
p=4
f=n*p/120
#Calculations
p_im=6.0
n_s=120*f/p_im
s=0.05 #slip
n_im=(1-s)*n_s
#Results
print(n_im,'speed of induction motor(rpm)')
import math
#initialisation of variables
#to find voltage available b/w slip rings and its freq
print('(a)')
f=50.0
p=6.0
n_s=120*f/p
n=-1000
#Calculations
s=(n_s-n)/n_s
f_s=f*s
print(f_s,'slip freq(Hz)')
v2=100
V2=s*v2
print(V2,'slip ring voltage(V)')
print('(b)')
n=1500
s=(n_s-n)/n_s
f_s=abs(f*s)
print(f_s,'slip freq(Hz)')
v2=100
V2=s*v2
#Results
print(V2,'slip ring voltage(V)')
import math
#initialisation of variables
#to find no of poles, slip and freq of rotor currents at full load, motor speed at twice of full load
n_s=600.0
f=50.0
P=120*f/n_s
print(p,'no of poles')
n=576.0
#Calculations
s=(n_s-n)/n_s
print(s,'slip')
f2=s*f
n_r=s*n_s
print(n_r,'rotor speed wrt rotating field(rpm)')
ss=f2*s
n=(1-ss)*n_s
print(n,'motor speed(rpm)')
nn=528
s_old=s
s_new=(n_s-nn)/n_s
fac=s_new/s_old
#Results
print(fac,'factor is')
import math
#initialisation of variables
# to calculate amplitude of travelling wave mmf,peak value of air flux density, velocity of wave, current freq at some desired velocity
K_w=.925
N_ph=48
I=750.0/math.sqrt(2)
wndnglgth=2
wavelgth=wndnglgth/0.5
p=2*wavelgth
#Calculations
F_peak=(3.0/2)*(4*math.sqrt(2)/math.pi)*K_w*(N_ph/p)*I
print(F_peak,'F_peak(A/m)')
g=.01
u_o=4*math.pi*10**-7
B_peak=u_o*F_peak/g
print(B_peak,'B_peak(T)')
f=25
B=.5
v=f*B
print(v,'velocity(m/s)')
vv=72*10**3/3600 #given velocity
f=vv/0.5
#Results
print(f,'freq(Hz)')