Quadrature Current Compensation in Non-Sinusoidal Circuits Using Geometric Algebra and Evolutionary Algorithms

Non-linear loads in circuits cause the appearance of harmonic disturbances both in voltage and current. In order to minimize the effects of these disturbances and, therefore, to control the flow of electricity between the source and the load, passive or active filters are often used. Nevertheless, determining the type of filter and the characteristics of their elements is not a trivial task. In fact, the development of algorithms for calculating the parameters of filters is still an open question. This paper analyzes the use of genetic algorithms to maximize the power factor compensation in non-sinusoidal circuits using passive filters, while concepts of geometric algebra theory are used to represent the flow of power in the circuits. According to the results obtained in different case studies, it can be concluded that the genetic algorithm obtains high quality solutions that could be generalized to similar problems of any dimension.


Introduction
The introduction of distributed generation and microgrids in power networks allow an efficient energy management and integration with renewable energy sources [? ]. However, these grids include an increasing number of power electronic devices and non-linear electronic loads, such as power inverters, cycloconverters, speed drives, batteries, household appliances, among others. These non-linear loads increase the harmonic disturbances both in voltage and current, then causing detrimental effects to the supply system and user equipment [? ]. As consequence, these grids are seriously affected by events that degrade the power quality [? ], and provoke excessive heating, protection faults and inefficiencies in the transmission of energy [? ], it becomes a critical task to determine precisely the electrical energy balances on the microgrid. Different authors have presented models and theories in the past [? ? ? ], but while all them coincide in the study of the sinusoidal case, there are some controversy in the analysis of non-sinusoidal systems with a high harmonic content, such as modern microgrids. In particular, well-known theories such as those proposed by Budeanu [? ] and Fryze [? ], have been questioned by different authors after demonstrating inconsistency and errors [? ? ? ]. Therefore, it is important to investigate how to improve the compensation of the power factor in non-sinusoidal systems in presence of harmonics. Some investigations have highlighted that algorithms for calculating the parameters of filters has rarely been discussed [? ], although in recent years some authors have applied computational optimization methods, including meta-heuristic approaches for optimizing filter parameters in circuits having harmonic distortion [? ? ? ? ]. More specifically, genetic algorithms have been successfully applied in [? ? ? ].
In this paper, an evolutionary algorithm is used to optimize the type and characteristics of passive filters for power factor compensation. The rest of the paper is organized as follows: Section 2 introduces 2 of 17 some basic ideas about geometric algebra and its application to power systems. Section 3 describes the problem at hand and the genetic algorithm used as solution method. Section 4 presents the empirical study, while the main conclusions obtained are detailed in Section 5.

Geometric algebra and power systems
Traditionally, electrical engineers have been taught to solve sinusoidal electrical circuits using complex number algebra, exactly as Steinmetz theory [? ] introduced in the 19th century. It stated that differential equations in time domain can be transformed into algebra equations in complex domain. Under these assumptions, the apparent power can be expressed as: where P is the active power, Q is the reactive power and j is unit imaginary number. The limitations of the algebra of complex numbers and the impossibility to apply the principle of conservation of energy to the apparent power quantity [? ], has caused that some researchers propose alternative circuit analysis techniques, including those based on geometric algebra [? ].

Basic definitions of geometric algebra
Geometric algebra has its origins in the work of Clifford and Grassman in the 19th century and is considered as a unified language for mathematics and physics. It is based on the notion of an invertible product of vectors that captures the geometric relationship between two vectors, i.e., their relative magnitudes and the angle between them [? ]. Some investigations have defined the properties of geometric algebra [? ? ] applied to physics and engineering. Traditional concepts such as vector, spinor, complex numbers or quaternions are naturally explained as members of subspaces in geometric algebra. It can be easily extended in any number of dimensions, being this one of its main strengths. Because these are geometrical objects, they all have direction, sense and magnitude. The basics of GA properties are based on well established definitions around vectors. For example, a vector a = α 1 e 1 + α 2 e 2 (a segment with direction and sense) can be multiplied by a vector b = β 1 e 1 + β 2 e 2 in different ways, so the result has different meanings. In (2), the inner product is defined and the result is a scalar. In (3) a new product is defined, the wedge product. The main difference with its cousin the outer product (see figure 1) is that the result is neither a scalar nor a vector, but a new quantity called bivector.
A bivector is known to have direction, sense and magnitude in the same way a vector has. It defines an area enclosed by the parallelogram formed by both vectors (see figure 2). This product complies with the anti-commutative property, i.e. a ∧ b = −b ∧ a. A bivector is a key concept in geometrical algebra and cannot be found in linear algebra or vector calculus. The outer product of two vectors produces a new entity in a plane that can be operated like vectors, i.e., addition, product or even inverse. Like vectors, a bivector can be written as the linear combination of a base of bivectors. Finally, the third product between vectors is defined in (4) as the geometric product and can be described as one of the major contributions in geometric algebra. Not only vectors can be multiplied geometrically, but bivectors and other entities, in general, can be used.
The result is a linear combination of the inner product and the wedge product. Equation (4) can be expanded to further find out new insights.
where A 0 is the scalar part and A 2 is the bivector part.

