import math
#initialisation of variables
# to compute the ratio of E_mf/E_mb,V_f/V_b,T_f/T_b,gross total torque,T_f/total torque, T_b/total torque
R_lm=3.0
X_lm=5.0
R_2=1.5
X_2=2.0
s=1-.97 #slip
#Calculations
a=complex(R_2/s,X_2)
b=complex(R_2/(2-s),X_2)
c=abs(a)/abs(b)
print(c,'E_mf/E_mb')
a=(1.0/2)*complex((R_lm+R_2/s),(X_lm+X_2))
b=(1.0/2)*complex((R_lm+R_2/(2-s)),(X_lm+X_2))
c=abs(a)/abs(b)
print(c,'V_f/V_b')
d=(2.0-s)/s
print(d,'T_f/T_b')
Z_tot=a+b
V=220.0
I_m=V/abs(Z_tot)
P=6.0
f=50.0
n_s=120.0*f/P
w_s=2*math.pi*n_s/60
T_f=(I_m**2*R_2/(2*w_s))*(1/s)
T_b=(I_m**2*R_2/(2*w_s))*(1/(2-s))
T_tot=T_f-T_b
print(T_tot,'gross total torque(Nm)')
a=T_f/T_tot
b=T_b/T_tot
#Results
print(a,'T_f/T_total')
print(b,'T_b/T_total')
import math
#initialisation of variables
# to calculate parameters of the ckt model, line current, power factor, shaft torque and efficiency
V_0=215.0
I_0=3.9
P_0=185.0
R_1=1.6
V_sc=85
I_sc=9.8
P_sc=390.0
X=(V_0/I_0)*2.0 #magnetisation reactance
phi_sc=math.degrees(math.acos(P_sc/(V_sc*I_sc)))
I_e=V_sc/complex(0,X)
I_SC=I_sc*complex(math.cos(math.radians(phi_sc*(-1))),math.sin(math.radians(phi_sc*(-1))))
I_m=I_SC-I_e
Z=V_sc/I_m
R_2=(Z.real)-R_1 #real(Z)=R=R1+R2
print(R_2,'R_2(ohm)')
print((Z.imag),'X_1+X_2(ohm)')
#Calculations
n=1500.0
nn=1440
s=(n-nn)/n
a=1.55/s
b=1.55/(2-s)
Z_ftot=(complex(0,X/2))*(complex(a+.8,(Z.imag)/2))/((complex(0,X/2))+(complex(a+.8,(Z.imag)/2)))
Z_btot=(complex(0,X/2))*(complex(b+.8,(Z.imag)/2))/((complex(0,X/2))+(complex(b+.8,(Z.imag)/2)))
Z_tot=Z_ftot+Z_btot
I_m=V_0/Z_tot
I_L=abs(I_m)
print(I_L,'line current(A)')
pf=math.cos(math.radians(math.degrees(math.atan((I_m.real)/(I_m.imag)))))
print(pf,'pf')
P_in=V_0*I_L*pf
I_mf=I_m*complex(0,X/2)/complex(39.55,59.12)
I_mb=I_m*complex(0,X/2)/complex(1.59,59.12)
T=(1/157.1)*(abs(I_mf)**2*38.75-abs(I_mb)**2*.79)
P_m=157.1*(1-s)*T
P_L=185
P_out=P_m-P_L
eff=P_out/P_in
#Results
print(eff*100,'efficiency(%)')
T_shaft=P_out/157.1
print(T_shaft,'shaft torque(Nm)')
import math
#initialisation of variables
#to compute ampitudes of forward and backward stator mmf waves,magnitude of auxillary currrent and its ph angle diff
N_m=80.0
N_a=100.0
I_m=15*complex(math.cos(math.radians(0)),math.sin(math.radians(0)))
I_aa=7.5*complex(math.cos(math.radians(45)),math.sin(math.radians(45)))
I_a=7.5*complex(math.cos(math.radians(60)),math.sin(math.radians(60)))
F_m=N_m*I_m
F_a=N_a*I_a
F_aa=N_a*I_aa #mmf at 45 angle
#Calculations
F_f=(1.0/2)*(F_m+1j*F_aa)
a=abs(F_f)
print(a,'forward field(AT)')
F_b=(1.0/2)*(F_m-1j*(F_aa))
b=abs(F_b)
print(b,'backward field(AT)')
#1200+100*I_a*complex(sind(a),cosd(a))=0
#equating real and imaginery parts
#100*I_a*cosd(a)=0
a=90
print(a,'phase angle diff')
I_a=-1200.0/(100*math.sin(math.radians(a)))
#Results
print(I_a,'auxillery current(A)')
import math
#initialisation of variables
#to determine value of capacitor
f=50.0
w=2*math.pi*f
Z_lm=complex(3,2.7)
Z_la=complex(7,3)
#Calculations
I_m=(-1)*math.degrees(math.atan((Z_lm.imag)/(Z_la.imag)))
a=90.0
I_a=a+I_m
c=1/(w*((Z_lm.real)-(Z_la.real)*math.cos(math.radians((-1)*I_a))))
#Results
print(c,'value of capacitor(F)')
import math
#initialisation of variables
#to calculate starting torque and atarting current,motor performance
V_a=110*complex(math.cos(math.radians(90)),math.sin(math.radians(90)))
V_m=220*complex(math.cos(math.radians(0)),math.sin(math.radians(0)))
R_1=3
R_2=2.6
X_1=2.7
X_2=2.7
X=110
V_f=(1.0/2)*(V_m-1j*V_a)
V_b=(1.0/2)*(V_m+1j*V_a)
#Calculations
Z_f=(complex(0,X)*complex(R_2,X_2))/(complex(0,X)+complex(R_2,X_2))
Z_b=Z_f
Z_ftot=complex(R_1,X_1)+Z_f
Z_btot=complex(R_1,X_1)+Z_b
I_f=V_f/Z_ftot
I_b=V_b/Z_btot
T_s=(2/157)*(Z_f.real)*(abs(I_f)**2-abs(I_b)**2)
print(T_s,'starting torque(Nm)')
I_m=I_f+I_b
I_a=1j*(I_f-I_b)
print(abs(I_a),'starting current(A)')
s=0.04
Z_f=(complex(0,X)*complex(R_2/s,X_2))/(complex(0,X)+complex(R_2/s,X_2))
Z_b=(complex(0,X)*complex(R_2/(2-s),X_2))/(complex(0,X)+complex(R_2/(2-s),X_2))
Z_ftot=complex(R_1,X_1)+Z_f
Z_btot=complex(R_1,X_1)+Z_b
I_f=V_f/Z_ftot
I_b=V_b/Z_btot
w_s=157.1
T_s=(2/157.1)*(abs(I_f)**2*(Z_f.real)-abs(I_b)**2*(Z_b.real))
print(T_s,'starting torque(Nm)')
I_m=I_f+I_b
m=math.degrees(math.atan((I_m.imag)/(I_m.real)))
I_a=1j*(I_f-I_b)
a=math.degrees(math.atan((I_a.imag)/(I_a.real)))
P_m=w_s*(1.0-s)*T_s
P_L=200.0
P_out=P_m-P_L
P_min=V*abs(I_m)*math.cos(math.radians(m))
P_ain=V*abs(I_a)*math.cos(math.radians(a))
P_in=P_min+P_ain
n=P_out/P_in
print(n,'efficiency')
r=Z_ftot/Z_btot #r=V_mf/V_bf
#V_mf+V_bf=220
V_mf=220/(1+r)
V_mb=220-V_mf
V_a=1j*(V_mf-V_mb)
#Results
print(abs(V_a),'V_a(V)')