Introduction

Reactive power dispatch constitutes a fundamental component of power system operations, primarily tasked with the regulation of voltage stability and attenuation of line losses1,2,3,4,5. Particularly within distribution systems and microgrids, where the resistance-to-reactance ratio surpasses that of transmission systems, the implementation of localized reactive power compensation holds substantial potential in diminishing power losses and, consequently, operational expenditures6,7,8,9,10. In pursuit of local reactive power provision, numerous scholars have investigated the optimal allocation and operational strategies concerning reactive power compensation devices within distribution systems11,12,13,14,15. The study presented in reference16 introduces a novel slack bus independent loss allocation methodology tailored for the bilateral market setting. Within this framework, the generator assumes responsibility for supplying power to both loads and their accompanying losses, thereby distributing the total load and its associated losses among all generators interconnected within the network. In contrast, reference17 outlines an alternative loss allocation technique wherein generators and loads are depicted as current injections and impedances, respectively. Employing principles derived from circuit theory and the Aumann–Shapley method, this approach offers a refined mechanism for loss allocation18,19,20,21,22. Furthermore, the paper proposes a fresh pricing model applicable to bilateral, pool, and reserve markets, leveraging the optimal power flow (OPF) paradigm23,24,25,26,27.

In reference28, researchers employed an ant colony optimization (ACO) algorithm to optimize the overall cost of electrical energy generated by distribution companies (Discos) and distributed generators (DGs) within the framework of the daily voltage/var control (VVC) problem. Conversely, reference6 presented a novel fuzzy price-based compensation methodology designed to address the daily VVC conundrum in distribution systems amid the presence of DGs. Furthermore, in reference29, a pioneering optimization algorithm centered on a chaotic improved honey bee mating optimization (CIHBMO) approach was implemented. This algorithm facilitates the determination of critical control variables for the subsequent day, encompassing the active and reactive power of DG units, reactive power settings of capacitors, and tap positions of transformers. Similarly, reference30 introduces a fuzzy adaptive chaotic particle swarm optimization (FACPSO) technique to address the multiobjective optimal operation management of distribution networks inclusive of fuel-cell power plants. In31,32,33,34, a methodology for minimizing active power losses and microgeneration shedding was proposed. This approach aims to achieve optimized and coordinated voltage support within distribution networks characterized by significant integration of DGs and microgrids. Finally, in reference35,36,37, an innovative approach combining an analytic hierarchy process (AHP) strategy with a binary ant colony optimization (BACO) algorithm was employed to resolve the multiobjective daily VVC problem encountered in distribution systems. The slime mold algorithm (SMA) is a nature-inspired optimization algorithm inspired by the behavior of slime molds, which are simple organisms capable of complex behaviors such as pathfinding and optimization. This algorithm is particularly useful for solving optimization problems, inspired by the ability of slime molds to find efficient routes in complex environments. In38,39,40,41, a sliding mode algorithm (SMA)) search strategy was proposed for solving the optimal power flow (OPF) and reactive power dispatch problem. The Runge‒Kutta method is a numerical technique used for solving ordinary differential equations (ODEs) and systems of ODEs and was used for analysis and load power flow dispatch in42. HHO is a nature-inspired optimization algorithm in which each potential solution is represented as a bird in a population, and these birds collaborate to find the optimal solution to a given optimization problem. The algorithm simulates the hunting behavior of Harris's hawks, including exploration, exploitation, and communication among individuals.43,44,45 used the HHO method to optimize the reactive and active power flow to stabilize the voltage.

Given the significantly greater share of active power generation costs compared to reactive power generation costs, the attention devoted to the behavior of the latter in the reactive market tends to be relatively diminished. However, in fuzzy references46,47, a model is introduced that aims to simultaneously minimize the total cost associated with active and reactive power generation. This research endeavors to devise a model for optimizing the distribution of reactive power, taking into consideration not only the maintenance of voltage levels within permissible thresholds but also the preservation of voltage stability throughout operational phases48,49,50,51.

