1 Introduction

Capacitors have been considered as crucial components in distribution systems. Capacitors, when they are optimally allocated, reduce power losses, correct the power factor, improve the voltage profile, and release system capacity [1,2,3,4]. These units also supply reactive powers locally at their connection points, and so, they strengthen the system against reactive power shortages [5, 6]. These sources of reactive power also reduce the operational stress on the traditional voltage control devices, e.g., on-load tap changer transformers (OLTC) and step voltage regulators (SVR), in which their managing systems are mechanical based [7, 8]. Furthermore, they can also release the spare capacity of the interfacing inverter of particular renewable energy sources, thereby reducing their active power curtailments [9,10,11]. Besides, capacitors require lower initial and operational costs compared with other effective voltage control devices.

It is a fact that allocating several capacitors at improper locations with erroneous sizes could worsen the performance of distribution systems. Indeed, the problem of capacitor allocation means determining the best combination of locations for installing capacitors with their optimal capacities so that their benefits are maximized. In addition, the number of capacitors is a critical variable that needs to be optimally calculated. This optimization problem has combinatorial nature where several continuous and discrete variables are required to be solved [12,13,14]. For such nature, exhaustive search methods are not helpful considering their computational burden, especially with a high number of capacitors to be allocated.

Several methods in the literature have been proposed for allocating capacitors in distribution systems. These methods can be classified as numerical-based (NB), heuristic-based (HB), artificial intelligent-based (AIB) methods, and analytical-based (AB) methods [15, 16]. Dynamic programming (DP) [17], mixed integer programming (MIP) [18], linear programming (LP) [19], and comprehensive mixed integer linear programming model (MILP) [20] are examples for NB methods. HB methods, such as evolutionary algorithm (EA) [21], two-stage heuristic method (TSHM) [22], teaching learning-based optimization (TLBO) [23], and search algorithm (SA) [24], develop rules of thumb that reduce the search space. Regarding AIB methods, the most popular examples are genetic algorithms (GA) [25], fuzzy GA [26], particle swarm optimization (PSO) [27], improved harmony algorithm (IHA) [28], flower pollination algorithm (FPA) [29], ant colony optimization algorithm [30], and non-dominated sorting genetic algorithm [31]. AB methods involve employing analytical formulations for maximizing the benefits of capacitors, such as in [32,33,34].

As illustrated in the aforementioned literature review, various research studies have been focused on the optimal allocation of capacitors in distribution systems. Due to the stochastic nature of NB, HB, and AIB methods, the global optimal solutions are not guaranteed where the solutions often stuck in local minima. In turn, AB methods could have more reliable and accurate solutions, whereas complex unified models are a must. However, most of the existing AB methods simplify the allocation problem by adopting some assumptions, e.g., priority list of potential locations of capacitors, uniform loading, and/or ignoring the cost of capacitors. Besides, other AB methods determine the optimal locations of capacitors by a sequential manner that can lead to a sub-optimal solution. To fill this gap in the literature review, this work has been directed proposed an efficient AB method by introducing efficient analytical closed-form expressions.

In this paper, a novel AB method is proposed for directly solving the optimal allocation of multiple capacitors for minimizing the total cost, i.e., the costs of capacitors and losses. The proposed method is based on efficient analytical closed-form expressions which requires the power flow results only for the base case for solving the allocation problem. Two analytical expressions are driven for the optimal capacitor sizing and the selection of the optimal combination of locations. By utilizing these expressions, a solution process for determining the optimal number, locations, and sizes of multiple capacitors is introduced. The most distinguishing feature of the proposed method is that the global optimal point of the optimization problem can be accurately determined. This feature is accomplished since all possible combinations of capacitor locations are evaluated, thanks to the proposed direct analytical expressions and the unified mathematical model for multiple capacitors.

2 Proposed approach

The cost function (CF) of the capacitor allocation problem is firstly presented in this section. Second, we propose an analytical expression for directly calculating cost reduction (CR) with capacitors. Then, an analytical expression is proposed for the optimal sizing of capacitors. The solution process of the proposed approach is given in the last subsection.

2.1 CR formulation

