# Holomorphic Embedding¶

First introduced by Antonio Trias in 2012 [1], promises to be a non-divergent power flow method. Trias originally developed a version with no voltage controlled nodes (PV), in which the convergence properties are excellent (With this software try to solve any grid without PV nodes to check this affirmation).

The version programmed in GridCal has been adapted from the outstanding contribution by Josep Fanals Batllori. This version includes a formulation of the voltage controlled nodes that is competitive with the traditional methods. It is safe to say that now GridCal features the first source code holomorphic embedding open that works for real life grids.

## Concepts¶

All the power flow algorithms until the HELM method was introduced were iterative and recursive. The helm method is iterative but not recursive. A simple way to think of this is that traditional power flow methods are exploratory, while the HELM method is a planned journey.

The fundamental idea of the recursive algorithms is that given a voltage initial point (1 p.u. at every node, usually) the algorithm explores the surroundings of the initial point until a suitable voltage solution is reached (the algorithm converges) or no solution at all is found because the initial point is supposed to be far from the solution.

On the HE method, we form a curve that departures from a known mathematically exact solution that is obtained from solving the grid with no power injections. This is possible because with no power injections, the grid equations become linear and straight forward to solve. The arriving point of the curve is the solution that we want to achieve. The curve is a convergent series of terms that approximates the voltage. The convergence of the series approximation to the point of interest can be enhanced by using series approximants functions like the Padè, Epsylon, Sigma, etc. that enhance the rate at which the series of coefficients reach a solution.

The HE formulation consists in the derivation of formulas that enable the calculation of the coefficients of the series that describes the curve from the mathematically know solution to the unknown solution. Once the coefficients are obtained, a simple summation or the accelerated approximation computes the voltage solution at the end of the curve, providing the desired voltage solution. The more coefficients we compute the more exact the solution is since the series is a convergent one. This is true until the numerical precision limit is reached.

All this sounds very strange, but it works ;)

If you want to get familiar with this concept, you should read about the homotopy concept. In practice the continuation power flow does the same as the HE algorithm, it takes a known solution and changes the loading factors until a solution for another state is reached.

## Formulation¶

The fundamental equation that defines the power flow problem is the Ohm law in matrix form for AC current:

Where is the nodal complex admittance matrix, is the nodal voltages vector and is the nodal current injections vector. To be able to solve this equation we need to specify at least one of the voltages (the slack node voltage that acts as a voltage source). But we still have a problem, the admittance matrix is singular. To deal with this, we reduce the grid by removing the slack nodes and computing the equivalent current injections:

Now, for the holomorphic embedding to work we need to compose voltage series which first coefficient is close to 1. To achieve this, we need to split the admittance matrix into and . We eill see later why this is necessary, for now suffice that this is a required step. could be stored as a vector, but for mathematecal accuracy, let’s deal with it as a diagonal matrix. The following relation should hold:

is the admittance matrix formed only by series elements of the grid. is a vector or diagonal matrix formed only by the shunt admittances. This includes the shunt admittances of the branch pi model too. Substituting and rearranging we should have:

It is necessary to express the nodal current injections in terms of the specified power:

The holomorphic embedding is to insert a “travelling” parameter , such that for we have an mathematically exact solution of the problem in the no-load situation, and for we have the solution for the specified load (the one we’re looking for)

For the power term becomes zero, in this way the equation becomes linear, and its solution is mathematically exact. This will be useful later. Now we need to express all the magnitudes that are a function of into McLaurin series.

Wait, what?? did you just made this stuff up??

So far the reasoning is:

• The voltage is what we have to convert into a series, and the series depend of , so it makes sense to say that , as it is dependent of , becomes .
• The slack currents are formed as a function of the voltage at the slack nodes, hence they turn into an -dependent series too.
• Regarding the values multiplying and , they are there to provoke the first voltage coefficients to be one in the no load situation (). This is essential for the obtaining of convergent series.
• The asterisk in the of the term is explained below. In short, it is there to ensure that the Cauchy-Riemann condition is met.

The series are expressed as McLaurin equations:

Theorem - Holomorphicity check There’s still something to do. The magnitude has to be converted into . This is done in order to make the function be holomorphic. The holomorphicity condition is tested by the Cauchy-Riemann condition, this is , let’s check that:

Which is not zero, obviously. Now with the proposed change:

Yes!, now we’re mathematically happy, since this stuff has no effect in practice because our is not going to be a complex parameter.

(End of Theorem)

Alright! Now we know that we have to use McLaurin series, let’s continue with the formulation. For the sake of clarity lets call the voltage coefficients to separate them from the voltage . THe coefficients aready represent the reduced scheme, so no need for the red subscript.

In this equation we have a couple of problems; First we have a dividing series of voltage coefficients and second we have still around. To deal with the dividing voltage coefficients is relatively easy, we substitute them by their inverse.

Substituting we get:

## Implementation¶

