from cmath import polar, sin
from __future__ import division
n=300/1
Z2=1.5+1J
I2=5
E2=I2*Z2
E1=E2/n
from math import atan, degrees, sin, cos
alpha=(atan(1/1.5))
Io=(100+40*1J)
delta=(atan(40/100) )
sigma=-(Io*sin(alpha+delta))*100/(n*I2)
print "Ratio error=%.2f percent"%abs(sigma)
bet=(Io*cos(alpha+delta))/(n*I2)
print "Phase angle=%.2f degree"%abs(bet)
I_ratio=500/5
n=1/100
I2=300/100
print "Secondary current=%.2f A"%(I2)
V2=I2*1.5
print "Secondary voltage=%.2f V"%(V2)
V_line=200*33000/220
print "Voltage on line=%.0f "%V_line
I_line=4*100/5
print "Current in line=%.0f A"%(I_line)
n=1000/5
Ie=0.7*1000/100
Tp=1
n=200
Ts=200
R_actual=Ts+(7/5)
Error_ratio=(200-R_actual)*100/R_actual
print "Ratio error=%.2f percent"%(Error_ratio)
Ts=200-(0.5*200/100)
n=199/1
R_actual=Ts+(7/5)
Error_ratio=(200-R_actual)*100/R_actual
print "Ratio error=%.2f percent"%(Error_ratio)
Vp=1000
Vs=100
n=Vp/Vs
pf_no_load=0.4
sina=0.4
cosa= (1-sina**2)**0.5
tana=sina/cosa
Im=0.02
Ie=Im*tana
xp=66.2
rp=94.5
#At no load Is=0 so
theta=((Ie*xp)-(Im*rp))/(n*Vs)
print "Phase angle error at no load=%.4f"%(theta)
E2=((1.8+5*0.16)**2+(2.4+5*0.195)**2)**0.5
pf2=2.6/E2
AT_sec=600
sina=3.375/E2
AT_pri=600+10.1*pf2+13.4*sina
I1=AT_pri/40
Ratio_error=(15-I1)*100/I1
print "Ratio error=%.2f percent"%(Ratio_error)