# a
import math
V1 = 440./math.sqrt(3.);
s = 0.025; # slip
r1 = 0.1;
r2 = 0.12;
x1 = 0.35;
x2 = 0.4;
z = complex(r1 + r2/s, x1 + x2);
i2 = V1/z; # input line current
I2 =51.2;# math.sqrt(real(i2)**2. + imag(i2)**2.); # magnitude of input line current
print '%s' %("a")
print "input line current = ",i2
i1 = complex(18.*math.cos(-1.484), 18.*math.sin(-1.484)); # magnetizing current
I1 = 18;#math.sqrt(real(i1)**2. + imag(i1)**2.); # magnitude of magnetizing current
i = i1 + i2; # total current drawn from the voltage source
I =58.2;# math.sqrt(real(i)**2. + imag(i)**2.); # magnitude of total current
theta =-0.457;# math.atan(imag(i)/real(i)); # phase difference between current and voltage
pf = math.cos(theta); # power factor
print '%s %.2f' %("power factor = ",pf)
if theta >= 0 :
print '%s' %("leading")
else :
print "lagging"
# b
f = 60.; # hertz
ns = 1800.;
ws = 2.*math.pi*ns/f; # stator angular velocity
Pg = 3.*I2**2.*r2/s; # power
T = Pg/ws; # developed electromagnetic torque
print '%s' %("b")
print '%s %.2f' %("developed electromagneic torque (in Newton-meter) = ",T)
# c
Prot = 950.; # rotational losses (in watts)
Po = Pg*(1. - s) - Prot ; # output power
HPo = Po/746.; # output horse power
print '%s' %("c")
print '%s %.2f' %("output horse power = ",HPo)
# d
Pc = 1200.; # core losses (in W)
SCL = 3.*I**2.*r1; # stator copper loss
RCL = 3.*I2**2.*r2; # rotar copper loss
loss = Pc + SCL + RCL + Prot; # total losses
Pi = 3.98*10.**4.;#real(3.*V1*i); # input power
efficiency = 1. - (loss/Pi);
print '%s %.2f' %("efficiency = ",efficiency)