The objective function of the allocation problem is to minimize CF that involves the cost of capacitors and losses. If we consider allocating \(N_\mathrm{c}\) capacitors to specified set of locations {\({c_1\ldots c_n}\)}, donated by \(\varOmega _c\), in a power distribution system, the CF formula can be expressed as follows:

$$\begin{aligned} \mathrm{CF}=K_pP_\mathrm{Loss}T+N_\mathrm{c}K_\mathrm{Ins}+\sum _{i\in \varOmega _c} K_{ci} Q_{ci} \end{aligned}$$
(1)

in which

$$\begin{aligned} P_\mathrm{Loss}=\sum _{j\in \varOmega _b} \frac{r_j}{v_j^{2}}\left( P_{\mathrm{In}_j}^{2}+Q_{\mathrm{In}_j}^{2}\right) \end{aligned}$$
(2)

where \(P_\mathrm{Loss}\) is the total real power losses (kW); \(\varOmega _b=\{ {b_1\ldots b_n} \}\) is the set of receiving buses for all lines in the system; \(P_{\mathrm{In}_j} and Q_{\mathrm{In}_j}\) are the incoming active and reactive powers at bus j, respectively; \(v_j\) is the voltage amplitude; \(r_j\) is the line resistance; \(Q_{ci}\) is the capacitor size (kvar) at bus i; \(K_p\) is the cost per unit losses ($/kWh); \(K_{ci}\) is the cost per kvar production of the capacitor at bus i; \(K_\mathrm{Ins}\) is the installation cost for each capacitor; and T is the number of hours.

2.2 Analytical expression for CR

Fig. 1
figure 1

The power flow through the distribution lines of a 5-bus system: a the base case, b with installing two capacitors

An analytical expression is proposed here to directly compute CR after installing multiple capacitors at specified set of locations in a distribution system. Normally, in passive distribution systems, the active and reactive powers flow in one direction from slack bus to load buses, as shown in Fig. 1a, where a 5-bus system is considered. However, if two capacitors are installed at buses 2 and 4 (Fig. 1b), the reactive power flow through some lines will be influenced by their reactive power injections. This injected reactive power for each capacitor will affect only the power flow through its upstream lines. For example in Fig. 1b, all lines are affected by \(Q_{c4}\), while only lines 1 and 2 will be affected by \(Q_{c2}\). This implies that the impact of a capacitor on the system lines varies depending on its location (i.e., bus). On other words, for each capacitor, there are some lines whose reactive power flows are affected by. CF at the base case, i.e., without capacitors \((\mathrm{CF}_{wo/c})\), can be written as follows:

$$\begin{aligned} \mathrm{CF}_{wo/c}=K_pT\sum _{j\in \varOmega _b} \frac{r_j}{v_j^{2}}\left( P_{\mathrm{In}_j}^{2}+Q_{\mathrm{In}_j}^{2}\right) \end{aligned}$$
(3)

CF with considering capacitors \((\mathrm{CF}_{w/c})\) can be written as:

$$\begin{aligned} \begin{aligned} \mathrm{CF}_{w/c}&=K_pT\sum _{j\varepsilon \varOmega _b} \frac{r_j}{v_j^{2}} \left( P_{\mathrm{In}_j}^{2}+\left( Q_{\mathrm{In}_j}-\sum _{i\in \varOmega _c} M_{i,j}Q_{ci}\right) ^{2}\right) \\&+N_\mathrm{c}K_\mathrm{Ins}+\sum _{i\in \varOmega _c} K_{ci} Q_{ci} \end{aligned} \end{aligned}$$
(4)

where \(M_{i,j}\) is equal to 1 if bus j belongs to upstream buses of the capacitor bus i; otherwise, it is 0. Note that Eq. (3) formulates the active loss which is a function of line resistance, but the complete line model is considered in this work. This full line mode is required to calculate the bus voltage (\(v_j\)). The analytical expression for calculating CR can be formulated as in (5) with considering (3) and (4):

