from math import sqrt
v=460;
i=200;
r=1.73*v*i/1e3;
r=round(r*10)/10;
p=120;
c=p/r;#the difference in result is due to erroneous calculation in textbook.
s=sqrt(1-(c**2))
rr=r*s;
print"the power factor=\nthe rating=kVA\n the kVAr of system=kVA",c,r,rr
print"the difference in result is due to erroneous calculation in textbook."
from math import sin,cos,acos,sqrt
r1=75;
c1=.8;
p1=r1*c1;
rr1=r1*(sin(acos(c1)));
r2=150;
c2=.8;
p2=r2*c2;
rr2=r2*(sin(acos(c2)));
r3=50;
c3=1;
p3=r3*c3;
rr3=r3*(sin(acos(c3)));
rr=-rr1+rr2+rr3;
p=p1+p2+p3;
r=sqrt(p**2+rr**2);
r=round(r)
j=p/r;
print"the power factor of the substation=",round(j,2)
from math import sin,cos,acos,sqrt
c1=.8;
p1=120;
r1=p1/c1;
rr1=r1*(sin(acos(c1)));
c2=.9;
r2=p1/c2;
rr2=r2*(sin(acos(c2)));
rr2=round(rr2);
rr=rr1-rr2;
print"the kVAr of capacitors = kVA",rr
k=100.;
s=400.;
pf=1-((k/s)**2);
print"the power factor is ",pf
print"the difference in result is due to erroneous calculation in textbook."
k=12.
m=72.;
pf=1-((k/m)**2);
print"the power factor is (lag)",round(pf,2)
from math import sin,cos,acos,sqrt,tan,atan
n1=.89;
h1=150;
c1=.9;
h2=200;
n2=.9;
c2=.8;
h3=500;
n3=.93;
c3=.707;
p4=100;
p1=h1*.746/n1;
p2=h2*.746/n2;
p3=h3*.746/n3;
rr1=p1*(tan(acos(c1)));
rr2=p2*(tan(acos(c2)));
rr3=p3*(tan(acos(c3)));
rr4=0;
rr=rr1+rr2-rr3+rr4;
p=p1+p2+p3+p4;
c=rr/p;
j=cos(atan(c));
j=round(j*1000)/1000;
print"the Power Factor of the combined sub-station= leading",j