import math
#given
vl=400 #line voltage
va=vl/math.sqrt(3)
vb=230.94 #angle(-120)
vc=230.94 #angle(-240)
#case a
#the line currents are given by
ia=12000/230.94 #with angle 0
ib=10000/230.94 #with angle 120
ic=8000/230.94 #with angle 240
print"ia=",round(ia,3),"A"
print "ib=",round(ib,5),"A"
print "ic=",round(ic,5),"A"
#case b
#IN=ia+ib+ic
#ia,ib and ic are phase currents hence contain with angles they are in the form sin(angle)+icos(angle)
#IN=51.96*(sin(0)+i*cos(0))+43.3*(sin(120)+i*cos(120))+34.64*(sin(240)+i*cos(240))
#IN=51.96+(-21.65+i*37.5)+34.64*(-0.5-i*0.866)
#12.99+i*7.5 on which the sin+icos=sin**2+cos**2 operation is performed
#therefore
IN=15 #at angle 30
print "IN=",round(IN,10),"A"
import math
#case a
vab=400 #phase angle of 0
vbc=400 #phase angle of 120
vca=400 #phase angle of 240
#the phase currents are given by iab,ibc,ica
iab=400/150 #from the diagram
print "iab=",round(iab,5),"A"
#ibc=(400*314*50)/10**6 numerator with an angle of -120 and denominator angle of -90 which amounts to -30 in numerator
#this leads to simplifying with the formula as the value obtained for ibc after simplification from above mutiplied by values of cos(-30)+jsin(-30)
#therefore print as below
print"ibc=5.4414-j3.1416","A"
#same method for ica
print "ica=3.1463+j4.2056","A"
#case b
#ia=iab-ica
#ia=2.667-(3.1463+j4.2056)
#leads to 4.2328 with an angle of -96.51
#angle calculated using tan formula
print "ia=4.2328 with an angle of -96.51","A"
#same for ib and ic
print "ib=4.1915 with angle of -48.55","A"
print "ic=7.6973 with an angle of 107.35","A"
import math
#case a
#given
zl=5 #load impedanc with an angle of 36.87 degrees
vl=400 #line voltage
il=46.19
va=400/3**0.5 #phase voltage
ia=va/zl #line current with an angle of -36.87 degrees
#ib and ic are also the same values with changes in in their angles
#case b
#cos(-36.87)=0.8 lagging
print "power factor =0.8"
#case c
p=3**0.5*vl*il*0.8 #power where 0.8 is power factor
print"p=",round(p,2),"KW"
#case d
q=3**0.5*vl*il*0.6 #where 0.6 is sin(36.87) and q is reactive volt ampere
print"q=",round(q,2),"Kvar"
#case e
t=3**0.5*vl*il #total volt ampere
print "t=",round(t,0),"KVA"
import math
#given
za=50
zb=15 #j15
zc=-15 #-j15
vl=440
vab=440 #with an angle of 0
vbc=440 #with an angle of -120
vca=440 #with an angle of -240
#applying kvl to meshes as in the diagram we get the following equations
#50i1+j15(i1-i2)-440(angle 0)=0,j15(i2-i1)+(-j15)i2-440(angle 120)=0
#solving the above 2 eqns we get the values of ia,ib and ic as follows
print "ia=29.33A" #at angle -30
print "ib=73.83A" #at angle -131.45
print "ic=73.82A" #at angle 71.5
#the voltage drops across vr,vl and vc which are voltages across resistance ,inducctance and capacitance are given as follows
print "vr=1466.5V" #at angle -30
print "vl=73.83V" #at angle -41.45
print "vc=73.83V" #at angle -18.5
#the potential of neutral point
print "vn=1212.45V" #at angle 150
import math
#given
v=440 #voltage
o=25000 #output power
e=0.9 #efficiency
p=0.85 #poer factor
#case a
il=o/(3**0.5*v*p*e) #line current
print "il=",round(il,5),"A"
#case b
ip=o/(3*v*e*p) #phase current for delta current winding
print "ip=",round(ip,5),"A"
import math
#given
#25kW at power factor 1 for branch AB
#40KVA at power factor 0.85 for branch BC
#30KVA at power factor 0.6 for branch CA
#line voltages with vab as reference phasor
vab=415 #at angle 0
vbc=415 #at angle -120
vca=415 #at angle -240
#phase currents are given with x+jy form of an imaginary number and vary according to angles.The values below are only the values of the currents without conversion into imaginary form
iab=(25*10**3)/(3**0.5*415*1)
print "iab=",round(iab,3),"A"
ibc=(40*10**3)/(3**0.5*415)
print "ibc=",round(ibc,3),"A"
ica=(30*10**3)/(3**0.5*415)
print "ica=",round(ica,3),"A"
#the line currents are as below.The following values can also be converted to x+iy form where x is real and y is imaginary
#ia=iab-ibc and subtraction is done of x+iy forms where the value of the term varies as obtained by sqrt(x**2+y**2)
print "ia=76.38A" #at angle -3.75
#ib=ibc-iab
print "ib=87.85A"
#ic=ica-ibc
print "ic=32.21A"
#wattmeter readings on phase A
#w1=vab*ia*cos(-3.35) where the cos angle is given by phase angle between ia and vab
print "w1=31.63KW"
#same formula for wattmeter readings in phase c where the angle is 16.35
print "w2=12.827KW"
import math
#given
w1=500
w2=200
w=w1+w2
#case a
print "the total input power=",round(w,0),"KW"
#case b
#tan(angle)=3**0.5*(w1-w2)/(w1+w2) where the angle=36.58 and cos(36.58)=0.803 which is the power factor
print "power factor=0.803"
#case c
#given
vl=2200
il=w/(3**0.5*vl*0.803) #0.803 is the value of the cos angle and il is the line current
print "il=",round(il,5),"A"
#case d
#efficiency=o/i #i is input and o is output
hp=746 #horse power
o=0.9*w/hp #0.9 is efficiency
print "output=",round(o,3),"hp"