$$\begin{aligned} \mathrm{CR}&=\mathrm{CF}_{wo/c}-\mathrm{CF}_{w/c} \nonumber \\&=K_pT\left( \sum _{j\in \varOmega _b} \frac{r_j}{v_j^{2}}(2Q_{\mathrm{In}_j} \sum _{i\in \varOmega _c}M_{i,j}Q_{ci}-\sum _{i\in \varOmega _c}M_{i,j}Q_{ci}^2)\right) \nonumber \\&\quad -N_\mathrm{c}K_\mathrm{Ins}-\sum _{i\in \varOmega _c} K_{ci} Q_{ci} \end{aligned}$$
(5)

Here, a simple example of generating the matrix M is described. Consider the distribution system given in Fig. 1 in which two capacitors are required to place optimally. For this case, six possible combinations of capacitor locations are available, where the M matrix can be formulated as follows:

The above analytical expressions can be employed for directly evaluating the benefit of installing a group of capacitors to specified locations in terms of minimizing the total cost, i.e., maximizing CR, without requiring iterative power flow analysis.

2.3 Analytical closed-form expression for optimal sizing of capacitors

This subsection aims at formulating an analytical expression for the optimal sizing of multiple capacitors in distribution systems. Consider a group of capacitors are connected to a system, while the resultant reduction in the total cost can be expressed by (5). It is a fact that the first derivatives of this equation with respect to the sizes of capacitors are equal to zero at the optimal solution. For a capacitor that is located at bus m, the following derivative equation is satisfied:

$$\begin{aligned}&\frac{\partial \mathrm{CR}}{\partial Q_{cm}}=2K_pT\sum _{j\in \varOmega _b} \frac{r_j}{v_j^2}M_{m,j} \left( Q_{\mathrm{In}_j}-\sum _{i\in \varOmega _c}M_{i,j}Q_{ci}\right) \nonumber \\&\quad -K_{cm}=0 ,\quad \forall m \in \varOmega _c \end{aligned}$$
(6)

Equation (6) can be rewritten as follows:

$$\begin{aligned}&\sum _{j\in \varOmega _b}\sum _{i\in \varOmega _c} \frac{r_j}{v_j^2}M_{m,j}M_{i,j}Q_{ci} =\sum _{j\in \varOmega _b} \frac{r_j}{v_j^2}M_{m,j}(Q_{\mathrm{In}_j})\nonumber \\&\quad -2K_pT/K_{cm} ,\quad \forall m \in \varOmega _c \end{aligned}$$
(7)

It is important to note that the number of derivative equations is equal to number of capacitors in \(\varOmega _c=\) {\({c_1\ldots c_n}\)}. These equations can be arranged in the following linear matrix form:

$$\begin{aligned} {[}\mathbf {Q_{c}}]_{N_\mathrm{c}\times 1} =[\mathbf {A}]^{-1}_{N_\mathrm{c}\times N_\mathrm{c}}[\mathbf {B}] _{1\times N_\mathrm{c}} \end{aligned}$$
(8)

in which

$$\begin{aligned} \mathbf {Q}_c&= \begin{bmatrix} Q_{c_1}\\ \vdots \\ Q_{c_{n-1}}\\ Q_{c_n}\\ \end{bmatrix} \\ \mathbf {A}&= \begin{bmatrix} \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_1},j}M_{{c_1},j} &{} \dots &{} \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_1},j}M_{{c_{n-1}},j} &{} \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_1},j}M_{{c_n},j}\\ \vdots &{} \ddots &{} \vdots &{} \vdots \\ \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_{n-1}},j}M_{{c_1},j} &{} \dots &{} \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_{n-1}},j}M_{{c_{n-1}},j} &{} \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_{n-1}},j}M_{{c_n},j} \\ \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_n},j}M_{{c_1},j}&{} \dots &{} \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_n},j}M_{{c_{n-1}},j} &{} \sum _{j\in \varOmega _b}\frac{r_j}{v_j^2}M_{{c_n},j}M_{{c_n},j}\\ \end{bmatrix} \\ \mathbf {B}&= \begin{bmatrix} \sum _{j\in \varOmega _b} \frac{r_j}{v_j^2}M_{{c_1},j}Q_{\mathrm{In}_j}-2K_pT/K_{c,{c_1}}\\ \vdots \\ \sum _{j\in \varOmega _b} \frac{r_j}{v_j^2}M_{{c_{n-1}},j}Q_{\mathrm{In}_j}-2K_pT/K_{c,{c_{n-1}}} \\ \sum _{j\in \varOmega _b} \frac{r_j}{v_j^2}M_{{c_n},j}Q_{\mathrm{In}_j}-2K_pT/K_{c,{c_n}} &{} \end{bmatrix} \end{aligned}$$

