A Novel Algorithm for Controlling Active and Reactive Power Flows of Electric Vehicles in Buildings and Its Impact on the Distribution Network

: In the literature, many optimization algorithms were developed to control electrical loads, especially Electric Vehicles (EVs) in buildings. Despite the success of the existing algorithms in improving the power profile of charging EVs and reducing the total electricity bill of the end-users, these algorithms didn’t show significant contribution in improving the voltage profile on the network, especially with the existence of highly inductive loads. The control of the active power may not be sufficient to regulate the voltage, even if sophisticated optimization algorithms and control strategies are used. To fill the gap in the literature, we propose a new algorithm that is able to control both the active and reactive power flows using electric vehicles in buildings and homes. The algorithm is composed of two parts; the first part uses optimization to control the active power and minimize the electricity bill, while the second part controls the reactive power using the bidirectional converter in the EV in a way that the voltage profile on the distribution transformer respects its limits. The new approach is validated through a comparative study of four different scenarios, (i) without EV, (ii) with EV using uncoordinated charging, (iii) with EV using coordinated charging, (iv) with EV using our proposed algorithm. Results show that our algorithm has maintained the voltage within the recommended limits, and it has minimized the peak load, the electricity cost, and the techno-economic losses on the network.


Problem Statement
Plug-in electric vehicles (EVs) are considered as a promising technology to reduce the consumption of fossil fuel and the emission of CO2 and other harmful gases (SO2, NOx, etc.) [1]. Plugin hybrid electric vehicles (PHEVs) and fully battery electric vehicles (BEVs) are lumped together in this study by (EVs), in which the vehicles can be connected to the grid. EVs will definitely support the future deployment of smart grids because they are considered as a spinning reserve and able to store and deliver energy whenever it is needed. The integration of EVs has many benefits, such as providing ancillary services to the grid [2,3], and providing stability when fluctuant renewable energy sources are connected to the network [1,4,5]. Despite all the advantages that EVs can provide the smart grid, their integration should be supervised and controlled to maximize the profit from their existence. Hence, extensive studies should be conducted to propose the best optimization algorithms and control strategies that maximize the benefit of integrating EVs into the distribution systems.

