Optimal Power Flow Technique for Distribution System Considering Distributed Energy Resources (DER)

: Modern electric power systems consist of large-scale, highly complex interconnected systems projected to match the intense demand growth for electrical energy. This involves the decision of generation, transmission, and distribution of resources at different time horizons. They also face challenges in incorporating new forms of generation, distributed generations, which are located close to consumer centers, and new loads such as electric vehicles. Traditionally, the nonlinear Newton–Raphson optimization method is used to support operational decisions in such systems, known as Optimal Power Flow (OPF). Although OPF is one of the most practically important and well-researched sub-ﬁelds of constrained nonlinear optimization and has a rich history of research, it faces the convergence difﬁculties associated with all problems represented using non-linear power ﬂow constraints. The proposal is to present an approach in a software component in cloud Application Programming Interface (API) format, with alternative modeling of the electrical optimization problem as a non-linear objective function and representing electric network constraints modeled through both current and voltage Kirchhoff linear equations. This representation overcomes the non-linearity of the OPF problem considering Distributed Energy Resources (DER). The robustness, scalability, and availability of the method are tested on the IEEE-34 bus system with several modiﬁcations to accommodate the DER testing under conditions and in radial or meshed distribution systems under different load scenarios.


Introduction
Real power systems' decision problems are inserted in a complex and large-scale context with many associated challenges. The challenge involves the coordination of the availability of diverse components and control equipment connected to meet the demand needs across the electrical network. More recently, the inclusion of renewable energy generation sources, such as wind and solar, that are greatly associated with uncertainties, increase the complexity and competition in the electricity market, and the importance of adequately managing available resources [1,2]. A second challenge, associated with power systems decision problems, is related to responding to the market needs quickly and adequately in an unpredictable environment [3,4]. The third challenge is to determine an adequate computational environment for analyzing these power systems, considering Distributed Energy Resources (DER) [5][6][7][8][9]. A proposal for this computational environment will be detailed in section three.
To meet these challenges, the development of an efficient computational model for analysing DER systems is required. The model must be able to analyze the impact of different policies on demand attainment within a specified time horizon. Once there is a different degree of uncertainty associated with the system parameters that support decisions at distinct time horizons, it is necessary to analyze specific scenarios for each time horizon. Long-term power systems analysis is a large dimension problem associated with a model of great dimension and great uncertainty requiring the consideration of these special characteristics [10]. On the other side, models for short-term decisions must consider the systems under study in greater detail, with their variables and parameters associated with a high degree of certainty. Briefly, longer-term decisions require a large model to represent the entire system, with variables and parameters associated with greater uncertainty, while models for short-term decisions have smaller dimensions, representing a specific part of the system, and assuming its parameters are perfectly known. Then, a single model is not capable of solving the whole problem, since different degrees of representation are necessary. The corridor of possible solutions is narrow in the short term, where the uncertainties are smaller, and wide in the long term where the uncertainties are greater. Scenario 1 is the pessimist in the short term and optimist in the long term, while scenario 3 is the optimist in the short term and pessimist in the long-term horizons, as shown in Figure 1. Several studies have been carried out to find solutions that increase the operational efficiency of these systems. According to [11], earlier studies used the Newton-Raphson(NR) method for transmission systems. These techniques exhibit good convergence characteristics for well-conditioned transmission systems, but do not offer the same performance for distribution systems, as discussed in the literature [12,13]. These techniques often fail to converge when distribution systems become more heavily loaded and unbalanced. Furthermore, the high R/X ratio characteristic of the distribution systems deteriorates the dominance of the NR diagonal Jacobian matrix and fast decoupled techniques.
To overcome the heavy computational complexity of NR methods and the nonconvergence limitations for distribution systems, recent studies have indicated that the backward-forward sweep (BFS) approach is capable of producing good load flow solutions [14]. However, this method has some applicability restrictions due to its main premise: the radiality characteristic. Consequently, BFS methods are limited to systems with one source and a radial structure. Owing to their limitations, conventional BFS methods not meet the new challenges of modern distribution networks [12] The electric power systems must be planned and managed for years in advance to ensure that the system can operate reliably in real time, despite the many uncertainties surrounding future demands, fuel sources, asset availability, and grid conditions. The optimal power flow (OPF) methods are the most well-known approach for properly solving this class of problems, since they were introduced by Carpentier [15]. The optimal power flow (OPF) is concerned with the optimization of steady state power system performance with respect to an objective function while subjected to various equality and inequality constraints [16]. Although OPF is one of the most important and well-researched subfields of constrained nonlinear optimization, the algorithm often proves to be of increasing complexity for the modern electrical system, and does not cover the entire requirement of the different time horizons [17].
Considering the complexity of power systems, its numerical dimension, and the need to analyze different scenarios involving decisions in a dynamic environment, a general OPF model problem gives place to specific models that consider the characteristics and specificity of systems at each time horizon under analysis. These models must be easier to understand and better representative of the real system, generating more consistent results for the generation scheduling under the electrical power systems constraints.
The Optimal Current Flow (OCF) is presented as an alternative to analyze electrical network problems, as an alternative to traditional OPF approaches that models the network constraints as non-linear polar or nodal equations (Tinney e hart) [18]. The OCF models the electrical network through both Kirchhoff's current and voltage laws, representing the system's electrical network as linear [11]. This representation is particularly appropriate for an electrical power system to model electrical network problems, due to the flow concept. It is interesting, simple, easy to understand, and reflects the relevant characteristics of power distribution systems. The contributions of this paper are summarized as follows:

