In [7]:

```
%matplotlib inline
from numpy import linspace,array
from matplotlib.pyplot import bar,suptitle,xlabel,ylabel
# Variables
t = linspace(0,24,25)
SL = array([100,100,100,100,100,100,100,100,0,0,0,0,0,0,0,0,0,0,100,100,100,100,100,100,100]);
R = array([200,200,200,200,200,200,200,300,400,500,500,500,500,500,500,500,500,600,700,800,1000,1000,800,600,300]);
C = array([200,200,200,200,200,200,200,200,300,500,1000,1000,1000,1000,1200,1200,1200,1200,800,400,400,400,200,200,200]);
# Calculations
Tl = SL+R+C;
# Results
#To print lay the Load bar curve diagram
bar(t,Tl,color='red')#,0.5,'red')
suptitle('Example 2.1')
xlabel("Time in hrs")
ylabel("Load in kW")
```

Out[7]:

In [9]:

```
# Variables
Fls = 0.15;
Ppl = 80*(10**3); #Power Loss at peak load.
# Calculations
Avgpl = Fls*Ppl; #Average Power Loss
TAELCu = Avgpl*8760; #Total annual energy loss
# Results
print 'a) The average annual power loss = %g kW'%(Avgpl/1000)
print ' b) The total annual energy loss due to the copper losses of the feeder circuits = %g kWh'%(TAELCu/1000)
```

In [10]:

```
# Variables
TCDi = [9,9,9,9,9,9]; #Load for each house all in kilowatt
DFi = 0.65; #Demand factor
Fd = 1.1; #Diversity factor
# Calculations
Dg = sum(TCDi)*DFi/Fd;
# Results
print 'The diversified demand of the group on the distribution transformer is %g kW'%(Dg)
```

In [11]:

```
# Variables
SP = 3000*(10**3); #System peak in kVA per phase
Cl = 0.5/100; #Percentage of copper loss
# Calculations
I2R = Cl*SP; #Copper loss of the feeder per phase
I2R3 = 3*I2R; #Copper losses of the feeder per 3 phase
# Results
print 'a) The copper loss of the feeder per phase = %g kW'%(I2R/1000)
print ' b) The total coper losses of the feeder per three phase = %g kW'%(I2R3/1000)
```

In [12]:

```
# Variables
Pi = 2000.*(10**3); #Peak for industrial load
Pr = 2000.*(10**3); #Peak for residential load
Dg = 3000.*(10**3); #System peak load as specified in the diagram
P = [Pi,Pr]; #System peaks for various loads
# Calculations
Fd = sum(P)/Dg; #Diversity factor
LD = sum(P)-Dg; #Load diversity factor
Fc = 1/Fd; # Coincidence factor
# Results
print 'a) The diversity factor of the load is %g'%(Fd)
print ' b) The load diversity of the load is %g kW'%(LD/1000)
print ' c) The coincidence factor of the load is %g'%(Fc)
```

In [14]:

```
from numpy import array,transpose
# Variables
#Refer diagram of the first example of this chapter
Ps = 100.; #Peak load for street lighting in kW
Pr = 1000.; #Peak load for Residential in kW
Pc = 1200.; #Peak Commercial load in kW
P = array([Ps,Pr,Pc]) #Peaks of various loads
Ls5 = 0.; #Street lighting load at 5.00 PM in kW
Lr5 = 600.; #Residential load at 5.00 PM in kW
Lc5 = 1200.; #Commercial Load at 5.00 PM in kW
# Calculations
Cstreet = Ls5/Ps;
Cresidential = Lr5/Pr;
Ccommercial = Lc5/Pc;
C = array([Cstreet,Cresidential,Ccommercial]); #Class distribution for various factors
Fd = (sum(P))/(sum(P* transpose(C)));
Dg = (sum(P* transpose(C)));
Fc = 1/Fd;
print 'a The class distribution factors factor of:'
print ' i) Street lighting = %g \
\nii) Residential = %g \
\niii) Commercial = %g'%(C[0],C[1],C[2])
print ' b) The diversity factor for the primary feeder = %g'%(Fd)
print ' c) The diversified maximum demand of the load group = %g kW'%(Dg)
print ' d) The coincidence factor of the load group = %g'%(Fc)
```

In [15]:

```
print 'Assuming a monthly load curve as shown in the figure attached\
to this code'
# Variables
TAE = 10.**7; # Total annual energy in kW
APL = 3500.; #Annual peak load in kW
# Calculations
Pav = TAE/8760; #Annual average power demand
Fld = Pav/APL; #Annual load factor
# Results
print 'a) The annual power demand is %g kW'%(Pav)
print 'b) The annual load factor is %g'%(Fld)
print 'The unsold energy, as shown in the figure is a measure of capacity and investment math.cost. Ideally it should be kept at a minimum'
```

In [16]:

```
print 'Assuming a monthly load curve as shown in the figure attached to this code'
# Variables
Nl = 100.; #100% percent load to be supplied
TAE = 10.**7; # Total annual energy in kW
APL = 3500.; #Annual peak load in kW
# Calculations
Pav = TAE/8760; #Annual average power demand
Fld = (Pav+Nl)/(APL+Nl); #Annual load factor
Cr = 3; #Capacity math.cost
Er = 0.03; #Energy math.cost
ACC = Nl*12*Cr; #Additional capacity math.cost per kWh
AEC = Nl*8760*Er; #Additional energy math.cost per kWh
TAC = ACC+AEC; #Total annual math.cost
# Results
print 'a) The new annual load factor on the substation is %g'%(Fld)
print 'b) The total annual additional costs to NL&NP to serve this load is $%g'%(TAC)
```

In [18]:

```
# Variables
TAE = 5.61*(10**6); #Total annual energy in kW
APL = 2000.; #Annual peak load in kW
Lc = 0.03; #Cost of energy per kWh in dollars
Plp = 100.; #Power at peak load in kW
# Calculations
Fld = TAE/(APL*8760);
Fls = (0.3*Fld)+(0.7*(Fld**2));
AvgEL = Fls*Plp; #Average energy loss
AEL = AvgEL*8760; #Annual energy loss
Tlc = AEL*Lc; #Cost of total annual copper loss
# Results
print 'a) The annual loss factor is %g'%(Fls)
print ' b) The annual copper loss energy is %g kWh and the cost of total annual copper loss is $%g'%(AEL,Tlc)
```

In [27]:

```
import math
from numpy import array,arctan,transpose,arccos,radians
from sympy import Symbol,solve
Fd = 1.15;
Pi = [1800,2000,2200]; #Demands of various feeders in kW (Real Power)
PF = [0.95,0.85,0.90]; #Power factor of the respective feeders
Dg = sum(Pi)/Fd;
P = Dg;
theta = arccos(PF);
Q = sum(Pi*(radians(arctan(theta))))/Fd;
S = math.sqrt((P**2)+(Q**2));
LD = sum(Pi)-Dg;
#Transformer sizes
Tp = array([2500,3750,5000,7500]);
Ts = array([3125,4687,6250,9375]);
Ol = 1.25; #Maximum overload condition
Eol = Ts*Ol; #Overload voltages of the transformer
Ed = abs(Eol-S); # Difference between the overload values of the transformers and the P value of the system
A = sorted(Ed); # To sort the differences and choose the best match
T = [Tp[1],Ts[1]]; #Suitable transformer
g = Symbol('g');
X = (1+g)-pow(2,1./10); #To find out the fans on rating
R = solve(X)[0];
g = R*100;
n = Symbol('n');
Sn = 9375.; # Rating of the to be installed transformer
# Equation (1+g)**n * S = Sn
# a = (1+g)
# b = Sn/S
a = 1+R;
b = Sn/S;
n = math.log(b)/math.log(a);
print 'a) The 30 mins annual maximum deman on the substation transformer are %g kW and %g kVA respectively'%(P,S)
print ' b) The load diversity is %g kW'%(LD)
print ' c) Suitable transformer size for 25 percent short time over loads is %g/%g kVA'%(T[0],T[1])
print ' d) Fans on rating is %g percent and it will loaded for %g more year if a 7599/9375 kVA transformer is installed'%(g,math.ceil(n))
```

In [34]:

```
from numpy import array
print 'NOTE'
print 'The figure 1 attached along with this code is the Maximum diversified 30- min demand characteristics\
of various residential loads; A = Clothes dryer; D = range; E = lighting and miscellaneous appliances; \
J = refrigerator Only the loads required for this problem have been mentioned '
Ndt = 50.; #Number of distribution transformers
Nr = 900.; #Number of residences
#When the loads are six.
PavMax6 = array([1.6,0.8,0.066,0.61]); #Average Maximum diversified demands (in kW) per house for dryer, range, refrigerator, for lighting and misc aapliances respectively according to the figure 1 attached with code.
Mddt = sum(6*PavMax6); #30 min maximum diversified demand on the distribution transformer
#When the loads are 900.
PavMax900 = array([1.2,0.53,0.044,0.52]); # #Average Maximum diversified demands (in kW) per house for dryer, range, refreigerato, for lighting and misc aapliances respectively according to the figure 1 attached with code.
Mdf = sum(Nr*PavMax900); #30 min maximum diversified demand on the feeder
#From the figure 2 attached to this code
Hdd4 = array([0.38,0.24,0.9,0.32]); #Hourly variation factor at time 4 PM for dryer, range, refrigerator, lighting and misc appliances
Hdd5 = array([0.30,0.80,0.9,0.70]); #Hourly variation factor at time 5 PM for dryer, range, refrigerator, lighting and misc appliances
Hdd6 = array([0.22,1.0,0.9,0.92]); #Hourly variation factor at time 6 PM for dryer, range, refrigerator, lighting and misc appliances
Thdd4 = (6*PavMax6)*(Hdd4.T); #Gives the total hourly diversified demand in kW at time 4 PM
Thdd5 = (6*PavMax6)*Hdd5; #Gives the total hourly diversified demand in kW at time 5 PM
Thdd6 = (6*PavMax6)*Hdd6; #Gives the total hourly diversified demand in kW at time 6 PM
print ' a) The 30 min maximum diversified demand on the distribution transformer = %g kW'%(Mddt)
print ' b) The 30 min maximum diversified demand on the distribution transformer = %g kW'%(Mdf)
print ' c The total hourly diversified demands at:'
print ' i) 4.00 PM = %g kW'%(sum(Thdd4))
print ' ii) 5.00 PM = %g kW'%(sum(Thdd5))
print ' iii) 6.00 PM = %g kW'%(sum(Thdd6))
```

In [40]:

```
import math
from numpy import array,arctan,radians,degrees,ceil
T = 730; #Average monthly time in hrs
Pla = 22; #Peak Load for consumer A in kW
Plb = 39; #Peak load for consumer B in kW
MEC = array([0.025,0.02,0.015]); #Monthly Energy charges in cents/kWh according to the units consumed
Uc = array([1000,3000,3000]); #Units consumption according to the Energy charges
MDC = 2; #Monthly demand charge in dollars/kW
Pa = 7000.; #Units served to Consumer A in kWh
Pb = 7000.; #Units served to Consumer B in kWh
#Power factors
Pfa = 0.9; # Lag
Pfb = 0.76; #Lag
#Monthly Load factors
Flda = Pa/(Pla*T);
Fldb = Pb/(Plb*T);
#Continous kilovoltamperes for each distribution transformer
Sa = Pla/Pfa;
Sb = Plb/Pfb;
#Ratings of the distribution transformers needed
Ta = round(Sa/5)*5;
Tb = round(Sb/5)*5;
#Billing Charges
#For Consumer A
Mbda = Pla*(0.85/Pfa); # Monthly billing demand
Mdca = Mbda*MDC; #Monthly demand charge
#Since the units served are 7000 it can be split according to the rates as 1000, 3000, 3000 excess units.
Uca = Uc; #Units consumption by A
Meca = MEC*Uca.T; #Monthly energy charge
Tmba = Meca+Mdca; #Total monthly bill
#For Consumer B
Mbdb = Plb*(0.85/Pfb); # Monthly billing demand
Mdcb = Mbdb*MDC; #Monthly demand charge
#Since the units served are 7000 it can be split according to the rates as 1000, 3000, 3000 excess units.
Ucb = Uc; #Units consumption by B
Mecb = MEC*Ucb.T; #Monthly energy charge
Tmbb = Mecb+Mdcb; #Total monthly bill
#To find the capacitor size
Q1 = Pb*math.radians(arctan(math.acos(Pfb))); #For original power factor
Q2 = Pb*math.radians(arctan(math.acos(0.85))); #For new power factor
dQ = (Q1-Q2)/T; #Capacitor size
#For new power factor
#For Consumer B
Mbdbn = Plb*(1); # Monthly billing demand
Mdcbn = Mbdbn*MDC; #Monthly demand charge
#Since the units served are 7000 it can be split according to the rates as 1000, 3000, 3000 excess units.
Ucbn = Uc; #Units consumption by B
Mecbn = MEC*Ucbn.T; #Monthly energy charge
Tmbbn = Mecbn+Mdcbn; #Total monthly bill
Saving = abs(Tmbbn-Tmbb); #Saving due to capacitor installation
Ci = 30; # Cost of capacitor in dollar per kVAr
Cc = Ci*dQ; #The math.cost of the installed capacitor
PP = Cc/Saving; #Payback Period
PPr = 90/Saving; #Realistic Payback period
print 'a Monthly load factor for :'
print ' i) Consumer A = %g'%(Flda)
print ' ii) Consumer B = %g'%(Fldb)
print ' b Rating of the each of the distribution transformer:'
print ' i) A = %g kVA'%(Ta)
print ' ii) B = %g kVA'%(Tb)
print ' c Monthly bil for:'
print ' i) Consumer A = $%g'%(sum(Tmba))
print ' ii) Consumer B = $%g'%(sum(Tmbb))
print ' d) The capacitor size required is %g kVAr'%(dQ)
print ' e Payback period:'
print ' i) Calculated : %g months'%(sum(ceil(PP)))
print ' ii) Realistic as capacitor size available is 3 kVAr : %g months'%(sum(ceil(PPr)))
```

