**4. Implementation of PSO**

This section provides a brief introductory concept of PSO. If Xi = (*xi*1, *xi*2 ,…, *xid)* and *Vi =*(*vi*1, *vi*<sup>2</sup> ,…, *vid)* are the position vector and the velocity vector respectively in *d* dimensions search space, then according to a fitness function, where *Pi=(pi*1, *pi*2,…, *pid)* is the *pbest* vector and Pg=(pg1, p*g*2,…, pg*d)* is the *gbest* vector, i.e. the fittest particle of *Pi*, updating new positions and velocities for the next generation can be determined.


**Figure 2.** The pseudo code of the PSO method

A PSO Approach in Optimal FACTS Selection with Harmonic Distortion Considerations 67

$$\mathbf{V}\_{id}\left(t\right) = \alpha \mathbf{V}\_{id}\left(t-1\right) + \mathbf{C}\_1 \, ^\ast \, rand \mathbf{1} \, ^\ast \left(P\_{id} - X\_{id}\left(t-1\right)\right) + \mathbf{C}\_2 \, ^\ast \, rand \mathbf{2} \, ^\ast \left(P\_{\frac{\pi}{\mathcal{S}}d} - X\_{id}\left(t-1\right)\right) \tag{21}$$

$$X\_{id}\left(t\right) = X\_{id}\left(t-1\right) + V\_{id}\left(t\right) \tag{22}$$

where *Vid* is the particle velocity, *Xid* is the current particle (solution). *Pid* and *Pgd* are defined as above. *rand1* and *rand2* are random numbers which is uniformly distributed between [0,1]. *C1, C2* are constant values which is usually set to *C1 = C2 = 2.0*. These constants represent the weighting of the stochastic acceleration which pulls each particle towards the *pbest* and *gbest* position. ω is the inertia weight and it can be expressed as follows:

$$
\omega = (\alpha\_i - \alpha\_f)^\* \frac{iter\_{\text{max}} - iter}{iter\_{\text{max}}} + \alpha\_f \tag{23}
$$

where i and f are the initial and final values of the inertia weight respectively. *iter* and *itermax* are the current iterations number and maximum allowed iterations number respectively.

The velocities of particles on each dimension are limited to a maximum velocity *Vmax*. If the sum of accelerations causes the velocity on that dimension to exceed the user-specified *Vmax*, the velocity on that dimension is limited to *Vmax*.

In this chapter, the parameters used for PSO are as follows:


66 An Update on Power Quality

explained as follows.

**4. Implementation of PSO** 

and velocities for the next generation can be determined.

END

Do

 End 

End

**Figure 2.** The pseudo code of the PSO method

For each particle Initialize particle

For each particle

Calculate fitness value

the particles as the *gbest*  For each particle

condition is satisfied

 If the fitness value is better than the best fitness value (*pbest*), set current value as the new *pbest* 

Choose the particle with the best fitness value of all

 Calculate particle velocity from equation (*21*) Update particle position from equation (*22*)

While maximum iteration is reached or minimum error

Perform mutation operation with pm

or reproduction, 2) Crossover, and 3) mutation. Each string is called chromosome and represents a possible solution. The algorithm starts from an initial population generated randomly. Using the genetic operations considering the fitness of a solution, which corresponds, to the objective function for the problem generates a new generation. The string's fitness is usually the reciprocal of the string's objective function in minimization problem. The fitness of solutions is improved through iterations of generations. For each chromosome population in the given generation, a Newton-Raphson load flow calculation is performed. When the algorithm converges, a group of solutions with better fitness is generated, and the optimal solution is obtained. The scheme of genetic operations, the structure of genetic string, its encode/decode technique and the fitness function are designed. The implementation of PSO components and the neighborhood searching are

This section provides a brief introductory concept of PSO. If Xi = (*xi*1, *xi*2 ,…, *xid)* and *Vi =*(*vi*1, *vi*<sup>2</sup> ,…, *vid)* are the position vector and the velocity vector respectively in *d* dimensions search space, then according to a fitness function, where *Pi=(pi*1, *pi*2,…, *pid)* is the *pbest* vector and Pg=(pg1, p*g*2,…, pg*d)* is the *gbest* vector, i.e. the fittest particle of *Pi*, updating new positions