1.
A simple and easily understood model for use as an alternative to the traditional nonlinear equations approach based on NR nodal formulation.

2.
Representation of modern distribution system with PV buses and loops by a quadratic loss minimization function subjected to linear network flow constraints.

3.
Optimization of DER systems with voltage control.

4.
Allows analyses of optimization scenarios through APIs in a cloud environment.
To solve the mentioned OCF optimization problem, a cloud environment is suggested. In this computational environment, the OCF solution can consider Distributed Energy Resources (DER). Cloud solutions enable the reduction of operational costs, complexity, and time-to-market deployment compared to the local model, and especially the availability and scalability of the system, in the presence of scenarios of high-volume requests [5][6][7]. They include the following benefits: increased efficiency, reliability, performance, resilience with real-time DER operations, centralized and switching studies, and operations for distributed energy systems. In addition, it is possible to incorporate new algorithms for optimizing operations in DERs, aiming to study network switching, minimization of losses, and minimization of the number of switching operations in the recomposition problems. This paper is organized as follows. Section 2 gives an Optimal Power Flow Formulation, and Section 3 presents the Computational Environments for Analyzing DER Systems. Section 4 presents the IEEE 34-Bus Test Case and the numerical results, and some observations and discussions are presented in Section 5. Section 6 outlines the conclusions.

Standard Form of OPF Method
Optimal Power Flow (OPF) models for electrical networks are one of the most important and well-researched sub-fields of constrained nonlinear optimization, where methods, tools, and software deal with finding an optimal operating point of a power system that minimizes an appropriate cost function, such as generation cost or transmission loss, subject to a certain set of constraints. OPF methods are utilized to find the optimal scheduling for any system under constraint conditions, such as reactive power limits, voltage profile, transmission lines thermal limits, and generation, transmission, and distribution systems' active and reactive power flow optimization, individually or all together [16]. There are a wide variety of OPF formulation and solution methods to address specific issues of each problem within a time horizon, and most of them formulate the problem using the following standard form, [19].
subject to: The objective function f (u, x) represents the system's optimization goal. Vector functions g(u, x) and h(u, x) represent system equality and inequality constraints of the electrical network, respectively. Depending on the selection of f , g, and h, the OPF problem may become a linear, mixed integer-linear, nonlinear (likely non-convex), or mixed integernonlinear programming problem according to each application [16]. The traditional OPF models the problem using polar or nodal power flow representation, where constraint equations in the full version of the power flow are nonlinear [16]. This approach leads to a large-scale complex nonlinear problem, where the candidate solution increases exponentially with the system size [20]. To overcome the non-linearity of the constraints, this work proposes an alternative model that considers Kirchhoff's voltage and current laws to represent electrical constraints.

