In [1]:

```
#pg 200
#calculate the line current, power factor and power supplied
# Given data
from math import cos,acos,sqrt
R = 20.;# in ohm
X_L = 15.;# in ohm
V_L = 400.;# in V
f = 50.;# in Hz
#calculations
V_Ph = V_L/sqrt(3);# in V
Z_Ph = sqrt( (R**2) + (X_L**2) );# in ohm
I_Ph = V_Ph/Z_Ph;# in A
I_L = I_Ph;# in A
print "The line current in A is",round(I_L,2)
# pf = cos(phi) = R_Ph/Z_Ph;
R_Ph = R;# in ohm
phi= acos(R_Ph/Z_Ph);
# Power factor
pf= cos(phi);# in radians
print "The power factor is : ",pf,"degrees lag."
P = sqrt(3)*V_L*I_L*cos(phi);# in W
print "The power supplied in W is",P
```

In [2]:

```
#pg 201
#calculate the line and phase voltage, current and power
# Given data
from math import sqrt,cos
import cmath
R_Ph = 16.;# in ohm
X_L = 12.;# in ohm
V_L = 400.;# in V
f = 50.;# in Hz
#calculations
V_Ph = V_L/sqrt(3);# in V
Z_Ph = R_Ph + 1j*X_L;# in ohm
I_Ph= V_Ph/Z_Ph;# in A
I_L= I_Ph;# in A
phi= cmath.phase(I_L);
cos_phi= R_Ph/abs(Z_Ph);
P= sqrt(3)*V_L*abs(I_L)*cos_phi;# in W
#results
print "The line voltage in V is",V_L
print "The phase voltage in V is",round(V_Ph,2)
print "The line current in A is : ",round(abs(I_L),2)
print "The line current in A is : ",round(abs(I_Ph),2)
print "Power factor is : ",cos_phi," lagging"
print "The power absorbed in W is : ",P
```

In [3]:

```
#pg 202
#calculate the resistance and inductance
# Given data
from math import sqrt,cos,pi,acos
P = 1.5;# in kW
P = P * 10**3;# in W
pf = 0.2;# in lag
V_L = 400;# in V
f = 50;# in Hz
#calculations
phi= acos(pf);
V_Ph = V_L/sqrt(3);# in V
# P = sqrt(3)*V_L*I_L*cos(phi);
I_L = P/(sqrt(3)*V_L*cos(phi));# in A
I_Ph = I_L;# in A
Z_Ph = V_Ph/I_Ph;# in ohm
R_Ph = Z_Ph*cos(phi);# in ohm
X_Ph = sqrt( (Z_Ph**2) - (R_Ph**2) );# in ohm
L_Ph = X_Ph/(2*pi*f);# in H
#results
print "The Resistance in ohm is",round(R_Ph,2)
print "The inductance in H is",round(L_Ph,4)
```

In [4]:

```
#pg 203
#calculate the line current and total power
# Given data
from math import sqrt,pi,cos,acos
R = 5;# in ohm
L =0.02;# in H
V_L = 440.;# in V
f = 50.;# in Hz
#calculations
X_L = 2*pi*f*L;# in ohm
Z_Ph = sqrt( (R**2)+(X_L**2) );# in ohm
V_Ph = V_L;# in V
I_Ph = V_Ph/Z_Ph;# in A
I_L = sqrt(3)*I_Ph;# in A
phi = acos(R/Z_Ph);# in lag
P = sqrt(3)*V_L*I_L*cos(phi);# in W
P= P*10**-3;# in kW
#results
print "The line current in A is",round(I_L,2)
print "The total power absorbed in kW is",round(P,2)
print 'Note: To evaluate the value of P, the wrong value of I_L is put , so the calculated value of P in the book is not correct'
```

In [5]:

```
#pg 203
#calculate the phase current, resistance, inductance and power
# Given data
from math import acos,sqrt,pi,cos
V_L = 400.;# in V
f = 50.;# in Hz
I_L = 17.32;# in A
pf = 0.8;# in lag
#calculations
I_Ph = I_L/sqrt(3);# in A
print "The phase current in A is",round(I_Ph)
V_Ph = V_L;# in V
Z_Ph = V_Ph/I_Ph;# in ohm
phi = acos(pf)# in lag
R_Ph = Z_Ph*cos(phi);# in ohm
print "The resistance of coil in ohm is",round(R_Ph)
X_Ph = sqrt( (Z_Ph**2) - (R_Ph**2) );# in ohm
# X_Ph = 2*%pi*f*L;
L = X_Ph/(2*pi*f);# in H
L = L * 10**3;# in mH
print "The inductance of coil in mH is",round(L,1)
P = V_Ph*I_Ph*cos(phi);# in W
print "The power drawn by each coil in W is",round(P)
```