In [41]:

```
# Variables
Kh = 7.2; #Meter consmath.tant
Kr1 = 32; #Revolutions of the disk in the first reading
Kr2 = 27; #Revolutions of the disk in the second reading
T1 = 59; #Time interval for revolutions of disks for the first reading
T2 = 40; #Time interval for revolutions of disks for the second reading
# Calculations
# Self contained watthour meter; D = (3.6*Kr*Kh)/T
def Id1(a,b):
return ((3.6*Kh*a)/b) #Function to calculate the instaneous demand
D1 = Id1(Kr1,T1);
D2 = Id1(Kr2,T2);
Dav = (D1+D2)/2;
# Results
print 'The instantenous demands are %g kW and %g kW for reading 1 and 2 and the average demand is %g kW'%(D1,D2,Dav)
```

In [42]:

```
# Variables
#For a transformer type watthour meter; D = (3.6*Kr*Kh*CTR*PTR)/T
CTR = 200.;
PTR = 1.;
Kh = 1.8;
Kr1 = 32.; #Revolutions of the disk in the first reading
Kr2 = 27.; #Revolutions of the disk in the second reading
T1 = 59.; #Time interval for revolutions of disks for the first reading
T2 = 40.; #Time interval for revolutions of disks for the second reading
# Calculations
def Id1(a,b):
return ((3.6*Kh*a*CTR*PTR)/b) #Function to calculate the instaneous demand
D1 = Id1(Kr1,T1);
D2 = Id1(Kr2,T2);
Dav = (D1+D2)/2;
# Results
print 'The instantenous demands are %g kW and %g kW for reading 1 and 2 and the average demand is %g kW'%(D1,D2,Dav)
```

In [43]:

```
# Variables
Kh = 1.2;
CTR = 80.;
PTR = 20.;
#Revolutions of the disk in a watthour meter for 1 and 2 readings respectively
Kr1 = 20.;
Kr2 = 30.;
#Revolutions of the disk in a VArhour meter for 1 and 2 readings respectively
Kr3 = 10.;
Kr4 = 20.
#Time interval for revoltion of disks in watthour meter for 1 and 2 readings respectively
T1 = 50.;
T2 = 60.;
#Time interval for revoltion of disks in VArhour meter for 1 and 2 readings respectively
T3 = 50.;
T4 = 60.;
def Id1(a,b):
return ((3.6*Kh*a*CTR*PTR)/b) #Function to calculate the instaneous demand
#instanmath.taneous kilowatt demands for readings 1 and 2
D1 = Id1(Kr1,T1);
D2 = Id1(Kr2,T2);
#instanmath.taneous kilovar deamnds for readings 1 and 2
D3 = Id1(Kr3,T3);
D4 = Id1(Kr4,T4);
Davp = (D1+D2)/2; #Average kilowatt demand
Davq = (D3+D4)/2; #Average kilovar demand
Dav = math.sqrt((Davp**2)+(Davq**2)); #Average kilovoltampere demand
# Results
print 'a) The instanmath.taneous kilowatt hour demands for readings 1 and 2 are %g kW and %g kW respectively'%(D1,D2)
print ' b) The average kilowatt demand is %g kW'%(Davp)
print ' c) The instanmath.taneous kilovar hour demands for readings 1 and 2 are %g kVAr and %g kVAr respectively'%(D3,D4)
print ' d) The average kilovar demand is %g kVAr'%(Davq)
print ' e) The average kilovoltampere demand is %g kVA'%(Dav)
```