Optimal Current Flow (OCF) by Network Flow Method
One of the main tasks of the distribution system operator is to determine the operation point that minimizes the feeder and generator current injections, within their limits. The generalized representation of the OCF problem is given by: subject to: is a generation cost function, w is the weight to transform power losses into cost, R is a diagonal resistance matrix, A is the bus-branch incidence matrix, I is the complex current branch vector, I r is the active component vector of I, I B is the bus complex injected current, V is the generation bus voltage vector, Z is the loop impedance, and I r min and I r max are the minimum and maximum active current vectors line limits, and V r min and V r max are the minimum and maximum active voltage vectors; V i min and V i max are the minimum and maximum reactive voltage vectors at generation buses. The number of constraints is 2x(n − 1) + n(I l ) + n(E l ) where n is the number of nodes, nI l is the number of internal loops and nE l is the number of external loops. Note that A is an incidence matrix formed by zero or one.
Decomposing the Equation (1) into an active and reactive part results in Equation (3).
Rearranging the above equations in active and reactive components results in Equation (4).
where I r is the active branch and generator current vector, I i is the reactive branch and generator current vectors. I r I , and I i I , are the active and reactive components of the injected current vector ((I i L + I g )) i , respectively. R is the diagonal resistance matrix. R l is the loop resistance matrix and X l is the loop reactance matrix; V f is the reference voltage vector. I r min and I r max are the minimum and maximum active current vectors used to represent line limits. V r i min and V r i max are the minimum and maximum active voltage vectors

Flexibility of Optimal Current Flow (OCF) Formulation
The network current flow concept is simple and easy to understand, reflects relevant characteristics of the power systems, reduces the traditional Optimal power flow problem to a quadratic network flow model, and is very flexible, representing models in different time horizons. Taking advantage of this, this section presents some models, from the simplest to those that include reconfiguration of the distribution system due to unplanned line output.

Direct Current Optimal Flow (DCOF)
Power flow optimization problems modeled as a linear minimization problem are largely used, particularly in the congestion-constrained markets, contingency analysis, or, less commonly, to initialize, or warm-start, a nonlinear OPF application. Many versions of these approximate models are found in the literature [21][22][23][24]. The classical DC OPF approach, based on the approximation of power nodal flow formulation, has several applications in load supply capability evaluation, economic dispatch [25,26] contingency analysis [27] transfer capability, and transmission network planning [28,29]. The alternative to the traditional DC OPF is the adoption of DCOF, which represents the network flow constraints by the Kirchhoff current equation as in [30][31][32][33][34][35]. The DCOF model is represented as: subject to: The alternate current flow considers the active and reactive components of the current. This consideration is important for evaluating the resource availability to supply both the active and reactive demand. For that, the complex current in Equation (5) has to be decomposed into active and reactive components, as in Equations (6) and (7) min ( f (I r g ) + w[I rt * R * I r ]) (6) subject to:

Alternate Current Optimal Flow with Internal and External Loops
An improved load flow technique based on load current injection for modern distribution systems must consider either radial or weakly meshed networks [12]. The network mesh equation for internal loops, as shown in Figure 2 Those that exist in a real network, is written as: where Z l is the internal loop impedance Matrix and I is the complex current Vector. The existence of distributed energy resources (DERs) allows the implementation of grid-supporting functions, such as volt-var control. This is considered by the inclusion of an external loop, a fictitious loop, connecting the reference bus, and the feeder, to each DER-controlled bus. The equation used to represent this inclusion is: where Vre f is the voltage at the reference bus, VDGn is the controlled DER bus voltage vector, and Z LE is the external loop impedance matrix, as shown in Figure 3.

