In [1]:

```
import math
#initialisation of variables
I1 = 1.0
I2 = 0.8
V3 = 1.0
pf1 =1.0
pf2 = pf1
pf3 = pf1
#Calculations
Za = complex(0.04,0.16)
Ra = Za.real
Zb = complex(0.03,0.12)
Rb = Zb.real
Zc = complex(0.02,0.08)
Rc = Zc.real
V1 = V3 + I1 * Za
print(V1,'Voltage at bus 1,V1 in per unit')
V2 = V3 + I2 * Zb
#Results
print(V2,'Voltage at bus 2,V2 in per unit')
print('Transmission Loss Co-efficients')
B11 = (Ra + Rc) / (abs(V1) * pf1)**2
print('B11 in per unit = %.2f' %B11)
B12 = Rc / (abs(V1) * abs(V2) * pf1 * pf2)
print('B12 in per unit = %.2f' %B12)
B22 = (Rb + Rc) / (abs(V2) * pf2)**2
print('B22 in per unit = %.2f' %B22)
```

In [2]:

```
import math
#initialisation of variables
I1 = 1.0
I2 = 0.8
V3 = 1.0
pf1 =1.0
pf2 = pf1
pf3 = pf1
#Calculations
Za = complex(0.04,0.16)
Ra = Za.real
Zb = complex(0.03,0.12)
Rb = Zb.real
Zc = complex(0.02 ,0.08)
Rc = Zc.real
V1 = V3 + I1 * Za
V2 = V3 + I2 * Zb
B11 = (Ra + Rc) / (abs(V1) * pf1)**2
B12 = Rc / (abs(V1) * abs(V2) * pf1 * pf2)
B22 = (Rb + Rc) / (abs(V2) * pf2)**2
P1 = (I1.real * V1.real)
#Results
print('P1 in per unit = %.2f' %P1)
P2 = (I2.real * V2.real)
print('P2 in per unit = %.2f' %P2)
PL = (P1)**2 * B11 + 2 * P1 * P2 * B12 + (P2)**2 * B22
print('Loss calculated using loss coefficients in per unit is = %.2f' %PL)
PL_I2R = I1**2 * Ra + (I1+I2)**2 * Rc + I2**2 * Rb
print('Loss calculated using current and resistance in per unit is = %.2f' %PL_I2R)
```

In [3]:

```
import math
#initialisation of variables
l = 12.5
dF_dP = [[0.01,8,0.5],[0.015,9,0.5]]
B22 = 0
B12 = 0 #since all the load is at plant 2
P1_trans = 200
PL_trans = 16
#Calculations
B11 = PL_trans / P1_trans**2
print(" Penalty factors are \n L1 = 1 / (1 - %fP1) \n L2 = 1" %(2*B11))
P1 = (l - dF_dP[0][1]) / (2*B11 * l + dF_dP[0][0])
P2 = (l - dF_dP[1][1]) / dF_dP[1][0]
PL = B11 * P1**2
Pr = P1 + P2 - PL
#Results
print("Required generation from plant \n P1 = %.0fMW \n P2 = %.0fMW" %(P1,P2))
print("Power loss in transmisison is %.0fMW" %(PL))
print("The delivered load is %.0fMW" %Pr)
```