There are two stopping criteria in this chapter. Firstly, i(t is the number of iterations since the last change of the best solution is greater than a preset number. The PSO is terminated while maximum iteration is reached.

For the PSO, the constriction and inertia weight factors are introduced and (21) is improved as follows.

$$V\_{id}\left(t\right) = k \left\langle \alpha V\_{id}\left(t - 1\right) + \varphi\_1 \ast rand1^\*\left(P\_{id} - X\_{id}\left(t - 1\right)\right) + \varphi\_2 \ast rand2^\*\left(P\_{\rm gd} - X\_{id}\left(t - 1\right)\right)\right\rangle \tag{24}$$

$$k = \frac{2}{\left| 2 - \left( \wp\_1 + \wp\_2 \right) - \sqrt{\left( \wp\_1 + \wp\_2 \right)^2 - 4\left( \wp\_1 + \wp\_2 \right)} \right|}\tag{25}$$

where *k* is a constriction factor from the stability analysis which can ensure the convergence (i.e. avoid premature convergence) where ߮ଵ ߮ଶ> 4 and kmax < 1 and is dynamically set as follows:

$$
\omega \circ \omega = \alpha\_{\max} - \frac{\alpha\_{\max} - \alpha\_{\min}}{t\_{Total}} \times t \tag{26}
$$

A PSO Approach in Optimal FACTS Selection with Harmonic Distortion Considerations 69

No No solution found within the constraints

Start

Input setting, system file and capacitor file.

Setup a Y-matrix

Setup the possible choice of the SVC sizes and costs.

Optimal SVC location calculation subprogram \*

PSO calculation subprogram \*\*

Any feasible solution found ?

End

Output the old setting result

No

PSO calculation subprogram \*\*

Record the best result and set as new solution

Record the best result and set as old solution

Optimal SVC location calculation subprogram \*

Yes

Old solution replaced by new solution

> Is all location considered ?

Yes

No

Yes

Output the new setting result

\* refer to Figure 4 and \*\* refer to Figure 5 **Figure 3.** Flow chart of main operation Is new solution better than old solution?

where t and tTotal is the current iteration and total number of iteration respectively and ߱ and ߱௫ is the upper and lower limit which are set 1.3 and 0.1 respectively.

The advantage of the integration of mutation from GAs is to prevent stagnation as the mutation operation choose the particles in the swarm randomly and the particles can move to difference position. The particles will update the velocities and positions after mutation.

$$
\mathcal{I}(\text{mutation}(\mathbf{x}\_{id}) = \mathbf{x}\_{id} - \alpha \iota(-1 < r < 0) \tag{27}
$$

$$\text{Amutation} \left( \mathbf{x}\_{\text{id}} \right) = \mathbf{x}\_{\text{id}} + \alpha \nu \left( \mathbf{1} > r \ge 0 \right) \tag{28}$$

where xid is a randomly chosen element of the particle from the swarm, ω is randomly generated within the range [0, <sup>ଵ</sup> ଵ × (particle max – particle min)] (particle max and particle min are the upper and lower boundaries of each particle element respectively) and r is the random number in between 1 and -1

Implementation of an optimization problem is realized within the evolutionary process of a fitness function. The fitness function adopted is derived as equation (9). The objective function is to minimize f. It is composed of two parts; 1) the cost of the power loss in the transmission branch and 2) the cost of reactive power supply. Since PSO is applied to maximization problem, minimization of the problem take the normalized relative fitness value of the population and the fitness function is defined as:

$$f\_i = \frac{f\_{\text{max}} - f\_a}{f\_{\text{max}}} \tag{29}$$

where 1 *m l p loss cj cj <sup>j</sup> f <sup>a</sup> KK P Q K* 

#### **5. Software design**

Figure 3 depicts the main steps in the process of this chapter. The predefined processes of optimal SVC location and Particle Swarm Optimisation calculation are illustrated in Figure 4 and Figure 5.