Alternate Current Optimal Flow (ACOF) 5 Bus-Example
An appropriate example with five buses, four loads, three phases balanced with the main feeder on bus-1, and a distributed generator (DER) installed on bus-3, is shown in Figure 4.

Capacity Constraint Equations
The lower and upper capacity limits for the current flow in the distribution network branches and for the injected current at generation buses are:

•
Branch capacity constraint; where I r min and I r max are the lower and upper active current bounds and I i min and I i max are the lower and upper reactive current bounds of the lines; where V r min and V r max are the lower and upper active voltage limits for PV buses (DG buses with voltage control).

ZIP Load Model
In the proposed model, the load can be represented by a constant power, constant impedance, and constant current model [36,37]: • Load as constant impedance: the load is represented as a constant impedance connected to the bus; that is, the active and reactive current is calculated from the voltage; where I L is the branch current, V is the bus voltage, and Z is the branch impedance; • Load as constant current: the current does not change with the voltage; • Load as a constant power: the values of the active and reactive powers remain constant regardless of the voltage variations. This model is valid for long time scales; where P is the active power associated with the load, Q is the reactive power associated with the load, V is the bus voltage, and I L is the branch current.
All the above equations can be decomposed into active and reactive components.

Alternate Current Optimal Flow (ACOF) 5 Bus-Matrix Representation
The objective function is modeled as a losses minimization function, represented by the objective line in Figure 5. The constraint matrix reproduces Equation (4) and represents the active bus balance equation, reactive bus balance equation, injected active and reactive current constraints, active and reactive external loop constraints, and voltage magnitude limits. The active components of the current balance equations are represented in the first constraint equations, identified by the red line, and in the following five lines, the reactive components of the balance current equations, identified by the green line. The number of external loops is equal to the number of generator buses; the voltage constraint row represents the minimal voltage constraint for bus-3. From the above matrix representation, three use cases of the optimal current flow studies can be analyzed. Case one, represented by a constraint matrix circled by a red line, considers the active current optimization model. The case with the matrices in green considers the active and reactive current optimization model as Equation (6). The blue line represents the model optimization of the active and reactive current, control of limit's lines and control of voltages case, as in Equations (6)-(9).

Computational Environments for Analyzing DER Systems
The complexity of the problem increases with the diversity of the system's generation resources. Then, integrated solutions for the DMS (Distribution Management Systems) and ADMS (Advanced Distribution Management System), have to be implemented to simulate different situations such as loss of line analysis, network loading capacity, system reconfiguration, and switching planning. These solutions can be reached with the DER support [6][7][8]. DER system is a relatively new concept for power distribution in the objectives and functionalities consist mainly of organizing, managing, optimizing, and effectively controlling the resources of the distribution network to maximize the economic benefits of the network, proposing more reliability of network operation and quality of [8].
The proposed Computational Environment is divided into layers, as seen in Figure 6, where the layer with the system with Power System Model corresponds to the integrated distribution network with DERs interconnected with the ADM DMS system layer of the companies sent the data from the network in the OCF API interface in Table 1. The DMS and ADMs systems use the APIs that are in the Cloud layer. The use of cloud APIs for DMS and ADM systems, proposed in this work, guarantees high availability, scalability, and performance in a centralized environment and facilitates the interface of distribution networks with controllers compatible with the standard, offering an environment close to the real one for use.
In addition to taking in the importance of DER, the utilities need to consider its implementation in their systems. Different solutions may be reached depending on DER penetration levels, network characteristics, capabilities, and new system architectures that support DERs [8]. The works of literature [1,2,6] detail cloud environments for load flow simulation; however, they do not present a flexible model with different APIs and optimization algorithms.
The focus of this work is not on the integration of DERs with ADMs and DMS systems, but on how ADMs and DMS systems use Cloud APIs in real time to optimize distribution network operations with DERs. For that, the solution architecture proposes a standard real-time communication interface using the Sunspec Modbus protocol [38]. The control hardware used is a cloud-based IoT solution [6]. KMC Controls Internet of Things (IoT) devices are directly connected to DER Models over Modbus TCP/IP via a LAN connection.