Literature Review
The study of the integration of electric vehicles into the distribution system goes back to the 1980s, when the coordinated charging of EVs was examined and papers published as in [6]. Since then, the integration of EVs has become a hot topic, and scientists started to study how to charge EVs in a way to minimize the negative impact of their charging on the distribution network [7][8][9]. Some papers studied how to control the charging of EVs using unidirectional converters, while others studied the impact of controlling the charging and discharging of EVs on the network using bidirectional converters and charging strategies [10][11][12][13][14][15][16][17][18]. Usually, each charging strategy (uni-or bidirectional) has its advantages and barriers. The bidirectional charging strategies have many more benefits than the other method since they provide more ancillary services even during peak demand periods [2,16,[19][20][21]. Such benefits include: voltage regulation [15,22,23], frequency regulation [24], spinning reserve participation [19], supporting the integration of renewable energy sources (RES) [2,5,19,25] etc. It is important to note that uncoordinated charging and discharging strategies do not have a positive impact on the network, even if EVs are introduced in small quantities [26,27]. Therefore, it is always recommended to use coordinated charging strategies, although their implementation implies complexity and higher cost.

Impediments and Barriers of Other Studies
In recent years, the integration of EVs into buildings becomes an interesting topic to study [28][29][30][31]. Studies used many optimization algorithms and control strategies to get the most from their integration. The mostly used objective function was to minimize the electricity cost at home by optimizing the charging of EVs and other loads [32,33]. Regarding the constraints to be considered for optimal operation, many papers did not consider the active power limit of a distribution transformer ( ), the active power limit at home level ( ), and the active power limit of the main circuit breaker at home ( _ ) [25,34]. Exceeding may result in an overload on the distribution transformer (DT) and may reduce its lifetime and increase the electrical and financial losses [35]. The transformer's lifetime and its voltage profile are negatively affected even when optimization algorithms are used without considering the limits at homes and the distribution network. Other papers considered the limit on the transformer as constant [23], or variable [36], depending on the internal characteristics of the DT, such as temperature. The problem in these studies is that the proposed limits do not consider the electrical loads that exist on other transformers connected to the network. Hence, the total load demand of all electrical loads may highly affect the stability and create severe voltage drop on certain transformers, especially when high energy-demanding loads such as EVs are connected. Moreover, the reactive power has a much higher impact on the voltage profile compared to the active power. Therefore, a house/building with high consumption of reactive power may worsen the voltage profile drastically, not just on the local transformer, but also it might affect other vulnerable transformers on the network. To make things much clearer, Figure 1 shows two different cases for the same electrical network. Transformer 1 is supplying 2 other transformers (2 and 3). Each transformer is feeding a certain number of houses or buildings. In the first scenario, homes are considered without connecting EVs, while in the second case, and on the second transformer "2", EVs are plugged-in at homes. On the right side of the figure, there are some voltage profiles that represent how the voltage varies in time on each transformer. The first two voltage profiles in case 1 respect the minimum and maximum limits (a minimum of 0.95, and a maximum of 1.05 per unit [pu]). In this example, everything seems to be all right before connecting EVs. In the second case, when EVs are connected to the second transformer, there might not be a severe voltage deviation on the transformer. However, the increasing demand for "transformer 2" due to EVs may affect the voltage profile on the transformer 3 even if its total load demand did not change. Moreover, homes on transformer 3 are not supposed to reduce their load demands because the power consumption did not change, and homes on transformer 2 will not reduce their power demand because the voltage profile on the transformer respects the limits. What will be the solution in this case? Which customer is responsible for the voltage deviation on transformer 3? This problem was not addressed in previous papers to the best of the authors' knowledge. In order to avoid such problems, in this paper, both active and reactive power are considered in order to reduce the voltage deviation on the DTs and minimize the electrical and economic losses on the network. The regulation of the reactive power flow from EVs has a better impact on improving the voltage profile than the active power flow, which will be demonstrated in this paper. Hence, in the previous example, homes on the second transformer can use the bidirectional converters to inject reactive power to the grid in order to improve the voltage profile on their transformer and on the transformer of their neighbors, as presented in Figure 2.

Contributions
The contribution of this paper is presented in the development of a novel algorithm that is able to optimize and control the active and reactive power flow of the EVs at homes and buildings. The proposed algorithm minimizes the electricity cost at home or building, respects the active, reactive power and voltage limits on the distribution transformer, reduces the techno-economic losses on the network even under different pricing mechanisms (such as a Fixed price, Time-of-Use and Real-Time price). In addition, the algorithm considers the following:

•
Main and branch circuit breaker rating into the optimization model, • Upper and lower limits of both active and reactive power on the distribution transformer, • real charging and discharging power profiles of the EVs, • It predicts and calculates the available power to be consumed at each instant and inform the end-user how much energy is left to use every day to charge his EV while respecting the power and energy limits at home, • It informs the end-user how much energy he should reduce at home in order to attain the desired State of Charge level, • The discharging mode could be selected according to the EV owner's desire, • The algorithm gives the EV owner the choice to participate or not in the ancillary services such as voltage and power flow regulations.
The study is realized for a single EV at home, and then it is generalized to a large area of homes supplied by the same transformer. The EVs penetration level is 100%, which means that every home has its own EV. A comparative study between four different scenarios is presented in order to validate the suggested algorithm: (a) a home without EV; (b) a home with EV using uncoordinated charging; (c) a home with EV using coordinated charging; (d) and home with EV using our proposed algorithm to charge and discharge the EV.

Paper Organization
Section 2 presents the problem formulation. Results and discussions for a single home are shown in Section 3. In Section 4, the study is generalized to a cluster of homes supplied by the same bus using IEEE (Institute of Electrical and Electronic Engineering) 13 node test feeder as standard. Section 5 shows a summary of the main outcomes of the proposed algorithm. Section 6 presents the conclusion and future work. Finally, the nomenclature is given.

Problem Formulation
The problem formulation consists of introducing both active and reactive power in the optimization model and the algorithm. Static, dynamic, and discrete constraints related to the EV, the owner, the power and energy demand, the transformer capacity, and the grid are considered in order to guarantee an optimal solution.

Objective Function
The objective of the optimization is to minimize the electricity cost at home by controlling the charging and discharging of the EV as in Equation (1), where is the period of time for the study; is the arrival time when the EV at home is plugged-in; ∆ is the time step interval.
( ) is the baseload power demand of the home without the presence of the EV; ( ) is the cost of electricity at instant " " ($/kWh); ( ) and ( ) are respectively the binary flags of the charging, and discharging modes ("1" means the mode is turned on; otherwise it is "0", and just one mode at a time could be applied) [19]; ( ) and ( ) are the absorbed and injected active power by the EV using charging and discharging modes, respectively.

Mode of Operation
The EV battery status has one among three modes of operations represented by binary variables in Equation (2): where, ( ), ( ) and ( ) are respectively the binary flags of the charging, discharging, and idle modes ("1" means the mode is turned on; otherwise, it is "0", and just one mode at a time could be applied) [19]. The defined charging and discharging mode flags in (2) are proposed in this paper as in (3) and (4). They provide a safe functionality of the connected EV.
where, ( ) is the plug status of the EV, it is equal to "1" if the vehicle is connected to the grid,

Active Power Constraints
A total load of active power is obtained from (5), where, ( ) and ( ) are the absorbed and injected active power by the EV using charging and discharging modes. The power limits not to be exceeded on the home's main circuit breaker (MCB) and on the EV branch circuit breaker (BCB) are proposed in this paper as in (6) and (7), respectively. Respecting these limits avoids the voltage deviation and tripping of the circuit breakers. If these limits are not considered, the total power may exceed the limits and may create lots of problems at home and on the bus.
where is the nominal voltage; and are the main and branch circuit breaker nominal rates; ( ) is the phase angle; ( ) and ( ) are the avoiding tripping factors of the circuit breakers. They are affected by internal factors such as temperature, and age.
( ) takes a dynamic value that could change during the time in order to limit the active power absorption, it is controlled by the distribution system operator (DSO), and it helps in the participation of the ancillary services and voltage regulation. The maximum available active power at home at instant " " is proposed in this paper and described in (8), which could be used by the EV to charge its battery. If this limit is not considered, the total power may exceed the limits.
The respected upper and lower limits of active power at instant " " for the total load, including the EV are proposed in this paper as in (9): where ( ) is set to zero. ( ) should be less than ( ) otherwise, the discharging mode is activated.
Most of the existing studies consider constant charging and discharging power profiles in the optimization model, which may reduce the accuracy in the results, especially because they are highly non-linear equations. To improve the accuracy in the simulation, we suggest using non-linear power profiles for both charging and discharging processes, as suggested in [37]; these non-linear profiles were applied, and their accuracies were demonstrated in [28,[38][39][40]. The maximum charging and discharging power limits for a certain state of charge (SOC) of the battery are considered in this paper as in (10) and (11), respectively. These limits protect the battery from high charging and discharging power rates. Therefore, they protect the battery from overheating and increase their lifetime. The mathematical models are developed to describe charging and discharging power rates for different EVs, as in [41] and [42]. Various mathematical models could be applied for different types of EVs, but the main idea in this study is to introduce these expressions in the optimization models. Where, , ( ) and , ( ) depend on the SOC of the battery [42]; , and , are respectively the maximum allowed power limits to charge and discharge the EV's battery, they are defined by the manufacturer. These constraints protect the battery from overheating, overcharging, and reducing its life loss. and are the charging and discharging rate factors which determine the curve form of , ( ) and , ( ) respectively.
is the maximum SOC of the EV battery.
The maximum charging and discharging power profile limits described in Equations (10) and (11) are depicted in Figure 3. It can be seen that the profiles are highly non-linear and can affect the results whenever they are considered constants.  (10) and (11).
The maximum SOC for charging and discharging power which is proposed in this paper as in (12) and (13) respectively, guarantee that the battery energy will never overpass the desired final energy ( • ) and will never be lower than ( • ). If the user wants to fully charge his battery, he just needs to set = 1: where, is the EV desired final SOC at the end of the charging; is the charging efficiency [25]; ( ) is the SOC of the discharged energy at iteration " ". Equation (14) is introduced to limit the discharged energy. If it is not introduced, the discharging process may not respect the SOC limits.
The EV maximum charging and discharging active power rates are proposed in this paper as in (15) and (16) considering other power limits in this paper. The minimum value is chosen among all the values which determine the charging and discharging power of the EV. If they are not considered, the charging and discharging powers may overpass the recommended limits and create additional problems for the system.
where, is the maximum allowed charging or discharging power rate set by the charger; , ( ) and , ( ) are the maximum charging and discharging power rates set by the EV owner; , and , are the maximum charging and discharging power rates allowed by standards, there is no standard for the discharging mode up to now; both , and , values could be regulated by the algorithm if higher values do not affect the performance of the system, the reason for this is to satisfy the client by attaining a SOC level close to the desired level when the period of charging is short; is the discharging efficiency. It is not recommended to discharge the EV battery more than the calculated limits for many reasons: (i) energy loss due to the efficiencies of discharging and charging processes; (ii) the battery life would be shortened; (iii) the charging rate may increase over its limit; and (iv) the SOC may not attain the desired level. This minimal overpassing load has to be reached while also searching for an optimal value of a second objective that consists of minimizing the total consumed electricity cost.
The absorbed and injected active power rates by the battery are bounded as in (17) and (18) by dynamic limits varying according to the charging and discharging conditions of operations. In the literature, they are considered constant, while in this paper, they are considered dynamic, which gives a realistic and good functioning of the system.
where, ( ) and ( ) are usually equal to zero in a normal case, but they could be variable according to the needs on the bus.

State of Charge (SOC) Constraints
Equation (19) represents the cumulative SOC in the battery starting from an initial value ( ) = until instant "t". starting from an initial value.
The predicted available SOC at home is proposed in this paper as in (20). The available energy is the energy value that could be used to charge the EV's battery for reaching the previously defined objectives without exceeding the predefined limits. If this equation is not calculated, the EV owner may not be able to predict what will be the final SOC of his battery. The battery may not be charged to the desired level, and the discharging process is undefined.
The discharged SOC ( ) should follow Equation (21), where ( = 0) = . The iteration counts the number of occurred discharging at different instant " ". = 1 means the first occurred discharging, etc. If this equation is not introduced, the discharging mode may not respect the SOC limits.
Equations (22)- (24) are proposed in this paper. They ensure that the total electrical energy used for discharging the battery ( ) should be within upper and lower limits. It is set by the user. Where, = ( ) is the initial SOC of the battery.
The used energy in the battery should be between its minimum and maximum limits as in (25): If the EV is in the discharging mode, and the battery's energy becomes equal to the lower limit, the discharging mode is turned off, and the idle mode is turned on until the energy in the battery becomes greater than the lower limit. If the EV is in the charging mode and the battery's energy becomes equal to the upper limit, the charging mode is turned off, and the idle mode is turned on until the energy in the battery becomes lower than the upper limit.
At the departure time , Equation (26) may guarantee that the battery's energy is equal to the desired final energy ( • ). But it could be lower if there is not enough available energy at home.

Reactive Power Constraints
All the reactive power equations presented in this subsection are mainly proposed in this paper to regulate the voltage deviation on the power grid and limit the absorption and injection of the reactive power. In the literature, these limits are not considered, which may create problems on the power factor limits if the injected or absorbed quantity of reactive power is not controlled.
A total load of reactive power is obtained from (27) or (28). Equation (27) is used when the DSO orders the EV charger to inject ( ( )) or absorb ( ( )) reactive power. Equation (28)  The respected upper and lower limits of the reactive power are calculated in (29) and (30): and are the minimum and maximum power factor limits (between 0.8 and 1.0 for residential buildings [43]). The reactive power is used to regulate the voltage profile in case the active power is not sufficient to maintain the voltage within the standard values. It is assumed that the charger is able to inject and absorb reactive power between values calculated in (32). These limits are set by the DSO.
The total load reactive power at home, including EV must satisfy (31).
The charger is able to inject and absorb reactive power between the minimum and maximum limits as in (32):

Voltage Constraint
Equation (33) defines the voltage at home between the minimum and maximum limits. The voltage on the transformer has to be confined between these limits [23].

Management of Home Power
This paper gives priority to the DSO's satisfaction in which the discharging occurs, and the charging stops when ( ) ≥ ( ). In a few cases, the available energy at home may not be sufficient to charge the battery to the desired level. Therefore, the EV owner may not be satisfied. In order to satisfy the EV owner, there are two possibilities. The first one is to reduce the base load consumption at home. This could be done by managing the loads using smart systems or by informing the user to turn off some electrical appliances. The second one is to increase the circuit breaker nominal rate. Thus, it increases the ( ) limit. In this paper, the problem is solved using the first method. Two original equations are proposed for this purpose, as in (34) and (35). The proposed algorithm predicts the available SOC at home ( ) and if it is less than , it notifies the user how much power he should reduce at home in order to attain . In another meaning, it notifies him what appliances he should turn off in order to use the vacant energy to charging his EV battery to the desired level. Equation (34) is the general case when the reduced power at home ( ) could vary when the EV is plugged-in, and (35) is a particular case when is considered constant during the charging process. These two equations are used in the algorithm but they are not constraints.

Proposed Algorithm to Solve the Problem
The proposed algorithm is divided into two main parts. The first part is the optimization model in which the algorithm starts to control and manage the active power at home by charging and discharging the EV. The main objective is to minimize the electricity cost at home, respecting the constraints mentioned before. Because some constraints are non-linear, the optimization model is considered as non-linear programming in which we have used the "Mixed-Integer Non-linear Programming" (MINLP) algorithm to solve the equations. MATLAB is used for simulation, and the algorithm used is "fmincon" with an interior-point solver, which is able to solve MINLP problems.
The second part consists of regulating both the active and reactive power flow whenever needed in order to reduce the voltage deviation on the transformer, respect its limit, and provide ancillary services to the distribution network.  (6) 21 Active Power Limit for the branch circuit breaker Equation (7) 22 Maximum available active power at home at instant "t" Equation (8) 23 Minimum Active Power Limit Equation (9) 24 Available energy at home to charge the EV Equation (20) While "Available energy at home to charge EV" < "Needed energy to … charge the EV to the desired SOC level" as in Equations (34) EVs inject reactive power respecting its maximum and minimum limits as in Equations (31) and (32) 48 Go back to Step 45 and measure V 49 EVs absorb reactive power respecting its maximum and minimum limits as in Equation (31)

Different Scenarios Are Studied at Home
This paper studies four different scenarios for a home with a single EV: (i) a home without EV (named BL); (ii) a home with EV using the uncoordinated charging strategy (named U); (iii) a home with EV using coordinated charging (only), (named CC), the discharging mode is deactivated; and (iv) a home with EV using coordinated charging and discharging (named CCD). All these scenarios are studied for 3 different pricing mechanisms: (i) fixed price, (ii) time-of-use, and (iii) dynamic price (Figure 4).

Considerations for a Single Home
The following values are considered for calculation: , and SAE J1772 Standard. , is supposed to be equal to 1.92kW for level 1, 5kW and 10kW for level 2 and higher levels respectively. = 0.2, = = 93%.

Results for a Single Home
In this subsection, the previously described algorithm is validated by means of simulations performed for each scenario mentioned before. Validation is performed through a comparative study on the following profiles: (i) the total power, (ii) the EV charging and discharging power rates, (iii) the voltage on the distribution board, (iv) the energy cost, (v) and the power losses.

Power and Charging Rates Profiles
The baseload power profile is considered deterministic [46], and according to [34], although a stochastic model is realistic, it will not affect the results significantly. This is assuming, as in Figure  5, RULP is constant.
Results in Figure 5 show that the CCD strategy is the best one, in which the total load respects the limits imposed by the circuit breakers. The EV battery is also charged to the desired level.

Voltage Profiles
The voltage profiles of the four mentioned scenarios are presented in Figure 6. The results show that the CCD strategy is the best one, in which the voltage profile is maintained within the required limits. Moreover, one has to mention that CCD strategy helps the user to improve the power quality. The installation of capacitor banks or tap transformers is then avoided, and the total cost of the electrical installation is reduced. It is important to mention that the control of the reactive power could be done using only the charger without putting any stress on the battery in order to reduce its life loss.

Energy Cost Profiles
The energy cost profiles of the four mentioned scenarios are presented in Figure 7.
= 0.85 for the CC and CCD strategies, and 1 for the U strategy, while Table 1 represents the study of = 1 for the CC, CCD and U strategies.  Table 1 presents a comparison between the four different scenarios stated before. The studies shown are for a dynamic electricity price, and = 1 for coordinated charging (CC), coordinated charging and discharging (CCD), and uncoordinated charging (U) strategies. The power loss in percentage is the difference between the total power loss of the Home + EV and the total power loss due to the baseload only. It is obvious that our proposed strategy "CCD-EV" has reduced peak demand compared to other strategies, which becomes 7.36 kW instead of 10.079 kW for the uncoordinated strategy U-EV and 8.159 kW for the coordinated strategy CC-EV. Moreover, it shows that the current value has respected the circuit breaker limit of 40 A, while other strategies have exceeded this limit, 54.777 A for U-EV and 44.342 A for CC-EV. In addition, our proposed strategy CCD-EV has respected the voltage drop within the limit of 2% while other strategies did not, in which the value is 2.993% for U-EV and 2.174% for CC-EV. Regarding the power losses, there are also improvements, in which the losses using our proposed strategy (CCD-EV) are almost 24.8466% while U-EV has a power loss of 28.8594% and the CC-EV also has 24.8875% of power loss compared to the initial case without EV. It can be concluded from this table that our proposed strategy has improved the performance of the low-voltage electrical network. Table 2 shows the energy cost at home, including the EV using three different pricing mechanisms represented in Figure 4. The study is done where = 1 for U, CC and CCD strategies. It can be seen that all strategies U-EV, CC-EV and CCD-EV have the same electricity cost when a fixed electricity tariff is used as shown in the second row. However, our proposed strategy shows better results when Time-of-Use (TOU) and dynamic pricing are used as shown in the rows 3 and 4. This is due to the fact that our strategy can discharge when the electricity price is high and charge when the electricity price is low in order to minimize the electricity cost at home and maximize the profit from selling electricity to the network.

Considerations for a Cluster of Homes on the Same Bus
The presented study in the previous section is generalized to a larger area of homes on the same bus. The four presented scenarios will be considered in this section in order to see their impact on the bus and on the distribution grid. In this study, the IEEE 13 node distribution test feeder is considered ( Figure 8) [47], the simulation is done using OpenDSS and MATLAB. The EV owners and their houses are located on bus 634 in which the penetration level of EVs is equal to 100%, in another meaning, every home has its own EV. Two different studies are undertaken; the first one is when the EVs are able to supply only active power to the grid, and the second one is when the EVs and their chargers are able to supply active and reactive power to the grid, respectively. OpenDSS is software that simulates a distribution network. In this paper, it is used in order to see the impact of the proposed algorithm not just at home levels but on the distribution network also. The software gives detailed results regarding the voltage drop, line and transformer losses, active and reactive power flow, and many others. For the studied case in this paper, we firstly considered a single home, then a cluster of homes on the same bus. The bus is a part of a network. Hence, it is necessary to study the complete network in order to see what will be the impact of different scenarios on the whole system, not just on a single transformer. OpenDSS is a powerful tool that allows the user to do a load flow analysis once it is run. It simulates and calculates the active and reactive power flow, the voltage, the current, and the phasing angle on each element of the system.  Figure 9a,b present the voltage profiles of the total load on the bus for the four mentioned scenarios. In Figure 9a, EVs are used to supply only active power to the grid for the CCD strategy. It can be seen that all strategies have exceeded the voltage limit imposed by the bus during the on-peak period, although active power is injected for the CCD strategy. Moreover, due to the previously mentioned constraints, the injection of the active power cannot exceed the imposed limits. In Figure  9b, the EV chargers at homes have injected a small amount of reactive power to the grid when the CCD strategy is considered. In this case, the voltage profile is improved, and it is confined within the required limits on the bus.

Summary of the Main Outcomes of the Proposed Algorithm
To summarize the study, the algorithm controls the flow of the active and reactive power from the EV by using its bidirectional converter. The control of both active and reactive power brought significant improvement at home and distribution network levels. The main outcomes of the proposed algorithm are stated as follows: • The power limit of the transformer is respected, • The techno-economic losses on the transformer and lines of the network are reduced, • Voltage limits on the network and transformer are respected, • The electricity cost at home is minimized.

Conclusions and Future Work
This paper has suggested an algorithm for improving the voltage profile, reducing the energy losses, controlling the active and the reactive power flows, and minimizing the electricity cost during the charging and discharging modes of an EV at home. Simulation results obtained for a small scale (a home with one EV) as well as for a large-scale system (a cluster of homes on the same bus) show that the proposed algorithm guarantees a better performance of the whole system in difficult situations. It lets the householder avoids installing a higher rating circuit breaker, thus, reducing the electricity bill. It also allows the DSO to avoid installing capacitor banks and tap changing transformers, thus reducing the total electricity cost of the infrastructure. In this paper, we take a home as an example, but the same concept can be applied to any type of building such as residential commercial, industrial, institution, even parking lots etc. Moreover, the deployment of electric vehicles (EVs) helps the distribution system operator (DSO) to reduce the investment cost by discarding the installation of new capacitor banks in buildings and on the grid. This can be done by using the existing bidirectional converters in the EVs in order to absorb and inject reactive power in order to increase the stability of the grid and provide ancillary services. From the results obtained, the proposed algorithm shows that it is even worth using EV in homes to manage the active and reactive power flow. In future work, this study will be completed by introducing renewable energy sources and considering the stochastic power profile instead of the deterministic one.

Conflicts of Interest:
The authors declare no conflict of interest.