\* refer to Figure 4 and \*\* refer to Figure 5

68 An Update on Power Quality

generated within the range [0, <sup>ଵ</sup>

number in between 1 and -1

where

*f*

and Figure 5.

**5. Software design** 

ω ω *max min max*

where t and tTotal is the current iteration and total number of iteration respectively and ߱

The advantage of the integration of mutation from GAs is to prevent stagnation as the mutation operation choose the particles in the swarm randomly and the particles can move to difference position. The particles will update the velocities and positions after mutation.

> , 1 0 *mutation x x r id id*

 , 1 0 *mutation x x r id id* 

where xid is a randomly chosen element of the particle from the swarm, ω is randomly

the upper and lower boundaries of each particle element respectively) and r is the random

Implementation of an optimization problem is realized within the evolutionary process of a fitness function. The fitness function adopted is derived as equation (9). The objective function is to minimize f. It is composed of two parts; 1) the cost of the power loss in the transmission branch and 2) the cost of reactive power supply. Since PSO is applied to maximization problem, minimization of the problem take the normalized relative fitness

> max max *a*

Figure 3 depicts the main steps in the process of this chapter. The predefined processes of optimal SVC location and Particle Swarm Optimisation calculation are illustrated in Figure 4

*f f*

*i*

value of the population and the fitness function is defined as:

1 *m l p loss cj cj <sup>j</sup>*

*<sup>a</sup> KK P Q K* 

and ߱௫ is the upper and lower limit which are set 1.3 and 0.1 respectively.

*Total*

 

*t* 

*t*

(26)