OCF API Interface
The API establishes a standard input for DMS and ADMS systems. Table 1 below represents the required API data for five bus distribution networks example with DERs. The Figure 7 shows the JSON format of line 1 (branch 0) of Table 1. The JSON string format contains either an array of values or an object, which is a set of name/value pairs. An object is surrounded by a pair of curly brackets and contains a comma-separated list of name−value pairs. A name−value pair consists of a field name (in double−quotes), followed by a comma(,), followed by the field value (in double quotes).  In an integrated ADMS operation with DER and microgrids, the goal is not only to allow mutual sharing of data, functionality, and task performance, but to achieve better coordination among different functions operation in relatively independent systems [5]. The proposed model uses an architecture of APIs as microservices. The cloud infrastructure used in the test simulations is GCP (Google Cloud Platform), but its solution is cloud agnostic, as shown in Figure 8. The OCF-Controller is responsible for performing, with Post request, the optimal power flow calculation for the OCF model using the JSON structure in the format of Figure 9 as the input parameter. The FeederInfoController microservice is responsible for getting requests for analyzing the feeder's characteristics, such as the DER number, bus identification, and whether there is mesh formation in the feeder. The documentation for both microservices is available in Swagger API (inputs and outputs)

OCF Algorithm
The OCF algorithm is coded using Java version 11, Scilab version 6.1, and FOSSEE Optimization Toolbox [39] as the solver engine. The developed approach can be applied to balanced and unbalanced DER Systems. The algorithm is resumed in eight steps, as shown in Figure 10. The initial voltage vector (real) is arbitrated equal to 1.0 p.u. for all buses. The iteration counter is set to p = 1. As shown in Step 7, the proposed model is iterative. For each iteration performed, Step 5, the OCF problem Equation (2) is solved, and a new bus voltage vector is determined. With a new voltage, the load bus injected current is recalculated, and the shadow price is updated. Finally, the convergence is performed (Step 7), and the algorithm returns to Step 4 if there is a δ V component of the bus vector V greater than . For a constant current model, the process is not iterative, since the current is always the same.

IEEE 34−Bus Test Case
The IEEE 34−bus Power System Model is a balanced three-phase, is lightly loaded and has a radial topology with 34 buses and PV bus, as shown in Figure 11. The loads are represented by the constant power, constant impedance, constant admittance and constant current model [40]. Two test scenarios were considered.

IEEE-34 without DER
This scenario considers the IEEE 34 network without the presence of DER, as defined in the literature [40]. This basic scenario allows analysis of the buses' active and reactive current and the voltage profile.