What we want with the method is to compute order after order the terms of the voltage series which will provide the nodal voltage of the reduced grid (this is ok, because we know the slack voltages already). Therefore, in our case we want to compute the complex voltage () at the PQ and PV nodes of the grid, and the reactive power at the PV nodes ().

As explained before, we are working with an equivalent grid that contains no slack nodes, since we have reduced then and replaced their influence by current injections () Hence, the number of nodes in the number of PQ nodes plus the number of PV nodes.

In this implementation the lists denoted as pq and pv, are referred to the reduced grid, not to the complete grid. To remember this is of capital importance because the dimensions belong to a grid with nodes.

Also, from the mathematical derivation we have concluded that we have three kinds of coefficients; The first ones () that will provide the zero-load solution, the second ones () and the rest (). The coefficients of order 0 require no system solution whatsoever. It also to be noted that the system matrix is computed and factorized only once. The resulting series are perfectly convergent so that you may find the nodal voltage by a simple voltage coefficient summation.

We will store three kinds of coefficients:

• : Complex voltage coefficients for all the nodes of the reduced scheme.
• : Complex inverse voltage coefficients for all the nodes of the reduced scheme. The exist because dividing a series by another is too hard, and thus we came up with the inverse to be able to operate the coefficient divisions via convolutions.
• : Reactive power coefficients at the PV nodes. These are to be able to compute the voltage while keeping the voltage module set.

### Linear system¶

This is the linear system of equations that is to be solved for coefficient orders greater than 0 ():

The updating of the voltage and PV-node reactive power coefficient arrays is done like this:

### C>1¶

The symbol is the convolution symbol.

### Finding the voltage¶

The simplest way to find the voltage is to sum the coefficients.

More refined methods might accelerate the obtaining of the voltage. This is that a more accurate solution can be obtained with less coefficients computed. For instance the Padè approximation.

The McLaurinV equation provides us with an expression to obtain the voltage from the coefficients, knowing that for we get the final voltage results. So, why do we need any further operation?, and what is this Padè thing?

Well, it is true that the McLaurinV equation provides an approximation of the voltage by means of a series (this is similar to a Taylor approximation), but in practice, the approximation might provide a wrong value for a given number of coefficients. The Padè approximation accelerates the convergence of any given series, so that you get a more accurate result with less coefficients. This means that for the same series of voltage coefficients, using the McLaurinV equation could give a completely wrong result, whereas by applying Padè to those coefficients one could obtain a fairly accurate result.

The Padè approximation is a rational approximation of a function. In our case the function is , represented by the coefficients structure . The approximation is valid over a small domain of the function, in our case the domain is . The method requires the function to be continuous and differentiable for . Hence the Cauchy-Riemann condition. And yes, our function meets this condition, we tested it before.

GridCal implements two algorithms that perform the Padè approximation; The Padè canonical algorithm, and Wynn’s Padè approximation.

The canonical Padè algorithm for our problem is described by:

Here , where is the number of available voltage coefficients, which has to be an even number to be exactly divisible by . and are polynomials which coefficients and must be computed. It turns out that if we make the first term of be , the function to be approximated is given by the McLaurin expression (What a happy coincidence!)

The problem now boils down to find the coefficients and . This is done by solving two systems of equations. The first one to find which does not depend on , and the second one to get which does depend on .

First linear system: The only unknowns are the coefficients.

Second linear System: The only unknowns are the coefficients.

Once the coefficients are there, you would have defined completely the polynomials and , and it is only a matter of evaluating the Padè approximation equation for .

This process is done for every column of coefficients of the structure depicted in the coefficients structure figure. This means that we have to perform a Padè approximation for every node, using the one columns of the voltage coefficients per Padé approximation.

Wynn published a paper in 1969 [4] where he proposed a simple calculation method to obtain the Padè approximation. This method is based on a table. Weniger in 1989 publishes his thesis [5] where a faster version of Wynn’s algorithm is provided in Fortran code.

That very Fortran piece of code has been translated into Python and included in GridCal.

One of the advantages of this method over the canonical Padè approximation implementation is that it can be used for every iteration. In the beginning I thought it would be faster but it turns out that it is not faster since the amount of computation increases with the number of coefficients, whereas with the canonical implementation the order of the matrices does not grow dramatically and it is executed the half of the times.

On top of that my experience shows that the canonical implementation provides a more consistent convergence.

Anyway, both implementations are there to be used in the code.

 [1] Trias, Antonio. “The holomorphic embedding load flow method.” Power and Energy Society General Meeting, 2012 IEEE. IEEE, 2012.
 [2] Subramanian, Muthu Kumar. Application of holomorphic embedding to the power-flow problem. Diss. Arizona State University, 2014.
 [4] Wynn, P. “The epsilon algorithm and operational formulas of numerical analysis.” Mathematics of Computation 15.74 (1961): 151-158.
 [5] Weniger, Ernst Joachim. “Nonlinear sequence transformations for the acceleration of convergence and the summation of divergent series.” Computer Physics Reports 10.5-6 (1989): 189-371.