Application of geometric algebra to power systems
Recently, several researchs have proven that geometric algebra or Clifford algebra is a powerful and flexible tool for representing the flow of energy or power in electrical systems [? ? ]. Some authors have motivated the use of power theory based on geometric algebra as Physics' unifying language, such that electrical magnitudes can be interpreted as Clifford multivectors [? ]. More specifically, Clifford algebra is a valid mathematical tool to address the multicomponent nature of power in non-sinusoidal contexts [? ? ? ] and has been used for analysis of harmonics [? ].
The concept of non-active, reactive or distorted power acquires a meaning that is more in line with its mathematical significance, making it possible to better understand energy balances and to verify the principle of energy conservation. Nevertheless, some authors have highlighted that the verification of the energy conservation law is only possible in sinusoidal situations [? ]. To overcome these drawbacks, these authors proposed a new circuit analysis approach using geometric algebra to develop the most general proof of energy conservation in industrial building loads, with capability of calculating the voltage, current, and net apparent power in electrical systems in non-sinusoidal situations.
Different authors have proposed definitions to represent non-active power for distorted currents and voltages in electrical systems, although no single representation has been universally accepted. For example, in [? ] a non-active power multivector from the most advanced multivectorial power theory based on the geometric algebra with the aim of analyzing the compensation of disturbing loads is presented, including the harmonic load compensation, identification, and metering between other applications. Other researches have shown that geometric algebra can be applied to analyze the apparent power defined in a poly-phase system having transmission lines with frequency-dependency under non-sinusoidal conditions [? ].

Geometric apparent power
As several authors have shown, the use of apparent power loses its meaning under non-sinusoidal conditions, involving erroneous calculation of energy flows between the load and source. In contrast, [? ] proposes the use of a new term called net apparent power or geometric apparent power M. This concept is the result of the geometric product of voltage and current in G N domain (6).
which result in a scalar and a bivector when the voltage and current are sinusoids It can be easily shown from (7) and (1) that so M 0 is the active power derived from the scalar part and M 2 is the reactive power derived from the bivector part of the net apparent power multivector. For the non-sinusoidal case, i.e., when harmonics are present in the voltage and/or current, the apparent power loses its validity and only M can reflect the exact flow of energy in the circuit. Consider a general voltage waveform u(t) where e i represents the product of n vectors and the subscripts c and s denote cosine and sine, respectively. Using (10), any waveform x(t) can be translated to the geometric domain G N , so the final result for the voltage is In (11), the transformation given in [? ] has been used and is reproduced here to make this paper more readable.
[? ] also demonstrates that the admittance of typical passive load is Y h = G h + B h e 1 e 2 , so the harmonic current associated to h-th voltage harmonic is and the total current where i g is the in-phase current where i b is the quadrature current. The geometric apparent power is then where M g is the in-phase geometric apparent power, CN d is the degraded power (summation of cross-frequency products between voltage and current) and M b is the quadrature geometric apparent power. Based on equation (14) and (8) the power factor in G N domain can be defined as in contrast to the clasical approach where S is used. As demonstrated by [? ], S and M are different concepts for non-sinusoidal scenarios, but reduces to the same in the sinudoidal case. Other power theories like Czarnecki's based their power factor definition on the concept of apparent power S, so it leads to different power factor results in non-sinusoidal situations.

Problem description and solution strategy
This section describes the proposed problem in this research and details the characteristics of the genetic algorithm used to solve it.