Equation (8) represents a novel analytical expression that directly calculates the optimal sizes of multiple capacitors (Q\(_{c})\) so that the CR value is maximum. Unlike the expressions that utilize sensitivity factors or optimize each capacitor individually, the proposed analytical expressions provides a unified mathematical model for multiple capacitors in distribution systems. Besides the light computational burden of the analytical expressions, this novel formulation has several other benefits, such as improving accuracy rate as it allows the assessment of all possible combinations of all sites for capacitors and enabling further planning options of the capacitor allocation. The proposed approach focuses on maximizing the benefits by reducing total cost (CF) expressed by (1) and (2) and maximizing the cost reduction (CR) formulated by (5). It is a fact that voltage quality is not considered in this approach. However, in the proposed approach, we follow a procedure that the voltage quality is attained after installing the capacitors by controlling the reactive power of capacitors by an adopted control scheme.

2.4 Proposed solution process

By employing the proposed analytical expressions, an efficient analytical method is developed to accurately determine the optimal number, locations, and sizes of capacitors. The base power flow results are obtained by a forward/backward sweep method given in [35] considering complete distribution line parameters as well as active and reactive load power. The optimal sizes of capacitors are calculated by (8) for all possible combinations of valid locations for capacitors. The number of these combinations \((N_\mathrm{com})\) is based on number of required capacitors to be allocated and number of valid locations, which mathematically is equal to \(^{N_{b}}{}{{P}}^{}_{N_\mathrm{c}}\) combinations. Having the calculated optimal sizes of capacitors for all possible combinations of locations, the next step is to choose the optimal combination among them. This optimal combination can be assigned with using the proposed analytical expression in (5). This analytical expression is used for evaluating all the combinations in terms of the CR values, thereby finding the optimal combination. As the proposed mathematical formulations are general, the proposed method can be directed to solve any of the following capacitor allocation cases:

  • Case 1: Determining the optimal locations of \(N_\mathrm{c}\) capacitors while their sizes are specified.

  • Case 2: Determining optimal locations and sizing of \(N_\mathrm{c}\) capacitors.

  • Case 3: Determining the optimal number and locations of capacitors while their sizes are specified.

  • Case 4: Determining optimal number, locations, and sizes of capacitors.

Fig. 2
figure 2

Flowchart of the proposed approach

Figure 2 shows a flowchart of the proposed method with considering the aforementioned four cases. Note that the shaded blocks in this figure represent two subroutines described in Fig. 3. The first subroutine (optimal capacitor sizing) aims at calculating the optimal sizes of capacitors (from \(\textcircled 1\) to \(\textcircled 2\)). The second subroutine (CR evaluation) estimates CR values for all combinations and gets the optimal combination (from \(\textcircled 3\) to \(\textcircled 4)\). For Cases 1 and 2, these subroutines are solved once. However, for the other two cases, these subroutines are repeated according to the acceptable range for the number of capacitors (\(N_\mathrm{c}^{\mathrm{max}}<N_\mathrm{c}<N_\mathrm{c}^{\mathrm{min}}\)). The process of optimal capacitor numbering starts with allocating \(N_\mathrm{c}^{\mathrm{min}}\) capacitors, as shown in Fig. 2. The stopping criteria of this process are satisfied if \({\mathrm{CR}_{N_\mathrm{c}} <= \mathrm{CR}_{N_\mathrm{c}-1}}\) or \(N_\mathrm{c}=N_\mathrm{c}^{\mathrm{max}}\). In this paper, we will focus on testing Case 4 in which all of the three variables (capacitor number, locations, and sizes) are required to be optimally computed. It is important to note that the proposed method provides a direct optimal solution for all the cases with using the power flow results of the base case. The proposed mathematical formulation is general, and therefore, it facilitates any extension raised by power utilities or system operators/planners with respect to the integration of capacitors.