ଵ × (particle max – particle min)] (particle max and particle min are

*<sup>f</sup> <sup>f</sup>* (29)

(27)

(28)

**Figure 3.** Flow chart of main operation

A PSO Approach in Optimal FACTS Selection with Harmonic Distortion Considerations 71

**Figure 5.** Flow chart of 'Particle Swarm Optimisation calculation subprogram' in Figure 3

**Figure 4.** Flow chart of 'Optimal SVC location calculation subprogram' in Figure 2

A PSO Approach in Optimal FACTS Selection with Harmonic Distortion Considerations 71

70 An Update on Power Quality

Is harmonic considered ?

Calculate power loss in each line (equation 7)

Harmonic distortion calculation subprogram

Yes

No

Select the optimal capacitor location

Exit

**Figure 4.** Flow chart of 'Optimal SVC location calculation subprogram' in Figure 2

Enter

Newton-Raphson power flow calculation

**Figure 5.** Flow chart of 'Particle Swarm Optimisation calculation subprogram' in Figure 3

A PSO Approach in Optimal FACTS Selection with Harmonic Distortion Considerations 73

**Bus j**  Ri,i<sup>1</sup> Xi,i<sup>1</sup>

**Bus 1 2 3 4 5 6 7 8 9 P(kW)** 1840 980 1790 1598 1610 780 1150 980 1640 **Q(MVAr)** 460 340 446 1840 600 110 60 130 200 **Non-linear (%)** 0 55.7 18.9 92.1 4.7 1.9 38.2 4.5 4.0

> 0 1 0.1233 0.4127 1 2 0.0140 0.6051 2 3 0.7463 1.2050 3 4 0.6984 0.6084 4 5 1.9831 1.7276 5 6 0.9053 0.7886 6 7 2.0552 1.1640 7 8 4.7953 2.7160 8 9 5.3434 3.0264

**Harmonic current sources(%) in harmonic order** 

Bus **5 7 11 13 17 19 23 25** 0 0 0 0 0 0 0 0 9.1 5.3 1.8 1.1 0.7 0.6 0.4 0.3 3.1 1.8 0.6 0.4 0.2 0.2 0.1 0.1 6.2 3.6 1.3 0.8 0.5 0.4 0.3 0.2 17.7 2.9 4.5 8.2 5.4 2.9 2.9 0 0 0 9.6 5.8 0 0 3.6 3.0 0.3 0 0 0 0 0 0 0 0.8 0.5 0.2 0 0 0 0 0 15.1 8.8 3.0 1.8 1.2 1.0 0.6 0.5

Kp is selected to be US \$168/MW in equation (9). The minimum and maximum voltages are 0.9 p.u. and 1.0 p.u. respectively. All voltage and power quantities are per-unit values. The base value of voltage and power is 23kV and 100MW respectively. Commercially available SVC sizes are analyzed. Table 4 shows an example of such data provided by a supplier for 23kV distribution feeders. For reactive power compensation, the maximum SVC size Qc(max) should not exceed the reactive load, i.e. 4186 MVAr. SVC sizes and costs are shown in Table 5 by assuming a life expectancy of ten years (the placement, maintenance, and running costs

**Table 1.** Load data of the test system

**Table 2.** Feeder data of the test system

**Table 3.** The harmonic current sources

are assumed to be grouped as total cost.)

**From Bus i From** 

**Figure 6.** Flow chart of 'Harmonic distortion calculation subprogram' in Figure 4 and Figure 5

## **6. Numerical example and results**

In this section, a radial distribution feeder [10] is used as an example to show the effectiveness of this algorithm. The testing distribution system is shown in Figure 7. This feeder has nine load buses with rated voltage 23kV. Table 1 and Table 2 show the loads and feeder line constants. The harmonic current sources are shown in Table 3, which are generated by each customer.

**Figure 7.** Testing distribution system with 9 buses


**Table 1.** Load data of the test system

Enter

Set first harmonic order

Adjust Y-matrix

Calculate Harmonic current source

Next harmonic order

No

Solve V\*Y=I

Is the highest harmonic order considered?

Calculate the harmonic distortion factor

Yes

**Figure 6.** Flow chart of 'Harmonic distortion calculation subprogram' in Figure 4 and Figure 5

In this section, a radial distribution feeder [10] is used as an example to show the effectiveness of this algorithm. The testing distribution system is shown in Figure 7. This feeder has nine load buses with rated voltage 23kV. Table 1 and Table 2 show the loads and feeder line constants. The harmonic current sources are shown in Table 3, which are

123456789

Exit

**6. Numerical example and results** 

Supply source

**Figure 7.** Testing distribution system with 9 buses

generated by each customer.


**Table 2.** Feeder data of the test system


**Table 3.** The harmonic current sources

Kp is selected to be US \$168/MW in equation (9). The minimum and maximum voltages are 0.9 p.u. and 1.0 p.u. respectively. All voltage and power quantities are per-unit values. The base value of voltage and power is 23kV and 100MW respectively. Commercially available SVC sizes are analyzed. Table 4 shows an example of such data provided by a supplier for 23kV distribution feeders. For reactive power compensation, the maximum SVC size Qc(max) should not exceed the reactive load, i.e. 4186 MVAr. SVC sizes and costs are shown in Table 5 by assuming a life expectancy of ten years (the placement, maintenance, and running costs are assumed to be grouped as total cost.)


A PSO Approach in Optimal FACTS Selection with Harmonic Distortion Considerations 75

The improvement of the harmonic distortion is quite attractive and it is clearly shown in Figure 7. The reductions in HDF are 80.49% and 14.29% with respect to Case 1 and Case 2.

The optimal cost and the corresponding SVC sizes, power loss, minimum / maximum voltages, the average CPU time and harmonic distortion factor are also shown in Figure 8.

Voltages in harmonic order

 1 5 7 11 13 17 19 23 25 Vrms HDF Bus x1 x10-2 x10-3 x10-3 X10-3 x10-4 x10-4 x10-4 x10-4 x1 % 1 0.993 4.41 2.96 1.57 1.25 9.60 8.12 7.47 4.72 0.992 5.78 2 0.987 4.43 2.98 1.58 1.26 9.69 8.19 7.53 4.76 0.987 5.85 3 0.963 4.45 2.98 1.58 1.26 9.70 8.18 7.54 4.74 0.963 6.02 4 0.948 4.47 3.00 1.59 1.27 9.76 8.21 7.59 4.75 0.947 6.15 5 0.917 4.23 2.78 1.46 1.18 9.02 7.49 6.98 4.24 0.916 5.95 6 0.907 4.14 2.71 1.41 1.14 8.61 7.14 6.65 4.05 0.907 5.86 7 0.889 4.02 2.61 1.34 1.08 8.11 6.72 6.22 3.79 0.888 5.78 8 0.859 3.80 2.43 1.23 0.98 7.31 6.05 5.57 3.40 0.858 5.60 9 0.838 3.66 2.32 1.15 0.91 6.79 5.61 5.13 3.15 0.837 5.49

**Figure 8.** Effect of harmonic distortion on each bus

**Table 6.** The voltage profile of Case 1


**Table 4.** Available 3-phase SVC sizes and costs

**Table 5.** Possible choice of SVC sizes and costs

The effectiveness of the method is illustrated by a comparative study of the following three cases. Case 1 is without SVC installation and neglected the harmonic. Both Case 2 and 3 use PSO approach for optimizing the size and the placement of the SVC in the radial distribution system. However, Case 2 does not take harmonic into consideration and Case 3 takes harmonic into consideration. The optimal locations of SVCs are selected at bus 4, bus 5 and bus 9.

Before optimization (Case 1), the voltages of bus 7, 8, 9 are violated. The cost function and the maximum HDF are \$132138 and 6.15% respectively. The harmonic distortion level on all buses is higher than 5%.

After optimization (Case 2 and 3), the power losses become 0.007065 p.u. in Case 2 and 0.007036 p.u. in Case 3. Therefore, the power savings will be 0.000747 p.u. in Case 2 and 0.000776 p.u. in Case 3. It can also be seen that Case 3 has more power saving than Case 2.

The voltage profile of Case 2 and 3 are shown in Table 6 and Table 7 respectively. In both cases, all bus voltages are within the limit. The cost savings of Case 2 and Case 3 are \$2,744 (2.091%) and \$1,904 (1.451%) respectively with respect to Case 1. Since harmonic distortion is considered in Case 3, the sizes of SVCs are larger than Case 2 so that the total cost of Case 3 is higher than Case 2.

The maximum HDF of Case 2 of Case 3 are 1.35% and 1.2% respectively. The HDF improvement of Case 3 with respects to Case 1 is

$$\text{HDF improvement }\% = \frac{6.15 - 1.20}{6.15} \times 100 = 80.49\%$$

The HDF improvement of Case 3 with respects to Case 2 is

$$\text{HDF improvement }\% \text{ = } \frac{1.40 - 1.20}{1.40} = 14.29\%$$

The improvement of the harmonic distortion is quite attractive and it is clearly shown in Figure 7. The reductions in HDF are 80.49% and 14.29% with respect to Case 1 and Case 2.

The optimal cost and the corresponding SVC sizes, power loss, minimum / maximum voltages, the average CPU time and harmonic distortion factor are also shown in Figure 8.

**Figure 8.** Effect of harmonic distortion on each bus

74 An Update on Power Quality

and bus 9.

buses is higher than 5%.

3 is higher than Case 2.

improvement of Case 3 with respects to Case 1 is

The HDF improvement of Case 3 with respects to Case 2 is

**Table 4.** Available 3-phase SVC sizes and costs

**Table 5.** Possible choice of SVC sizes and costs

**Size of SVC (MVAr)** 150 300 450 600 900 1200 **Cost of SVC (\$)** 750 975 1140 1320 1650 2040

**j 1 2 3 4 5 6 7 8 9**  *Qcj (MVAr)* 150 300 450 600 750 900 1050 1200 1350 *Kcj (\$ / MVAr)* 0.500 0.350 0.253 0.220 0.276 0.183 0.228 0.170 0.207 **j 10 11 12 13 14 15 16 17 18**  *Qcj (MVAr)* 1500 1650 1800 1950 2100 2250 2400 2550 2700 *Kcj (\$ / MVAr)* 0.201 0.193 0.187 0.211 0.176 0.197 0.170 0.189 0.187 **j 19 20 21 22 23 24 25 26 27**  *Qcj (MVAr)* 2850 3000 3150 3300 3450 3600 3750 3900 4050 *Kcj (\$ / MVAr)* 0.183 0.180 0.195 0.174 0.188 0.170 0.183 0.182 0.179

The effectiveness of the method is illustrated by a comparative study of the following three cases. Case 1 is without SVC installation and neglected the harmonic. Both Case 2 and 3 use PSO approach for optimizing the size and the placement of the SVC in the radial distribution system. However, Case 2 does not take harmonic into consideration and Case 3 takes harmonic into consideration. The optimal locations of SVCs are selected at bus 4, bus 5

Before optimization (Case 1), the voltages of bus 7, 8, 9 are violated. The cost function and the maximum HDF are \$132138 and 6.15% respectively. The harmonic distortion level on all

After optimization (Case 2 and 3), the power losses become 0.007065 p.u. in Case 2 and 0.007036 p.u. in Case 3. Therefore, the power savings will be 0.000747 p.u. in Case 2 and 0.000776 p.u. in Case 3. It can also be seen that Case 3 has more power saving than Case 2. The voltage profile of Case 2 and 3 are shown in Table 6 and Table 7 respectively. In both cases, all bus voltages are within the limit. The cost savings of Case 2 and Case 3 are \$2,744 (2.091%) and \$1,904 (1.451%) respectively with respect to Case 1. Since harmonic distortion is considered in Case 3, the sizes of SVCs are larger than Case 2 so that the total cost of Case

The maximum HDF of Case 2 of Case 3 are 1.35% and 1.2% respectively. The HDF

6.15 *HDF improvement*

 % <sup>40</sup> *HDF improvement*

6.15 1 % .20 100 80.49%

1.

1.40 1.20 14.29%


**Table 6.** The voltage profile of Case 1


A PSO Approach in Optimal FACTS Selection with Harmonic Distortion Considerations 77

This chapter presents a Particle Swarm Optimisation (PSO) approach to searching for optimal shunt SVC location and size with harmonic consideration. The cost or fitness function is constrained by voltage and Harmonic Distortion Factor (HDF). Since PSO is a stochastic approach, performances should be evaluated using statistical value. The performance will be affected by initial condition but PSO can give the optimal solution by increasing the population size. PSO offers robustness by searching for the best solution from a population point of view and avoiding derivatives and using payoff information (objective function). The result shows that PSO method is suitable for discrete value optimization problem such as SVC allocation and the consideration of harmonic distortion limit may be

**7. Conclusion** 

**Nomenclature** 

**Superscript** 

**Author details** 

*Australia* 

H.C. Leung and Dylan D.C. Lu

*The University of Sydney, NSW 2006,* 

*Qc* the size of SVC (MVAr)

*Ks* the SVC bank size (MVAr)

*Vi* voltage magnitude at bus *i* (pu)

*Kc* the equivalent SVC cost (\$/MVAr) *Kl* the duration of the load period

included with an integrated approach in the PSO.

*fmax* the maximum fitness of each generation in the population

*Kp* the equivalent annual cost per unit of power losses (\$/kW)

*Pi, Qi* active and reactive powers injected into network at bus *i* (pu)

*Gij, Bij* mutual conductance and susceptance between bus *i* and bus *j* (pu)

*ij* voltage angle different between bus *i* and bus *j* (rad)

*N* the number of harmonic order is being considered

*yci* frequency admittance of the SVC at bus *i* (pu)

*Pli, Qli* linear active and reactive load at bus *i* (pu) *Pni Qni* nonlinear active and reactive load at bus *i* (pu)

*Gii, Bii* self conductance and susceptance of bus *i* (pu)

*1* corresponds to the fundamental frequency value *n* corresponds to the nth harmonic order value

*Department of Electrical and Information Engineering,* 

**Table 7.** The voltage profile of Case 2


**Table 8.** The voltage profile of Case 3


**Table 9.** Summary results of the approach