Problem description
Power systems operating under harmonic distortion must be optimized to reduce power losses and improve power quality [? ? ]. Whether the system is linear or non-linear, it is necessary to provide reactances in parallel with the load in order to reduce these harmonics. The typical design of compensators is based on the knowledge of the susceptances of the system to different frequencies [? ], something that is not easy to achieve when you have highly distorted systems. The main objective of non active power compensation is to minimize the source RMS current [? ]. However, it is not a trivial task since it involves to determine which type of filter and characteristics of their components is more suitable for compensation purposes in a given circuit. For example, a capacitor with an optimal value connected in parallel to the load is an easy solution but this does not produce the absolute minimum of the distortion power [? ], while other alternatives could improve it.
Some studies have highlighted that algorithms for calculating the parameters of filters has not been studied in detail [? ], although some authors have implemented optimization algorithms for optimizing the configuration of the filters in circuits having harmonic distortion. For example, in [? ] it was proposed a genetic algorithm to minimize current total harmonic distortion using LC passive harmonic filters. Other recent studies have applied swarm intelligence methods to comparatively evaluate single-tuned, double-tuned, triple-tuned, damped-double tuned and C-type filters in order to improve the loading capability of a set of transformers under non-sinusoidal conditions [? ]. In addition to the use of passive filters, some studies proposed algorithms for estimating the optimal parameters of active and hybrid filters. For example, in [? ] it was proposed the use of direct neural intelligent techniques to improve performance of a shunt active filters. In other recent studies, it has been proposed the use of differential evolution (DE) algorithms to optimize the parameters of hybrid filters (combining active and passive filters) in order to minimize harmonic pollution [? ]. The problem to be solved involves the determination of the most suitable type of passive filter and its parameters to minimize the source RMS current I s in order to get the optimal value I scp .

Solution approach
Genetic algorithms are optimization methods based on principles of natural selection and genetics [? ]. Figure 3 shows the flowchart describing the operation of the genetic algorithm. It consists of a set (population) of solutions, each of which is called individual or phenotype, that evolve to reach solutions of high quality in terms of a fitness function. As an initialization step, genetic algorithm randomly generates a set of solutions to a problem (a population of genomes). As Figure 4 shows, each individual is represented by a string of real numbers. Specifically, the data structure of each individual consists of three possible values for inductors L (Henry) and three possible values for capacitors C (Farad). All or some of these values will be considered in the optimization process depending on the filter choosed, which will be specified in the FT field (filter type), as described below. The actual values that can be assigned to inductors and capacitors are preset between two limits (upper and lower), so that the search space of the evolutionary algorithm is limited within reasonable margins. After calculating the fitness values for all solutions in a current population, the individuals for mating pool are selected using the operator of reproduction according to a given fitness function defined for the problem to be solved. In our problem the fitness function is where I s is the source current calculated according to geometric algebra operations. These selection strategies aim to introduce a certain degree of elitism in the population. These solutions evolve by applying mutation and crossover operators that modify the genotype of the individuals. Offspring solutions substitute some old solutions of the population, and the new generation of individuals repeats the evolution process until a termination criterion is fulfilled (e.g. a maximum number of generations has been reached). In this paper we have adapted a genetic algorithm solver for mixed-integer or continuous-variable optimization, constrained or unconstrained, included in the MATLAB Global Optimization Toolbox [? ]. This toolbox allows to solve smooth or non-smooth optimization problems with constraints using different mutation and crossover operators. The original source code has been adapted to deal with the problem at hand. It also has been adapted to take into account the particularities of the proposed problem through GA. More specifically, an opensource implementation of GA "Clifford multivector toolbox" has been used, available at https://sourceforge.net/projects/clifford-multivector-toolbox/. A preliminary sensitivity analysis has been performed to determine the parameters of the algorithm, such that the values used in our study are: Population size: 100 individuals; crossover rate: 0.8; mutation rate: 0.2; selection criteria: roulette wheel selection; termination criteria: 50 iterations.

Empirical study
This section presents the results obtained by the genetic algorithm in three different case studies.

Case studies
• Czarnecki's case study [? ]: This example consists of simple circuit with a harmonic polluted ideal voltage source of normalized frequency ω = 1 rad/s with an active power P = 344.23 W. Figure 5(a) shows the circuit load, while Figure 5(b) shows the solution found by Czarnecki with L 1 = 5.906H, L 2 = 19H, C 1 = 0.034F and C 2 = 0.012F, who compensate the reactive power of the harmonic components by the 1-port X of a precalculated admitance. The method proposed by Czarnecki was able to compensate the source RMS current to 3.10 A from the initial 12.24 A [? ].
Using (10), the voltage in G N domain can be expressed as where the uncompensated current is 44.72 A. Figure  • Castilla's case study [? ]: This example consists of a circuit with a distorted voltage source with three harmonics given by: which translates to with an uncompensated RMS current of I = 4.21 A. Although the structure of this compensator was not described in the paper published by Castilla [? ], this author indicated that it reduced the source RMS current to 3.21 A.