The proposed approach has been formulated based on the radial structure of distribution systems, and so, it is valid for radial distribution systems. However, the proposed method can be extended for meshed distribution systems. Such extension can be accomplished by the following steps: (1) Run the base power flow analysis of the meshed distribution system under study, (2) break all the loops in the distribution system, and (3) solve the capacitor allocation problem for resulting radial distribution system using the proposed method.

Fig. 3
figure 3

Subroutines in Fig. 2: a optimal capacitor sizing, b CR evaluation

3 Results and analysis

The proposed method is applied on the 69-bus distribution system, which is widely used as a test system for installing capacitors. Figure 4 shows the test system where its data that involve complete distribution line parameters and active and reactive load power are given in [18]. Bus 1 is the slack bus, while all other buses are valid for capacitor installation. In the simulation results, the parameters of CF are set as follows: \(K_p = 0.06\)$/kW, \(K_{ci} = 300\) $/year for each i location, \(K_\mathrm{Ins}=1000\)$ for each location, and \(T = 8760\) [29]. The annual total cost of the test system at the base case \((\mathrm{CF}_wo/c)\) is 118,260$. The proposed method has been implemented in C++ programming environment. In the following subsections, the proposed method is validated with an exact search method that exhaustively determines the optimal solution. The proposed method is also compared with existing methods to demonstrate its effectiveness.

Fig. 4
figure 4

The 69-bus distribution test system

3.1 Validation of the proposed method

Here, we validate the accuracy of the proposed closed-form expressions for the optimal allocation of multiple capacitors in distribution systems. For this purpose, the proposed method is applied for installing one, two, and three capacitors (assuming one unit per location) in the test system. To validate the accuracy of the proposed method, the calculated results are compared with the accurate results calculated by a repetitive power flow tool. This tool involves running the backward/forward sweep power flow method for all possible combinations of capacitor sizes, which needs excessive computational efforts. Figure 5 shows the calculated optimal sizes of capacitors for all combinations of valid locations, and the corresponding exact total cost (computed by the power flow tool) and estimated total cost (computed directly by (5)) are given in Fig. 6. It is important to mention that the data in Fig. 6 are viewed after rearranging the exact total cost in descending order, i.e., from the highest to the lowest values. Note that the computed optimal sizes of capacitors have different values for each combination of locations, as shown in Fig. 5. This variation verifies the importance of the proposed method to solve to determine the optimal locations and sizes of capacitors. To show the accuracy of the proposed method, the exact total costs, estimated total costs, and the estimated CR for all location combinations for the 69-bus system with single capacitor, two capacitors, and three capacitors are compared in Fig. 6. It is obvious that the exact total cost and the estimated total cost have their minimum values at the same combination of capacitor locations in which the estimated CR is the highest, as illustrated in Fig. 6. Subsequently, the proposed estimated formula for CR evaluation is efficient for assigning the optimal set of locations for capacitors without requiring iterative processes or complex optimization algorithms.

Fig. 5
figure 5

Computed optimal capacitor sizes at all possible combinations of locations for the 69-bus system: a single capacitor, b two capacitors, and c three capacitors

Fig. 6
figure 6

Exact total costs, estimated total costs, and estimated CR for all location combinations for the 69-bus system: a single capacitor, b two capacitors, and c three capacitors

3.2 Optimal number, locations, and sizes of capacitors