In this study, a hybrid approach incorporating the generator cross-section auction model52,53,54,55 and static compensator cost functions is employed. Moreover, the model encompasses the calculation of both the active and reactive power outputs of generators, along with the determination of reactive power levels for compensators and the associated cost of transformer tap changers. It is noteworthy that this methodology assumes constant outcomes in the active market, with considerations also given to the temporal evolution and fluctuation of grid load. Notably, this method neglects the slack bus generator from certain considerations56,57,58. The motivation for using particle swarm optimization (PSO) for reactive power dispatch (RPD) in power systems arises from several factors. Complexity of the Problem: Reactive power dispatch is a complex optimization problem involving nonlinear equations, multiple constraints, and a large solution space. PSO, as a metaheuristic optimization algorithm, offers a robust and efficient way to search through this complex solution space to find near-optimal solutions. Multidimensional Search Space: Reactive power dispatch involves adjusting the settings of various reactive power devices, such as generators, capacitors, and transformers59,60,61,62. The ability of PSO to explore multidimensional search spaces makes it suitable for finding optimal or near-optimal configurations of these devices to improve system performance. Real-Time Application: PSO is known for its computational efficiency, which is crucial for real-time or near-real-time applications in power systems. Reactive power dispatch needs to be performed rapidly to maintain system stability and reliability, and the fast convergence properties of PSO make it suitable for such applications. Adaptability and Tunability: PSO is highly adaptable and adaptable to specific problem characteristics and requirements. This flexibility allows researchers and engineers to customize the PSO algorithm to suit the unique aspects of reactive power dispatch problems, such as incorporating penalty functions or adjusting inertia weights63,64,65,66,67.

The subsequent sections of the paper are structured as follows:

Voltage stability margin index

There is currently a strong economic incentive to utilize the entire capacity of the electricity system68,69,70,71. The independent grid operator must be aware of the stability status and the distance to the edge of grid instability since rising power generation and demand are pushing the system to the point of instability29,30,31,34. It is a valuable indicator for making judgments since it can quantify the distance from the absolute location of the system's instability to the grid operator. The grid load limit index, which can be used as a gauge of the maximum voltage stability margin, is the sole indicator that possesses this property72,73,74,75. The voltage diagram is shown in Fig. 1 as a power diagram, where \(vsm\) denotes the system's loading parameter. This graph demonstrates that even when the system's overall load is increased by a factor of \(vsmP_{0}\), voltage collapse does not occur.

Figure 1
figure 1

Voltage diagram in terms of the power grid load and voltage stability.

Optimal reactive power planning model

This section presents a model that integrates operational reactive power management considerations. Voltage stability, a critical aspect influenced by various factors, including the spatial arrangement and magnitude of active power generation across the grid, the configuration of the distribution system, and the placement of reactive power supply assets40,41,42, is of paramount importance. In light of these multifaceted determinants, this section endeavors to delineate a reactive power distribution system that not only prioritizes voltage stability during operational phases but also ensures the preservation of voltage amplitude within acceptable limits.

Problem objective function

With increasing system load, \(Q_{GENi}\) and \(Q_{SHi}\) in the equation below indicate the reactive energy obtained from the i-th generator and the i-th static compensator, respectively. \(\Delta P_{GEN}^{slack}\) is the additional power obtained from the slack bus generator to increase the load and offset losses, and \(\Delta T_{Ti}\) is the modification to the ith transformer's conversion ratio. \(\gamma_{Ti}\) The cost of reactive electricity generated by the i-th generator is determined by the i-th generator's auction price function and this statement. The cost of acquiring static reactive power compensation for the grid is included in the second expression to the right of this equation, and the cost of changing the taps on transformers is included in the third expression. The final sentence also includes the price of the electricity drawn from the slag bus generator.

$$\begin{aligned}&MinF(Q_{GEN} ,Q_{SH} ,\Delta P_{GEN}^{slack} ,\Delta T) = \sum\limits_{i = 1}^{{N_{GEN} }} {\lambda_{GENi} (} Q_{GENi} ) \hfill \\& \quad + \sum\limits_{i = 1}^{{N_{SH} }} {C_{SHi} (} Q_{SHi} ) + \sum\limits_{i = 1}^{{N_{T} }} {C_{Ti} (} \Delta T_{Ti} ) + C(\Delta P_{GEN}^{slack} ) \hfill \\ \end{aligned}$$
(1)

Equality constraints

The equality of the active and reactive power produced with consumption is one of these restrictions. In this instance, it is presumable that generators are the only source of the necessary reactive power. Both the zero voltage angle of the slack bus and the stability of the voltage size of the bus with the generator are considered equal constraints. The active power equalization limits only consider the active power produced by the slack bus generator when the system experiences a rapid increase in load during operation. The reactive power equalizer restrictions also include static compensators in addition to generators. In this case, the stability of the active power produced by the generators, with the exception of the slack bus generator, is regarded as an equality requirement.

Inequality constraints

