from __future__ import division
from math import ceil
#Caption:Determines the turns per phase for the HV and LV winding of the 3 phase transformer.
F_max=0.024 #Maximum flux (in weber)
f=50 #Supply frequency(in Hz)
E_1p=11000 #Primary phase voltage(in Volts)
N_1=ceil(E_1p/(4.44*F_max*f)) #Turns per phase on primary
print 'turns per phase for the H.V. winding of the 3 phase transformer =',N_1
E_2l=400 #Secondary line voltage(in Volts)
E_2p=E_2l/(3)**(1/2) #Secondary phase voltage(in Volts)
N_2=ceil(E_2p/(4.44*F_max*f)) #turns per phase for the L.V. winding of the 3 phase transformer
print 'turns per phase for the L.V. winding of the 3 phase transformer =',N_2
# Answer wrong in the textbook.
#Caption:In a three phase transformer Calculate the secondary line voltage at no load
#when windings are star delta connected
V=3300 #the supply voltage(in Volts)
V_l1=V #Primary line voltage in star delta conection
N_1=420 #turns on the primary side of the transformer
N_2=36 #turns on the secondary side of the transformer
V_p1=V_l1/(3)**(1/2) #Primary phase voltage in star delta connection
V_p2=V_p1*(N_2/N_1) #Secondary phase voltage in star delta connection
V_l2=V_p2 #Secondary line voltage when windings are star delta connected(in Volts)
print 'Secondary line voltage when windings are star delta connected = %0.2f Volts '%V_l2
#when windings are delta star connected
V_P1=V #Primary phase voltage(in Volts)
V_L1=V_P1 #Primary line voltage in delta star connection
V_P2=V_P1*(N_2/N_1) #Secondary phase voltage in delta star connection
V_L2=V_P2*(3)**(1/2) #Secondary line voltage when windings are delta star connected(in Volts)=
print 'Secondary line voltage when windings are delta star connected = %0.2f Volts '%V_L2
#Caption:Find the secondary no load voltage and primary secondary currents in a 3 phase transformer
V_l=11000 #Input voltage(in Volts)
V_1ph=V_l/(3)**(1/2) #Phase voltage
KVA=50*10**(3) #
#KVA=((3)**(1/2))*V_l*I_l
I_1l=KVA/(((3)**(1/2))*V_l) #Line current
I_1ph=I_1l #Star system value of phase current
print 'Value of primary phase and line current = %0.2f Amp '%I_1ph
N_1=1000 #Primary turns
N_2=90 #Secondary turns
V_2ph=(N_2/N_1)*V_1ph #secondary phase voltage(in Volts)
#V_2ph=V_2l delta system
print 'Value of secondary phase and line voltage = %0.2f Volts '%V_2ph
I_2ph=(N_1/N_2)*I_1ph #secondary phase current(in Amp)
print 'Value of secondary phase current = %0.2f Amp '%I_2ph
I_2l=I_2ph*3**(1/2) #secondary line current(in Amp)
print 'Value of secondary line current = %0.2f Amp' %I_2l