In this subsection, we demonstrate the efficiency of the proposed method for determining the optimal number, locations, and sizes of capacitors so as to minimize the total costs. Specifically, the proposed method is applied to solve the capacitor allocation problem with considering a maximum capacitor number of 5. The calculated results for different numbers of capacitor are tabulated in Table 1. In general, the total costs with the all capacitor numbers are greatly reduced compared with that of the base case. For example, the total costs for 1, 2, 3, 4, 5 capacitors are 84,803, 83,706, 84,480, 85,463, 86,274$/year, respectively, which are much lower than of the base case (118,260$/year). The costs of capacitors, the cost of losses, and the total costs are normalized with respect to the total cost in the base case, and their variations are plotted against the number of capacitors (Fig. 7). It can be noticed that curves of capacitor and loss costs are contradictory in nature; therefore, ignoring any of them can lead to improper installation of these units, as shown in Fig. 7a. Figure 7b shows the total system cost which has a U-shape pattern . In other words, the total cost is initially reduced till a certain optimal capacitor size at which the total cost is increased. As shown in the figure, the optimal number is two capacitors, whereas the total cost is reduced to be only 83,706$/year. This trend demonstrates that increasing the number of capacitors cannot guarantee lower costs. For this reason, determining the optimal number, locations, and capacities of capacitors in a simultaneous manner as accomplished by the proposed method can yield economic benefits, i.e., minimum costs.

3.3 Optimal capacitor allocation with predefined sizes

Here, we simulate Case 3 which is described in Sect. 2.4 in which the optimal number and locations of capacitors are required to be determined, while their capacities are predefined. This analysis shows the flexibility of the proposed method which can be adopted by system operators and planners of utilities to quantify the feasible benefits for the allocation problem based on available capacitors. For this purpose, the proposed method is employed to solve the capacitor allocation problem with 1, 2, 3, 4, 5 capacitor numbers, and 300, 400, 500, 600, 700, and 800 kvar. In other words, 30 different capacitor allocation scenarios are simulated. Table 2 shows the determined optimal locations of capacitors with different numbers and predefined capacities by the proposed method. As shown, the optimal set of locations vary significantly among the capacitor allocation scenarios. In Fig. 8, active losses and total costs with different capacitor numbers and capacities for the 69-bus system are plotted. Regarding the active losses (Fig. 8a), their values initially decrease with the number of capacitors and their capacities, but they raise at certain capacitor numbers which can be considered optimal numbers with respect to the losses. However, the figures are different with the total costs shown in Fig. 8b. For each capacitor capacity, the total cost follows the U-shape where the optimal capacitor numbers decrease with the capacitor capacity. For instance, the optimal number of capacitors is 4, 4, 3, 3, 2, 2, and 2 with capacitor sizes of 300, 400, 500, 600, 700, and 800 kvar, respectively. Among the 30 capacitor allocation scenarios, the lowest losses and costs are attained by allocating three capacitors with 600 kvar, as shown in Fig. 8.

Table 1 Results for the capacitor allocation problem with different capacitor numbers
Fig. 7
figure 7

Variation in the costs against the number of capacitors: a normalized costs of capacitors and losses, b normalized total cost

Table 2 Optimal locations of capacitors with different numbers and predefined capacities
Fig. 8
figure 8

Active losses and total costs with different capacitor numbers and capacities for the 69-bus system: a active losses and b total costs

Fig. 9
figure 9

The percentage of CR and LR for different methods

3.4 Comparison with existing methods

The proposed method is compared with eight different existing methods given in the literature. The CR and loss reduction (LR) are compared for the different methods in Fig. 9. For the proposed method, two and three capacitors are considered in this comparison. The highest values of CR can be achieved with the proposed method (e.g., 29.2% with two capacitors and 28.65% with three capacitors). The corresponding LR values are also relatively high compared with most of the existing methods. We can note the preeminence of the proposed method compared to the existing methods. This positive feature of the proposed method is accomplished since all possible combinations of capacitor locations can be evaluated, thanks to the proposed closed-form expressions and the unified mathematical model for multiple capacitors while considering both the capacitor cost and losses.

4 Conclusions

This paper has proposed an analytical approach to determine the optimal number, locations, and sizes of capacitors in distribution systems to maximize CR. Novel analytical closed-form expressions are presented for directly allocating capacitors without requiring iterative processes. These analytical expressions can be employed for accurately solving the capacitor allocation problem. The results show that the proposed approach is accurate with respect to the exact solutions computed by exact search-based methods and efficient compared with existing methods. As the proposed approach is direct, it is considered a simple, practical, and efficient tool for allocating capacitors and even evaluating their positive impacts on the distribution systems. In the future, the proposed analytical expressions will be extended for considering load variations and distributed generations in distribution systems.