import math
from scipy.linalg import polar
# Given
#The system ABC is DELTA connected")
#Effective line voltage is 120V")
#The three impedances are 5(45 deg)")
Zmag = 5;Zph = 45;
#Let maximum line voltage is Vmax
Vmax = 120*math.sqrt(2)
#From fig 12.7(a)
#VAB = Vmax(120 deg)
#VBC = Vmax(0 deg)
#VCA = Vmax(240 deg)
#From figure 12.8
IABmag = Vmax/Zmag
IABph = 120-Zph
print "IAB = %3.2f%d deg)"%(IABmag,IABph);
IBCmag = Vmax/Zmag
IBCph = 0-Zph
print "IBC = %3.2f%d deg)"%(IBCmag,IBCph);
ICAmag = Vmax/Zmag
ICAph = 240-Zph
print "ICA = %3.2f%d deg)"%(ICAmag,ICAph);
#Applying KCL equation
#IA = IAB+IAC
#IB = IBC+IBA
#IC = ICA+ICB
x = IABmag*math.cos((IABph*math.pi)/180);
y = IABmag*math.sin((IABph*math.pi)/180);
z = complex(x,y)
x1 = ICAmag*math.cos((ICAph*math.pi)/180);
y1 = ICAmag*math.sin((ICAph*math.pi)/180);
z1 = complex(x1,y1)
x2 = IBCmag*math.cos((IBCph*math.pi)/180);
y2 = IBCmag*math.sin((IBCph*math.pi)/180);
z2 = complex(x2,y2)
IA = z-z1;
RA,ThetaA = polar([[IA]])
RA = RA[0][0].real
ThetaA = ThetaA[0][0].real
IB = z2-z;
RB,ThetaB = polar([[IB]])
RB = RB[0][0].real
ThetaB = ThetaB[0][0].real
IC = z1-z2
RC,ThetaC = polar([[IC]])
RC = RC[0][0].real
ThetaC = ThetaC[0][0].real
#Therefore")
print "IA = %3.2f%d deg)A"%(RA,(ThetaA*180/math.pi));
print "IB = %3.2f%d deg)A"%(RB,(ThetaB*180/math.pi));
print "IC = %3.2f%d deg)A"%(RC,(ThetaC*180/math.pi));
import math
from scipy.linalg import polar
#Example 12.5")
# Given
#The system ABC is DELTA connected")
#Maximum line voltage is 339.4V")
#The three impedances are 10(0 deg),10(30 deg),15(-30 deg)")
ZABmag = 10;ZABph = 0;
ZBCmag = 10;ZBCph = 30;
ZCAmag = 15;ZCAph = -30;
#Let maximum line voltage is Vmax
Vmax = 339.4
#From fig 12.7(a)
#VAB = Vmax(120 deg)
#VBC = Vmax(0 deg)
#VCA = Vmax(240 deg)
#From figure 12.15
IABmag = Vmax/ZABmag
IABph = 120-ZABph
print "IAB = %3.2f%d deg)"%(IABmag,IABph);
IBCmag = Vmax/ZBCmag
IBCph = 0-ZBCph
print "IBC = %3.2f%d deg)"%(IBCmag,IBCph);
ICAmag = Vmax/ZCAmag
ICAph = 240-ZCAph
print "ICA = %3.2f%d deg)"%(ICAmag,ICAph);
#Applying KCL equation
#IA = IAB+IAC
#IB = IBC+IBA
#IC = ICA+ICB
x = IABmag*math.cos((IABph*math.pi)/180);
y = IABmag*math.sin((IABph*math.pi)/180);
z = complex(x,y)
x1 = ICAmag*math.cos((ICAph*math.pi)/180);
y1 = ICAmag*math.sin((ICAph*math.pi)/180);
z1 = complex(x1,y1)
x2 = IBCmag*math.cos((IBCph*math.pi)/180);
y2 = IBCmag*math.sin((IBCph*math.pi)/180);
z2 = complex(x2,y2)
IA = z-z1;
RA,ThetaA = polar([[IA]])
RA = RA[0][0].real
ThetaA = ThetaA[0][0].real
IB = z2-z;
RB,ThetaB = polar([[IB]])
RB = RB[0][0].real
ThetaB = ThetaB[0][0].real
IC = z1-z2
RC,ThetaC = polar([[IC]])
RC = RC[0][0].real
ThetaC = ThetaC[0][0].real
#Therefore")
print "IA = %3.2f%d deg)A"%(RA,(ThetaA*180/math.pi));
print "IB = %3.2f%d deg)A"%(RB,(ThetaB*180/math.pi));
print "IC = %3.2f%d deg)A"%(RC,(ThetaC*180/math.pi));
import math
from scipy.linalg import polar
# Given
#The system CBA is WYE connected")
#Maximum line voltage is 150V")
#The three impedances are 6(0 deg),6(30 deg),5(45 deg)")
ZAmag = 6;ZAph = 0;
ZBmag = 6;ZBph = 30;
ZCmag = 5;ZCph = 45;
#Let maximum line voltage is Vmax
Vmax = 150
#Let the line to neutral voltage magnitude be Vn
Vn = Vmax/math.sqrt(3)
#From fig 12.7(b)
#VAN = Vn(-90 deg)
#VBN = Vn(30 deg)
#VCN = Vn(150 deg)
#From figure 12.16
IAmag = Vn/ZAmag
IAph = -90-ZAph
print "IA = %3.2f%d deg)A"%(IAmag,IAph);
IBmag = Vn/ZBmag
IBph = 30-ZBph
print "IB = %3.2f%d deg)A"%(IBmag,IBph);
ICmag = Vn/ZCmag
ICph = 150-ZCph
print "IC = %3.2f%d deg)A"%(ICmag,ICph);
#Now to calculate IN
#IN = -(IA+IB+IC)
x = IAmag*math.cos((IAph*math.pi)/180);
y = IAmag*math.sin((IAph*math.pi)/180);
z = complex(x,y)
x1 = ICmag*math.cos((ICph*math.pi)/180);
y1 = ICmag*math.sin((ICph*math.pi)/180);
z1 = complex(x1,y1)
x2 = IBmag*math.cos((IBph*math.pi)/180);
y2 = IBmag*math.sin((IBph*math.pi)/180);
z2 = complex(x2,y2)
IN = -(z+z1+z2)
R,Theta = polar([[IN]])
R = R[0][0].real
Theta = Theta[0][0].real
print "IN = %3.2f%d deg)A"%(R,(Theta*180/math.pi));