Filter optimization
The genetic algorithm has been adapted to manage different types of filters widely used in the literature for compensating purposes and mitigation of current harmonics. Based on equation (12), the admittance for a general load Y l and harmonic h, is equal to If we connect a pure reactive impedance in parallel with the load for current compensation, its admittance Y cp h will be For example, if we choose a simple LC series compensator, we have So we need to make equal B cp = −B l for every harmonic h to fully compensate the quadrature term. For the opmital case, the total current i is reduced to i g since i b + i cp is equal to 0 after applying Kirchhoff laws.
The following configurations were used based on very well-known type of filters: • C-type filter: it is is mainly used for suppressing the low order of harmonics [? ]. • Triple tuned filter: This type of filter is electrically equivalent to three parallel tuned filters connected in series [? ]. • Foster's filter: this filter combines in parallel single L-type and C-type filters and also parallel LC-type filters. Figure 11. Foster's filter.
• Czarnecki's 4-elements filter: it is a filter that combines two L and two C elements using a series/parallel configuration [? ].

Simulation results
Tables 1, 2, and 3 show the results obtained by the genetic algorithm in the three case studies described above, being the RMS current through the supply source the objective to be minimized. The best, mean and standard deviation of 10 independent runs are provided. As it can be seen in Table 1, in the case study proposed by Czarnecki [? ], the filters "Triple tune", "Foster" and "Czarnecki 4" obtain high quality results, while "C-type", "Series LC", and "Parallel LC" filters are far from the optimal solution. Some similar conclusions are obtained when analyzing the date from Table 2, corresponding to the circuit proposed by Castro-Nuñez and Castro-Puche's [? ]. . It is important to point out that better results are obtained in the case of Castro-Nuñez with the same choice of compensator (20.02 A vs. 20.10 A), although Castro-Nuñez does not specify the criterion for choosing the values of the L and C components, apart from discretionary choosing an LC series type compensator. Finally, the analysis of the results provided in Table 3 regarding to the filter proposed by Castilla [? ], indicate that "Triple tune", "Foster", "Czarnecki", and the series LC-type filter obtain high quality solutions. In summary, the genetic algorithm is able not only to equal but also to slightly improve the results obtained in these three case studies, which demonstrates that evolutionary approaches can be used to compensate the source current in different circuits using a variety of filters.  Table 4 shows the optimal values achieved for the 3 cases of study and the 6 proposed filters. The optimal current is also included for readability purposes. The table 5 shows a summary comparison for each of the problems solved showing current values without compensation I s , the optimum current that a passive filtering can achieve I opt , that provided by each author I auth and the optimum current obtained by applying the technique used in this work I GA cp . The value of the power factor for each of the above situations is also indicated plus the power factor without compensation using GA, PF GA . It should be noted that the power factor may differ between what is calculated by complex numbers and what is calculated by geometric algebra due to the different nature of the apparent power S and the geometric apparent power M. For the first case, the power factor is calculated as P/S while for the second case it is P/M. For example, for the Czarnecki case study, the apparent power S without compensating is worth 1,417 VA while compensated is worth 358.8 VA. However, using geometric algebra the power M is worth 1,842 VA and compensated is worth 359.25 VA. It should be noted that the final result of the compensation is quite similar since the proposed example is of low complexity as it only has 3 harmonics and low order. If we take into account the case of Castro-Nuñez or Castilla, the power of the proposed method is verified since with only 2 elements (LC filter series) or 3 elements, an almost optimal compensated current is obtained, unlike the original proposal of the author where the filter involved has many more elements and therefore, much less economic. It should also be noted that the methodology proposed by Castro-Núñez indicates the path to follow when it comes to compensate for the correct power terms, M b , which is not possible to cancel with the traditional power theory because it doesn't account for those terms arising from crossed products between voltage and currents.

Conclusions
In recent years, different authors have shown that geometric algebra, also known as Clifford algebra, can be applied to analyze electric circuits. Having in mind that different studies have shown that geometric algebra is more appropriate than the algebra of complex numbers for the analysis of circuits with non-sinusoidal sources and linear loads, this investigation is an important contribution in estimating the type of filter and its parameters to optimize the quadrature current in electrical circuits which leads to the compensation of new power terms like quadrature apparent power M b not included in the commonly accepted definition of electrical power standards. The traditional compensation of reactive power is exceeded by the compensation of cross products between current and voltage that have not been previously taken into account. The proposed approach is based on the use of a genetic algorithm which is able to optimize the parameters of different types of passive filters. In particular, six widely-used filters (single-tuned, double-tuned, triple-tuned, damped-double tuned and C-type ones by regarding their contribution on the loading capability improvement of the transformers under non-sinusoidal conditions.
The results obtained in three test circuits found in the literature show that the application of genetic algorithms based on geometric algebra representations are powerful methods that are able to equal or even improve the results previously obtained by other authors using analytical methods. These results open the door to investigate in the use of computational optimization methods for compensating the reactive power in complex circuits. As future work, it is planned to extend the analysis to larger circuits using these and other type of filters. Furthermore, multi-objective optimization methods will be considered to simultaneously optimize the reactive power compensation and to minimize the economic cost of the filters.