In [6]:

```
#pg 208
#calculate the power factor
from math import atan,sqrt,cos
# Given data
W1 = 1000.;# in W
W2 = 550.;# in W
#calculations
phi = (atan( sqrt(3)*((W1-W2)/(W1+W2)) ));# in radians
# power factor
pf= cos(phi);# lag
print "The power factor of the load is : ",round(pf,2)," lag."
```

In [7]:

```
#pg 208
#calculate the power factor in both cases
# Given data
from math import cos,atan,sqrt
W1 = 2000.;# in W
W2 = 500.;# in W
#calculations
phi = (atan( sqrt(3)*((W1-W2)/(W1+W2)) ));# in lag
# power factor
pf= cos(phi);# lagging
print "Part (i) : Power factor is : ",round(pf,4)," lagging"
W2 = -W2;# in W
phi = (atan( sqrt(3)*((W1-W2)/(W1+W2)) ));# in lag
# power factor
pf= cos(phi);# lagging
print "Part (ii) : Power factor is : ",round(pf,3)," lagging"
```

In [8]:

```
#pg 208
#calculate the power factor
# Given data
from math import atan,sqrt,cos
W1 = 375.;# in W
W2 = -50.;# in W
#calculations
# tan(phi) = sqrt(3)*((W1-W2)/(W1+W2));
phi = atan(sqrt(3)*((W1-W2)/(W1+W2)));# in degree
# power factor
pf= cos(phi);# lag
#results
print "The power factor is : ",round(pf,3)," lag."
```

In [9]:

```
#pg 209
#calculate the power input,factor,output and line current
# Given data
from math import atan,cos,sqrt
W1 = 300.;# in kW
W2 = 100.;# in kW
V_L= 2000.;# in V
Eta= 90/100.;
#calculations
P = W1+W2;# in kW
# tan(phi) = sqrt(3)*((W1-W2)/(W1+W2));
phi = atan(sqrt(3)*((W1-W2)/(W1+W2)));
pf = cos(phi);# power factor
# P = sqrt(3)*V_L*I_L*cosd(phi);
I_L = (P*10**3)/(sqrt(3)*V_L*pf);# in A
output = P*Eta;# in kW
#results
print "The power input in kW is",P
print "The power factor is",round(pf,3)
print "The line current in A is",round(I_L,2)
print "The power output in kW is",output
```

In [10]:

```
#pg 209
#calculate the phase current,impedance and power factor
# Given data
from math import sqrt,acos,cos
P = 12.;# in kW
P = P * 10**3;# in W
V_L = 400.;# in V
I_L = 20.;# in A
I_Ph = I_L;# in A
#calculations
V_Ph = V_L/sqrt(3);# in V
Z_Ph = V_Ph/I_Ph;# in ohm
# P = sqrt(3)*V_L*I_L*cos(phi);
phi= acos(P/(sqrt(3)*V_L*I_L));# in lag
# power factor
pf= cos(phi);# lag
#results
print "The phase current in A is",I_Ph
print "The impedance of load in ohm is",round(Z_Ph,2)
print "The power factor is : ",round(pf,3)," lag."
```

In [11]:

```
#pg 210
#calculate the line current, power factor, three phase power and volt amperes
# Given data
import cmath
from math import cos,sqrt
Z_Ph= 8+6*1j;# in ohm
V_L= 400;# in V
#calculations
V_Ph= V_L/sqrt(3);# in V
I_Ph= V_Ph/Z_Ph;# in A
I_L= I_Ph;# in A
phi= cmath.phase(I_L);# in radians
print "The line current in A is : ",round(abs(I_L),2)
# power factor
pf= cos(phi);# lagging
print "Power factor is : ",pf," lagging"
P= sqrt(3)*V_L*abs(I_L)*cos(phi);# in W
print "The three phase power in W is : ",P
S= sqrt(3)*V_L*abs(I_L);# in VA.
print "The three phase volt-amperes in VA is : ",S
```

In [12]:

```
#pg 211
#calculate the power and power factor
# Given data
from math import atan,cos,sqrt
W1 = 20.;# in kW
W2 = -5.;# in kW
#calculations
P = W1+W2;# in kW
phi = (atan( sqrt(3)*((W1-W2)/(W1+W2)) ));# in lag
# Power factor of the load
pf= cos(phi)
#results
print "The power in kW is : ",P
print "The power factor of the load is : ",round(pf,4)
```

In [13]:

```
#pg 211
#calculate the readings on both meters
# Given data
from math import atan,sqrt,cos,pi
V_L = 400.;# in V
I_L = 10.;# in A
W2= 1.;# assumed
#calculations
W1= 2*W2;
phi= atan(sqrt(3)*(W1-W2)/(W1+W2))*180/pi;
W1= V_L*I_L*cos(30-phi);# in W
W2= V_L*I_L*cos(30+phi);# in W
#results
print "The reading of first wattmeter in W is : ",W1
print "The reading of second wattmeter in W is : ",round(W2)
print 'The answer in textbook is wrong. please check using a calculator'
```

In [15]:

```
#pg 212
#calculate the phase current, resistance, inductance and power
# Given data
from math import acos,pi,cos,sqrt
from cmath import phase,exp
V_L = 400;# in V
f = 50;# in Hz
I_L = 17.32;# in A
#calculations
phi = acos(0.8);
I_Ph =I_L/sqrt(3);# in A
print "The phase current in A is",round(I_Ph)
V_Ph=V_L;# in V
Z_Ph = V_Ph/I_Ph;# in ohm
Z_Ph= Z_Ph*exp(phi*1j);# in ohm
R= Z_Ph.real;# in ohm
XL= Z_Ph.imag;# in ohm
L= XL/(2*pi*f);# in H
L= L*10**3;# in mH
print "The resistance of the coil in ohm is : ",round(R)
print "The inductance of the coil in mH is : ",round(L,4)
# The power drawn by each coil
P_Ph= V_Ph*I_Ph*cos(phi);# in W
print "The power drawn by each coil in W is : ",round(P_Ph)
```

In [16]:

```
#pg 212
#calculate the readings of both wattmeters
# Given data
from math import sqrt,acos,cos,pi
P = 30;# in kW
pf = 0.7;
#calculations
# cosd(phi) = pf;
phi = acos(pf)*180/pi;# in degree
# P = sqrt(3)*V_L*I_L*cosd(phi);
theta = 30.;# in degree
V_LI_L = P/(sqrt(3)*cos(phi*pi/180));
W1 = V_LI_L*cos((theta-phi)*pi/180);# in kW
W2 = V_LI_L*cos((theta+phi)*pi/180);# in kW
#results
print "The reading of first wattmeter in kW is",round(W1,4)
print "The reading of second wattmeter in kW is",round(W2,4)
```

In [17]:

```
#pg 213
#calculate the power factor,resistance, capacitance
# Given data
from math import cos,pi,acos,sqrt
from cmath import exp
P = 18.;# in kW
P= P*10**3;# in W
I_L = 60.;# in A
V_L = 440.;# in V
f= 50.;# in Hz
#calculations
# P = sqrt(3)*V_L*I_L*cosd(phi);
phi= acos(P/(sqrt(3)*V_L*I_L));# in radians
I_L= I_L*exp(phi*1j);# in A
I_Ph= I_L;# in A
V_Ph= V_L/sqrt(3);# in V
Z_Ph= V_Ph/I_Ph;# in ohm
R= Z_Ph.real;# in ohm
XC=abs(Z_Ph.imag);# in ohm
C = 1/(2*pi*f*XC);# in F
C=C*10**6;# in muF
# Power factor
pf= cos(phi);# lead
#results
print "The power factor is : ",round(pf,4)," leading"
print "The resistance in ohm is : ",round(R,4)
print "The capacitance in muF is : ",round(C,4)
print "The load is capacitive in nature."
```

In [18]:

```
#pg 213
#calculate the power factor, line current, impedance, resistance and inductance
# Given data
from math import cos,pi,acos,sqrt,atan
from cmath import exp
V_L = 400.;# in V
f = 50.;# in Hz
W1 = 8000.;# in W
W2 = 4000.;# in W
#calculations
W = W1+W2;# in W
phi =(atan( sqrt(3)*((W1-W2)/(W1+W2)) ));# in lag
P = W;# in W
# P = sqrt(3)*V_L*I_L*cosd(phi);
I_L = P/(sqrt(3)*V_L*cos(phi));# in A
V_Ph = V_L/sqrt(3);# in V
I_Ph = I_L;# in A
Z_Ph = V_Ph/I_Ph;# in ohm
Z_Ph= Z_Ph*exp(phi*1j);# ohm
R_Ph= Z_Ph.real;# in ohm
XL_Ph= Z_Ph.imag;# in ohm
L_Ph= XL_Ph/(2*pi*f);# in H
# power factor
pf= cos(phi);
#results
print "The power factor is : ",round(pf,5)
print "The line current in A is",I_L
print "The impedance of each phase in ohm is : ",Z_Ph
print "The resistance of each phase in ohm is : ",R_Ph
print "The inductance of each phase in H is : ",round(L_Ph,5)
```