IEEE-34 with DERs and Voltage Control
This scenario analyzes the influence of Bus-28 and Bus-30 DERs on the system voltage profile. The introduction DERs in the system lead to an optimization problem, as defined in Equation (2), which cannot be solved by [5,12]. Additionally, both methods do not consider line current limit constraints. The upper and lower limits of the current flows of the DERs 28 and 30, as shown in Table 2 and the upper and lower limits of the voltage profile of bus 30 as shown in Table 3. The objective of this test case is to minimize system losses, considering the Real Voltage component and the limits of the lines, in order to obtain and control an adequate voltage profile in the network. To demonstrate the result of the case test with multiple DERs in the IEEE-34 network, the voltage profile obtained is compared with two other network configurations present in the literature: first, with the base case (without the use of DERs) [11,40] and with one DERs connected at bus 28 [12] and without feeder generation limited and voltage control. Three test scenarios simulations were carried out, considering the power systems and DERs integrated into the ADMS-DMS systems. The simulations were performed through OCF-Controller API, sending the input parameters for the base case and case with DERs and voltage control. Figure 12 shows the results, with the voltage profiles (module) in p.u. The red line represents the result for the base case, and the blue line represents the result for the case with DERs resources and voltage control on the IEEE 34-bus distribution network.
The OCF Algorithm set the initial voltage vector (real) for all buses equal to 1.0 p.u. The initial voltage at the feeder bus is set equal to 1.02 p.u. The convergence value is set = 0.004. The results of OCF-Controller API for the active and reactive currents injected into the load buses and the voltage module are shown in Table 4. The results of the active and reactive injected currents by the DERs at bus 28 and bus 30 are highlighted at the end of the table. The feeder bus-0 is considered the reference bus, and the results of buses without load are not shown. To maintain the bus voltage at the specified value, the DER-30 reactive power generation was 0.3767 p.u., while to minimize the system losses, the two DERs have to work at the maximum active power generation, as shown at the end of Table 4.
In performed tests with the distribution IEEE 34-bus with DERs, it is possible to verify through Figure 11 the improvement in the voltage profile (in green) in consideration of the base case (in blue) and the case with one DER without voltage profile control (in red) [12]. In addition, in Table 4, it is possible to verify that the model considered the active and reactive current injection limits by the 28-DER and 30-DER, as defined in Table 2 and the minimum voltage limit at bus 30 = 0.93 p.u. as defined in Table 3.

Discussion
Medium-and low-voltage distribution systems have a high current value, which makes it necessary to develop dedicated solutions. As an objective function, the OCF Algorithm has the generation plus losses minimization; operation costs are represented by a quadratic function. As it adopts linear representation to the distribution network constraint, using both Kirchhoff laws, it overcomes the non-convergence of the Newton-Raphson approach for distribution systems with elevated resistance value. It is very flexible, representing models from the simplest, constant current to the most complex models: those with voltage control at generation buses that can generate reactive power. It also considers the current flow limits on the distribution components (lines, transformers, etc.), which are impossible to consider using the traditional Newton-Raphson method or Backward Forward Sweep algorithms focused on power flow representation. To consider current flow limits is adequate compared to power flow limits since the current causes heating effects on distribution components.
This architecture is an improvement on that of [5], which implements the API only with the Backward Forward Sweep (BFS-Controller) method of load flow analysis. This solution extends that work by adding an API to the list of services, now with the possibility of optimizing the load flow with the OCF-Controller API. The proposed API Architecture Layer is coded using Java version 16 and Spring Framework 2.5.3. The tests were executed in CGP Intel Core i5, 2.4 GHz processor, with 4 GB RAM. This section highlights the performance of the approach in terms of accuracy and convergence rate. To prove the high availability, performance, and multiple accesses in the cloud API infrastructure, two stress tests were simulated: the first test simulates sending 50 simultaneous requests to the optimization request calculation API per second. The second test simulates 100 requests per second, as shown in Table 5.

Conclusions
The Cloud API Architecture can be integrated with the DMS and ADMS systems to assess the performance of DERs resources. The platform includes the following benefits: increased efficiency, reliability, performance, and resilience with real-time DERs operations centralized, and switching studies for distributed energy systems. An application of the cloud API Environment was presented and, through the results of the IEEE 34-bus, it was demonstrated through the test scenarios with the IEEE-34 network that the DMS and ADMS systems allow the use of the OCF model in the cloud, reducing the complexity of different network configurations with DERs, especially the availability and scalability of APIs with a high volume of requests.
Some advantages and flexibility of the proposed architecture are: • It is adherent to the formulations of a great amount of DCOF and ACOF approaches;