Static compensators, generator output power, and reactive power generation or absorption capacity are used as inequality restrictions. The permitted range of changes in the transformer Tap, the temperature limit of the transmission lines, and the size and angle of the bus voltage are further inequality restrictions. The reactive power auction for a generator's entire curve is shown in Fig. 2. Figure \(\gamma_{GENi}\) shows the reactive power obtained from the i-th generator cost.

Figure 2
figure 2

Generic generator auction curve for reactive power.

A generator's maximum reactive power output is determined by the quantity of active power generation, following its operating capability curve. Taking the Slack Bass generator used in this project as an example, the auction function is as follows:

$$\gamma_{GEN2}(Q_{GEN2} ) = \left\{ {\begin{array}{*{20}c} { - 1.5Q_{GEN2} - 0.2} & { - 0.2 \le Q_{GEN2} < 0.12} \\ {1.6} & {0 \le Q_{GEN2} < 0.3} \\ 1 & {0.3 \le Q_{GEN2} < 0.5} \\ {8Q_{GEN2} - 2.2} & { - 0.2 \le Q_{GEN2} < 0.12} \\ \end{array} } \right.$$
(2)

The price per megawatt of production is calculated at $15, with the cost of creating reactive power for static compensators being considered to be fixed. Moreover, the price per unit to replace the transformer's tap is $15. This system has 12 transformers with tap changers, 4 reactive power compensators installed in buses 4, 8, 15, and 27, and 10 generators. The term “slack bus generator” is used to describe the generator linked to bus 31 (see Fig. 3).

Figure 3
figure 3

IEEE 39-bus system.

This section presents the results obtained from computations conducted using MATLAB software tools. The outcomes of optimization utilizing the Particle Swarm Optimization (PSO) algorithm will be discussed in a subsequent section, accompanied by a comparative analysis against existing methodologies. The analysis commences with the allocation of active power over a specific time period. Initially, generators constitute the sole source of reactive power required for the system. Subsequently, a scenario in which there is an unexpected increase in the total active power demand by a factor of ζ = 0.01 following the optimal allocation of active power to the grid's top is considered. In response to this situation, a decrease in bus voltages is observed, necessitating the provision of reactive power to rectify the voltage reduction. Furthermore, it is assumed that the active power output of the generators, excluding the slack bus generator, remains constant.

Following the resolution of the model, the following conclusions are drawn for both scenarios. The active and reactive power allocations for the generators are detailed in Table 1, while Table 2 presents the reactive power ratings for the static compensators. The transformer tap changer specifications are provided in Table 3, and the quantities and voltage angles of the buses are tabulated in Table 4. Additionally, Table 5 delineates the associated expenditures for each state, along with the supplementary costs incurred in the second state.

Table 1 Active and reactive power allocated for generators.
Table 2 Assigned reactive power of the static compensators.
Table 3 Changeer transformers.
Table 4 Amount and voltage angle of the buses.
Table 5 The related costs of each state as well as the additional costs incurred in the second state.

Using particle swarm optimization to solve the second mode optimization

This paper initially introduces the proposed methodology employed herein, followed by an elucidation of the Particle Swarm Optimization (PSO) technique. The PSO method, an optimization approach inspired by simulated animal behavior, originated in the 1990s. Specifically, Eberhart and Kennedy pioneered a technique for PSO based on behavioral analogies observed in fish and birds. A notable characteristic of this method is its capacity to operate based on relatively simplistic rules.

The underlying principle of the PSO technique revolves around the concept that individuals base their decisions on two types of information: personal experiences and observations of others' experiences. Individuals explore various options to discern their relative superiority and desirability, drawing upon their own past encounters. Additionally, they also consider the behaviors and outcomes of those in their proximity, leveraging external experiences to inform their decision-making process. Therefore, using the following information, each particle strives to enhance its position:

  • Vector of the current position

  • Current velocity vector

  • The distance between the current position and the most advantageous position encountered

  • The separation between the present position and the particle swarm's optimal position

The following equations can be used to formulate position adjustment, in accordance with the aforementioned sentences:

$$\begin{aligned} V_{i}^{N + 1} &= MV_{i}^{N} + J_{1} rand_{1} \times (pbest_{i} - Z_{i}^{N} ) \hfill \\ & \quad + J_{2} rand_{2} \times (gbest - Z_{i}^{N} ) \hfill \\ \end{aligned}$$
(3)

and

$$M = M_{\max } - \frac{{M_{\max } -M_{\min } }}{{iter_{\max } }} \times iter$$
(4)
$$Z_{i}^{N + 1} = Z_{i}^{N} + V_{i}^{N + 1}$$
(5)

where \(z_{i}^{N}\) is the current position of the i-th particle in the k-th iteration, \(pbest_{i}\) is the best position the i-th part has ever experienced, and gbest is the best experienced position of the particle swarm. \(V_{i}^{N}\) is the velocity vector of the i-th particle in the k-iteration, w is the weighting function, \(J_{j}\) is the weighting coefficient, and rand is the random vector of particle i between zero and one. Additionally, \(M_{\max }\) and \(M_{\min }\) are the highest and lowest weights, respectively, \(iter_{\max }\) is the number of repetitions, and \(iter\) is the current repetition.

Experience has demonstrated that the following values \(M_{\min } = 0.4\) and \(\begin{array}{*{20}c} {M_{\max } = 0.4} & {J_{j} } \\ \end{array} = 2\) for these parameters are appropriate for power system issues. The main advantages of this technique are shown in Fig. 4:

Figure 4
figure 4

General process of particle swarm optimization.

This research proposes an approach that surpasses customary methods in both accuracy and speed. Specifically, if a particle's current position in each iteration proves to be inferior to its best-experienced position, an adjustment is made to its velocity vector. This adjustment aims to propel the particle's future position away from its current location, thereby averting movement toward unfavorable conditions in subsequent cycles. This adjustment is mathematically expressed as follows:

$$\begin{aligned} V_{i}^{N + 1} &= MV_{i}^{N} + J_{1} rand_{1} \times (pbest_{i} - Z_{i}^{N} ) \hfill \\&\quad + J_{2} rand_{2} \times (gbest - Z_{i}^{N} ) + J_{3} rand_{3} \times (Z_{i}^{N} - pworse_{i} ) \hfill \\ \end{aligned}$$
(6)

where \(pworse_{i}\) is the place prior to the I particle that has poor experience. To address the optimal distribution of reactive power during operation, it is essential to define the variable vector for each particle. The grid under consideration encompasses 39 buses and 12 transformers equipped with tap changers, resulting in a total of 90 entries for each particle's variable vector. Specifically, the first 39 entries pertain to the bus voltage magnitude, the subsequent 39 entries correspond to the bus voltage phase angle, and the final 12 entries are associated with the tap settings of the transformers.

In this optimization strategy, 200 particles were employed, and 100 iterations were conducted to ensure convergence. The optimization outcomes achieved through this method are illustrated in Fig. 5, which also displays the power generated by generators before and after a significant increase in load. The transformer tap changer settings are provided in Table 6, while Table 7 outlines the allocated reactive power for the static compensators. Tables 8 and 9 present the quantities and voltage angles of the buses. Furthermore, Table 10 provides details on the expenditures associated with each mode, including the additional costs incurred in the second mode.

Figure 5
figure 5

Amount of objective function (additional cost in dollars) during 100 repetitions.

Table 6 Amount of active and reactive power generated by generators before and after sudden increase in load.
Table 7 Changeer transformers.
Table 8 Assigned reactive power of the static compensators.
Table 9 Amount and voltage angle of buses.
Table 10 Costs corresponding to each mode and additional costs imposed in the second mode.

The active generating power of generators using two optimization techniques is compared in Fig. 6. In Fig. 7, two approaches to maximizing the reactive power produced by generators are compared. Figure 8 An unexpected increase in the load's additional cost using two different techniques.

Figure 6
figure 6

Comparison of two optimization techniques in terms of the active generating power of generators.

Figure 7
figure 7

Comparison of two methods for optimizing the reactive power generated by generators.

Figure 8
figure 8

The additional cost of a sudden increase in load in the two methods.

Conclusions and discussion

Reactive power plays crucial roles in power system reliability and security. Market participants utilize the network differently to maximize their profits. This means that their effects on the system, such as losses, can also be different. The development of a fair and accurate loss allocation scheme for real and reactive power is important for avoiding cross subsidies and obtaining the correct charge for each participant. To minimize costs, this paper introduces a model for the optimal allocation of reactive power. Technically, this model utilizes the voltage stability margin as a safeguard for operational safety and ensures the attainment of maximum active power contracts in the market from an economic standpoint. Reactive power provision is regarded as an additional service within this framework. The efficacy of the proposed model has been evaluated using the 39-bus IEEE system, and simulation results employing the particle swarm optimization algorithm showcase its ability to achieve optimal reactive power allocation during operation, notwithstanding the constraints of the market environment.