EV Smart Charging in Distribution Grids–Experimental Evaluation Using Hardware in the Loop Setup

The rising demand for electric vehicles (EVs) in the face of limited grid capacity encourages the development and implementation of smart charging (SC) algorithms. Experimental validation plays a pivotal role in advancing this field. This article formulates a hierarchical mixed integer programming EV SC algorithm designed for low voltage (LV) distribution grid applications. A flexible receding horizon scheme is introduced in response to system uncertainties. It also considers the practical constraints in protocols, such as IEC/ISO 15118 and IEC 61851-1. The proposed algorithm is verified and assessed in a power hardware-in-the-loop testbed that incorporates models of real LV distribution grids. Furthermore, the algorithm's capabilities are examined through eight scenarios, out of which four focus on the uncertainties of the input data and two address the engagement of extra grid capacity restrictions. The results demonstrate that the SC algorithm adequately lowers the EV charging cost while fulfilling the charging demand, and substantially reduces the peak power as well as the overloading duration, even when faced with input data uncertainty. The additional grid restrictions in place are proven to improve peak demand reduction and overloading mitigation further. Finally, the limitations and potentials of the developed algorithm are scrutinized.


I. INTRODUCTION
Smart electric vehicle (EV) charging has gathered interest due to its potential in mitigating grid congestion [1], [2], enhancing renewable energy utilization [3], and improving the profitability of different parties [4].
A plethora of EV smart charging algorithms have been developed in the past decade.The comprehensive reviews of these algorithms from the angle of, e.g., mathematical model/algorithm, control structures, and application scenarios, have been addressed in studies like [5], [6], and [7].The common EV smart charging algorithm can be categorized into rule-based or heuristic algorithms, conventional optimization approaches like linear, quadratic, mixed integer programming (MIP) and nonlinear programming, and the AI-enabled method.Centralized, decentralized, and hierarchical control designs are widely adopted as control structures, while the optimization objectives are often operational or economic.
The goals of EV smart charging algorithms designed for distribution grid applications regularly consist of three pillars: 1) grid operation assurance; 2) energy cost reduction; and 3) the fulfilment of EV charging requests.Set minimizing the energy cost as (part of) the objective function is very standard in smart charging algorithms development, such as in studies where MIP method are used [8], [9], [10], [11], and in work [2] where a metaheuristic method is suggested.With respect to considering grid operational requirements, researchers hold various preferences.For example, grid constraint is out of the scope in the study [10] while some other research embeds grid features like load flow into the algorithm's objective functions [8], [12].In this case, heavy computations or a prelinearization process could be needed.On the other hand, meeting the user charging demand is not always covered in the existing research.Nevertheless, study [13] adapted the EV charging flexibility in the algorithm and research [8] include EV energy demand in the constraints.Although EV charging demand was not specifically mentioned in [11], the fairness in scheduling EV charging was addressed.In regard to control and communication structure design, centralized and decentralized control schemes are mixed-implemented in the above reviewed work.The largescale smart charging installation in a neighbourhood-level distribution grid introduced in [14] implied that the most flexible yet practical control scheme for grid constraint-involved EV smart charging in the Netherlands, given involved entities, is hierarchical control.
The practical-oriented hierarchical MIP EV smart charging algorithm proposed in our work, namely SC-Alg, aims to minimize the energy cost, maximize the local renewable energy generation self-consumption and meet the EV charging demand in the form of weighted combined objectives, while keeping the power exchange within the grid capacity which is reflected in the constraints.
An essential feature of the empirical EV smart charging algorithm is its capability to cope with the stochasticity of local renewable energy generation, load consumption, EV user behavior, as well as grid status.The common approach for stochasticity in smart charging algorithm development includes, but, is not limited to stochastic optimization [2] and robust optimization [10] when at least part of the characteristics of the stochasticity can be adapted into the optimization problem.Alternatively, the receding horizon method is often picked for its passive stochasticity resolving mechanism, which is to update uncertain parameters and reoptimize regularly [9], [15].A fixed horizon length is applied in most cases, yet when a desired optimization duration mismatches with the horizon length, a flexible horizon window size is superior [16].The next challenge for the empirical smart charging algorithm is to adapt the implementation requirements.The current commonly employed ac charging standard IEC 61851 instructs that the minimum nonzero EV charging current setpoint is sent to the EV via PWM signals through control pilot (CP) pin in the charger is 6 A [17].Besides, the EV charging current can only be adjusted with discrete steps, and the step size depends on the manufacturing design of the electric vehicle supply equipment (EVSE) and the EV [18], [19].Most of the existing works assume the EV charging current is continuously adjustable from zero whereas only a few research address these two constraints.The discrete charging current was emphasized in [20] and [21] while the minimal 6 A nonzero setpoint value is not mentioned.Although the authors in [18] and [19] accommodated both the minimum 6 A limit as well as the discrete setpoint interval in their algorithms, the discrete setpoint in their research was achieved by rounding up/down to the nearest integer value after the optimization.
To tackle the abovementioned implementational challenges, SC-Alg integrates the current setpoint constraints and the passive stochasticity handling mechanism through the MIP approach with a flexible receding horizon technique.
To test the functionality of the proposed algorithm and its impact on the LV distribution grid, especially the passive stochasticity handling feature, a real-time virtual representation of the system is desired.Besides, flexibility in defining test scenarios is necessary to fulfil this goal.This can be realised by using power hardware-in-loop (PHIL) containing a digital real-time simulator (DRTS) which runs the real-time digital twin (RTDT) of the target system.This real-time (RT) PHIL facility is especially beneficial for this type of research because the DRTS is capable of conducting simulations of wide-ranging power system models under numerous schemes in both transient and steady-state [22], [23], [24].The RTDT makes the tests on large systems with diversified scenarios more flexible, scalable, and achievable within a reasonable time span.Furthermore, the RTDT-embedded HIL is suited for demonstrating and verifying the innovation ideas with three or higher technological readiness levels [25].
In the realm of EV and grid integration, the HIL facilities are often used to evaluate the performance of the target hardware and their impact on the grid; and test the system integrity including the intercommunication.A lab-scale flexible testbed for EV charging was developed in [26], with which the operation of the EVSE and EV, the implementation of communication protocols are tested.In the study, a dc charging on/off event with 960 V and 95 A was successfully conducted.The authors in [27] explored the grid resilience during extreme EV fast charging through RT-PHIL grid simulations.The transient dynamics of the tested grid, including branch current, nodal voltage, and frequency, are evaluated with the RT grid simulation.
EV charging algorithm-incorporated controllers are also commonly tested with HIL simulations to verify their functionalities.In [28], an EV charging algorithm equipped controller for EV onboard bidirectional ac/dc converter is developed and verified with HIL simulation.The developed controller is integrated with an additive increase/multiplicative decrease EV charging algorithm for voltage drop mitigation in the distribution grid.The RT grid simulation indicates a 0.013 p.u. minimal voltage increase with the applied controller, proving the effectiveness of the algorithm.The authors in [29] tested the RT energy management controller for EV charging via a PHIL testbed that consists of one grid-connected microgrid simulated by DRTS, and two EVs that are emulated by two HIL units.The linear convex optimization equipped in the controller aims to minimize the cost of energy consumption at the workplace, and it is proven to be capable of reducing the weekly power consumption cost by 14%.
The application of HIL in investigating the innovative EV charging algorithm has become more popular as it bridges pure computer simulation and actual implementation.The HIL simulation offers a flexible platform for algorithm/hardware interface testing [30].Placing the relevant hardware components in the HIL testbed introduces factors that can potentially alter the algorithm's performance.These factors include but are not limited to information flow, the refresh rate of parameter exchange, communication delay, response lag, and grid status [31], [32].The authors in [33] proposed an EV adaptive charging characteristics expectation algorithm with a primary objective of distributing the available capacity of the local electricity network evenly and efficiently among active EVs.The algorithm is validated through HIL simulations in which one Nissan leaf and one BMW i3 are connected to two sockets of one 22 kW charger separately.The HIL simulation results show that an 88%-97% network capacity usage rate is achieved.Similarly, a decentralized demand response-based EV charging algorithm for residential community applications is proposed and inspected with both software simulation and HIL simulation in research [30].The results not only prove the efficacy of the algorithm, but also signify that the high resolution contributed by HIL can reveal phenomena that can hardly be observed in pure software simulations, such as power consumption difference due to hardware losses, voltage bounce, and dip caused by power variation and transient features of the grid [30].
Even while [34] emphasizes the importance of the experimental study on the impact of EVs on the distribution grids, the offered results are predominantly simulations.In our work, we develop a laboratory test bed to showcase the highlighted aspects in real-time hardware in the loop environment.The authors in [35] used grid voltage regulation control for a 2-kVA laboratory EV charger to validate effectiveness up-to charging currents of 5 A. Our work demonstrates efficacy at much higher currents and voltages that include the practical limitations associated with 6 A standard and includes a smart charging algorithm for many other variables using the PHIL-RTDS environment.
Nevertheless, for such experimental algorithm validation with different and scalable distribution grids and the ability of flexible testing conditions at reasonable costs, an RTDT-based HIL setup is necessary.This article utilizes such a setup to validate the proposed SC-Alg experimentally; explore its impact on the LV distribution grid; test the operation of relevant components and interfaces from both power and communication perspectives; and scrutinize its limitations and potential with eight scenarios from the perspectives of inaccurate PV/load prediction, EV information mismatch, and grid limitation incorporation.The extensive guidance on how to upgrade SC-Alg as well as the testbed is subsequently encapsulated.The major contributions of this research can be summarized as follows.
1) Suggesting a hierarchical MIP EV smart charging algorithm designed for LV distribution grid applications.A flexible receding horizon scheme is introduced as a passive mechanism to handle stochasticity within the algorithm.2) Integrating the implementational constraints arising from EVSE-EV communication protocols into the proposed algorithm.3) Performing a comprehensive assessment utilizing an RTDT-based HIL setup encompassing eight scenarios.
The scenarios explore the algorithm's performance considering input information stochasticity, user behavior uncertainty, and the integration of grid limitations.4) Offering detailed guidance for upgrading the proposed algorithm, drawing from the results obtained through HIL simulations.The rest of this article is organized as follows.The architecture of the whole system, including the proposed SC algorithm, is outlined in Section II.The PHIL testbed introduction and its interaction with the digital model and the SC algorithm are explained in Section III.The detailed description of the simulation setup, including input data and test scenarios, can be found in Section IV.Section V presents a thorough analysis of the simulation results.Finally, Section VI concludes this article.

II. ARCHITECTURE OF SYSTEM MODEL AND ALGORITHM A. SYSTEM ARCHITECTURE
Our algorithm SC-Alg has a hierarchical structure with one centralized and one distribution level, as shown in Fig. 1.The Sub-aggregator (Sub-aggr) at the distribution level is responsible for the behind-the-meter optimization at the grid node level.The primary goal of Sub-aggr is to obtain the optimal EV charging plan as well as the energy usage strategy for the local node by solving the (MIP problem.On top of that, a Central-aggregator (Ctr-aggr) is responsible for communicating the grid condition with the distribution system operator (DSO) and coordinates with the Sub-aggrs to ensure the grid capacity limitation is not violated.The Sub-aggr can be placed at a company campus, a household, or a public charging station connected to a node in the distribution grid.
The SC-Alg fits multiple control structures in different actual application scenarios.A possible control and communication structure used in this article is illustrated in Fig. 1.The grid status can be monitored by the grid estimations operated by the DSOs [36].The obtained available grid capacity is then sent by the Capacity Provider-DSO, to the Flexibility Provider-Ctr-aggr, over the Open Smart Charging Protocol (OSCP) [37].Then the Ctr-aggr, which serves as a Virtual Top Node, shares this grid status information with the Sub-aggr, which acts as a Virtual End Node, through Open Automated Demand Response (OpenADR) standard [38].And finally at the distribution level, the optimal EV charging current, which is the maximum allowed phase current that the EV can draw from the charger namely setpoint, is calculated and sent from the Sub-aggr to the EVSE through the Open Charge Point Protocol (OCPP) [39].Note that the OSCP and OpenADR can largely cover the same scenarios and are interchangeable in many EV smart charging contexts depending on which party presents as Capacity/Flexibility Provider and Virtual Top/End Node.Further discussion on the protocol implementation is out of scope for this article.
This study uses SC-Alg as an intermediary between the DSO and the EV charger.SC-Alg can be operated by two independent entities; e.g., the Virtual Power Plant aggregator is the Ctr-aggr, while an EV aggregator/Charge Point Operator (CPO) or a local energy management system (EMS) is the Sub-aggr.Alternatively, SC-Alg can be administrated solely by the CPO/EMS.In some cases, the DSO itself can take the role of a Ctr-aggr [40], [41].

B. SMART CHARGING ALGORITHM 1) OBJECTIVE FUNCTION
The primary goal of SC-Alg is to minimize the total node cost C tot n .The objective function (1) has the following two parts.
1) The compensation cost paid to the EV user from the Subaggr if the actual charged energy is less than the energy target.The energy target is what would be provided to the EV if an uncontrolled charging (UNC) policy was applied (B UNC n, j,T d j ).
2) The nodal net cost of buying/selling the electricity from/to the grid.
The parameters of the objective function and constraints of SC-Alg are listed in Tables I and II, respectively.

2) CONSTRAINTS
According to the current commonly employed ac charging standard IEC 61851 [17], the EV charging current setpoint is sent to the EV via PWM signals through the CP pin in the charger.The minimal nonzero charging current setpoint is 6 A, and the setpoint value can only be adjusted in discrete intervals.The charging current setpoint is set to be integer values in SC-Alg and is constrained in the equation listed below.The EV charging power is computed with the phase charging current setpoint, the number of phases and the node voltage.
The EV battery energy is calculated by integrating the charging power with time and multiplying the onboard charger efficiency.With the battery energy and capacity, the EV SoC is obtained.
The power exchange between the grid and the local node is presented as follows: where the import/export power from/into the grid is the positive/negative part of the node-grid exchange power, respectively.
The import/export node current/power i(p) . This value could be contracted between the local node and the DSO, or given by the Ctr-aggr when the central grid congestion management function is operating.
3) EV CHARGING MODEL The EV battery management system (BMS) can run its own charging strategy within the setpoint-defined maximum charging current.A study based on more than 10 k detailed charging session data suggests that EVs' dominant ac charging strategy is the constant-current-constant-voltage (CC-CV) method [42].Hence, this article assumes the EV BMS deploys a CC-CV strategy to set the EV's actual charging current i e+,Act n, j referring to the setpoint sent through the EVSE.The BMS charging strategies are not incorporated in SC-Alg, and this model is only used to emulate the EV charging performance.The CC-CV method is simplified in this article in that the BMS sets EV's charging current at its rated value I EV n, j until the SoC reaches the CC-CV switch point S CV n, j .After that, the charging current decreases linearly versus SoC till the car is fully charged, as exhibited in (9).

C. ALGORITHM EXECUTION AND THE FLEXIBLE RECEDING HORIZON SCHEME
SC-Alg algorithm is written in Python, and a Linear Programming, Quadratic Programming, and MIP specialized commercial solver Gurobi is applied to solve the optimization problem.
Considering the input data uncertainty, a passive stochasticity response mechanism-flexible receding horizon technique-is equipped in SC-Alg as introduced in Section I.This scheme is basically to reoptimize the system regularly with updated information.The optimization can be triggered in a fixed time interval or by events like new EV arrival, grid constraint adjustment, and the estimated-real SoC disparity.
SC-Alg uses the flexible receding horizon method to set its optimization horizon, and the length of the horizon is determined by the last future departure EV.How far to the future SC-Alg can optimize is limited by the prediction data availability and the computational power.To avoid an excessive optimization horizon, long-term parking EVs can be exempt from the "future departure EV" list and will not be included until a certain period of time, like 24 h, before their departures.Upon triggering reoptimization, the optimization horizon is automatically updated, and then the new optimization results are sent to the chargers to replace the old setpoints.A schematic of SC-Alg execution and the explanation of the flexible receding horizon is presented in Fig. 2. In this figure, each coordinate represents one charger while each block symbolizes one car, with its length indicating the parking duration.When a new car (Chr1-EV2) arrives at charger 1 and triggers the reoptimization at t i , the aggregator checks the in-use charger 1, 2, and 4, and compares the EV parking times of the three connected EVs.The latest departure time of all EVs (T d max = max{T d j | j ∈ J}) is identified and the optimization horizon T J i is determined as With this flexible receding horizon method, SC-Alg can run continuously and automatically adapt to the modification of the  input parameters or the uncertainties in them.The Sub-aggr accesses the local PV generation and load demand profile through smart meters and obtains the dynamic energy price information published in the market by the central price settlement entity.The EV-related information like the EV type, arrival SoC, and expected departure time is provided by the user upon arrival through, e.g., a smartphone app.

III. HARDWARE-SOFTWARE CONFIGURATION A. HIL SETUP
The schematic of the HIL setup used in this article and its lab photo are shown in Figs. 3 and 5, respectively [43].The whole setup consists of four parts.The solid lines in the plot depict the power flow while the information flows are illustrated in dotted lines.
The controller in block 1 is the brain of the whole setup; it has one target machine-a DRTS OPAL-RT 5700 and one host computer for the user interface.The testing model, containing a distribution grid with loads, PVs and EVs, is built with MATLAB /Simulink in the host computer and converted to C code, then uploaded to the simulator through the OPAL-RT interface software RT-LAB.When the model runs in DRTS, the host computer monitors its performance and communicates the input/output data through TCP/IP protocols.The DRTS manages the physical I/O signals and controls/communicates with the hardware devices in the power loop part.SC-Alg written in Python script also runs on the host computer.SC-Alg computes the optimal charging strategy and interacts with the model in DRTS.In block 2, the grid model inside the DRTS and a grid emulator comprising three 1.5 kVA rated power California Instruments AST1501 power amplifiers sits.One node of the grid is picked and each phase is emulated by a power amplifier.
The next component is the EVSE in block 3, an Alfen EVE Single Pro-Line ac charger that can provide power in both single and three-phase with a maximum 32 A phase current.When the smart charging is not initiated, the charger simply provides the power requested by the EV emulator as long as it is not higher than the maximum allowed phase current.However, when SC-Alg takes effect, the computed optimal current setpoint is sent to the EVSE from the DRTS via Modbus TCP/IP.Conversely, the EVSE measures the voltage and current drawn by the car and communicates them back to the DRTS.
The last part of the testbed, which is placed in block 4, is the EV emulator composed of one signal tester and one power circulation unit.The Walther-Werke EV signal tester can communicate the EV connection/ready-to-charge status to the EVSE through the CP pin.Even though the EV signal tester has the option to send up to 63 A rated current signal to the EVSE, a maximum of 16 A current is allowed to pass through due to its hardware limitation.The power circulation unit in block 4 processes the power with two Delta Elektronika SM15 K bidirectional ac/dc power supplies that are connected back-to-back, forming a conventional regenerative AC load (ac-dc-ac) and then returns this power to the connection between the power amplifier and the EVSE.The quantity of the circulating power is controlled by manoeuvring the second power supply's current while keeping the dc link voltage constant.Each power supply can process up to 15 kW power at a maximum of 500 V or 90 A.
The power circulation feature of the setup allows a much higher charging power with built-in bi-directionality as compared to the ac power amplifier, which is unidirectional and only supplies the losses of the system.More technical details about the experimental setup can be found in our previous work [43].

B. TESTBED/ALGORITHM INTERFACE
To ensure a steady data transmission between the SC-Alg in the host computer and the model in the target machine during real-time simulation, some adaptions as well as an extra interface are requested (Fig. 4).The Python API in DRTS's software RT-lab is employed to allow the variables to be read and written from/to the target machine while the RT model is operating.A one-minute reoptimization trigger resolution ensures sufficient timing for parameter exchange and optimization computation.Besides, frequent reoptimization can improve the stochasticity handling ability.
SC-Alg can serve in several nodes in a distribution grid simultaneously over multiple days.Schematic Fig. 4 shows how SC-Alg interacts with the model and how the simulation times are synchronized.
1) Once all the variables are initialized, the grid model launches in DRTS, and its simulation timestamp (t rt ) is read by SC-Alg.2) Whenever the simulation timestamp reaches the multiple of one timestep (t rt = k × t, k ∈ Z), the SC-Alg checks if a new round of optimization needs to be triggered.3) If optimization is requested, the SC-Alg would go through every relevant node and calculate each node's best EV charging profiles separately.This whole calculation process is finished within one timestep.4) The SC-Alg waits till the DRTS's simulation time reaches the next timestep (t rt = (k + 1) × t, k ∈ Z), then sends the calculated optimal charging profile to the target node in the grid model.5) Repeats the whole process until the RT simulation ends.

IV. ASSUMPTIONS AND TEST SCENARIOS A. GRID MODEL AND INPUT DATA
The grid model used in this study is adapted from data of a Dutch rural LV distribution grid as a representative example [44].Therefore, only the results pertaining to SC-Alg's performance relative to defined base case are relevant and the conclusion cannot be inferred to reflect actual congestion issues in actual Dutch grids.This grid has in total 19 nodes, with loads connected at nodes 5, 15, and 19, EV chargers connected at Node 5, 15, and one PV system installed at Node 5, as illustrated in Fig. 6.Nodes 5 and 15 are equipped with one Sub-aggr each for local optimization while the Ctr-aggr oversees the whole grid conditions.
Each node is assumed to have a 3 × 50 A connection capacity.Further, Nodes 5 and 15 are two small businesses where employees park and charge their EVs during weekday working hours.It is also assumed that the grid is three-phase balanced, and all EVs are charged with three phases.Considering the power limitation of individual testbed components, the emulated EV's maximum charging current is set as 16 A per phase.This is a reasonable assumption as most onboard chargers are rated for 3 × 16 A.In the simulation, each charger serves a maximum of one EV per day.Among all four simulated EVs, only EV1 is represented in the PHIL system while the others are virtual.The parameters of two types of EVs (Tesla Model 3 Standard Range and Model S P100D [45], [46]) are used in the model.All four EVs share the same arrival SoC of 40% and the expected departure SoC at 100%.
One arbitrary summer working day 9:00-17:00 is selected for the PHIL simulation.The load consumption power profile is derived from Dutch standard load profiles [47] with the yearly energy consumption value E LL,r provided in the grid model.The PV profile is generated based on the Dutch historical solar irradiation data [48].A 25 kWp PV installation in Node 5 is assumed.It is found that dynamic electricity price which encloses grid loading information could guide the consumer's behavior and significantly mitigate grid congestion [49], [50].The adoption of a variable energy tariff, combined with an EV SC algorithm is therefore preferred, in the absence of a mature congestion market incorporating grid loading information in the Netherlands [51].Historical Dutch Day-Ahead market (DAM) price data is utilized as the benchmark for determining electricity purchasing prices as the DAM price trend frequently aligns with the electricity consumption patterns during peak and off-peak periods.A constant value of C e(sell) t = 20 €/MWh electricity selling price, which is always lower than the selected buying price, is set.Compensation from the Sub-aggr to the EV user for the inadequate EV charged energy compared to the UNC scheme is set to be C comp n, j = 0.1 €/kWh.This value instead, is always higher than the selected electricity buying price.Note here that DAM is much lower than the retail electricity price (capped at 0.4 €/kWh in 2023 [52]) as a wholesale market price, and thus the C e(sell) t and C comp n, j are also low.However, the absolute value of the electricity price is not the imperative factor of the algorithm's performance; it is the ratio between C e(buy) t , C e(sell) t , and C comp n, j that matters.Other costs such as PV installation and maintenance costs are not considered.
The forecast PV and load profiles p PV,Fcst n,t , p LL,Fcst n,t of Node 5, and the energy price are presented in Fig. 7.

B. SIMULATION SCENARIOS
The testbed has subsequently been used to study the effect of uncontrolled and controlled charging on the simulated distribution grid for a total of eight different scenarios.Apart from two scenarios that serve as a benchmark: the uncontrolled charging (Case 0) and the proposed SC-Alg running without extra intervention (Case 1), the system was tested with six other scenarios with different impact factors.These scenarios are categorized into three groups: 1) inaccurate PV/load prediction; 2) EV information mismatch; and 3) grid limitation incorporation.The first two groups focus on testing SC-Alg's performance with the impact of stochasticity, while the last group explores the grid congestion mitigation potential of the SC-Alg.Each scenario only has one parameter changed with respect to Case 1 to avoid cross-correlation issues.The input is multiplied by a random multiplier generated by a normal distribution with its mean μ = 1.It is reported that even though the weather forecast technique has developed significantly nowadays, intra-hour forecast errors of solar irradiance could still be up to 30% [53].Therefore, the standard deviation σ of the normal distribution is set to be 0.15.On top of that, a correction factor C is added to ensure the total PV generated energy stays the same compared to the other cases, as stated in (10).
Case 3. Inaccuracy in Load Forecast: A similar process is applied to the load profile.The same random multiplier as Case 2 and a correction factor is adapted.Both predicted and actual PV and load profiles are shown in Fig. 7.Note that the SC-Alg still uses the provided forecast profiles (p PV,Fcst t , p LL,Fcst t ) for the optimization.

Case 4. Mismatch in EV Charging Current Information:
As mentioned in Section II-B3, the charging current setpoint is transmitted from EVSE to EV.However, the onboard BMS decides the actual current to be drawn, ensuring it remains below the setpoint.Even when the BMS is configured to adhere to the specified setpoint, the actual current drawn can be up to 10% lower than the provided setpoint [54].If the BMS is set to run an internal charging program which only uses the provided setpoint as the upper limit, the maximum bias between the actual current drawn and the setpoint per phase can be anywhere between 0% and 100%.For example, a maximum 53% of difference between the setpoint and real charging current in "low mode" was reported in [55].This charging control mechanism poses a challenge to smart charging when an unknown gap between the given setpoint and the actual EV charging current exists.Case 4 is then designed to test how much the inequivalent EV charging currents can affect the SC-Alg's behavior.In this case, all EVs' BMS follow the setpoint, but the actual-drawn currents are always 10% lower.
Case 5. Disparity in EV Battery Capacity Information: Another EV information mismatch which could hinder SC-Alg's performance is the disparity in EV battery capacity.Protocol IEC 61851-1 does not communicate the EV SoC to the EVSE.Regardless, it is assumed that users can provide their EV arrival SoC to the Sub-aggr through a mobile phone app for the SC-Alg to calculate EV SoC with a nonguaranteed accuracy, especially when the EV battery is degraded.This potentially deviated SoC estimation will obstruct SC-Alg's behavior.Case 5 is thence proposed to test the 30% battery capacity fading scenario.For a fair comparison, the actual EV charged energy needs to be kept the same across all cases.In order to do that, the battery capacity stated in Table III is set as the "actual capacity of aged battery," and EV battery capacity that is read by the SC-Alg is 50 0.7 = 71 kWh for EV1, 2, 4, and 100 0.7 = 143 kWh for EV3, respectively.

3) INCORPORATION OF GRID RESTRICTION
When EV charging demands from multiple users appear at the same time, the grid faces the risk of overloading.In the last two scenarios, extra constraints from the grid side, namely grid restriction incorporation (GRI), are in place to prevent potential grid congestion.Case 6. Centralized Grid Capacity Allocation (GCA): The design idea of GCA is that the Ctr-aggr allocates the grid capacity among multiple Sub-aggrs based on the nodal sum of the remaining EV charging energy demand.Assume the tested grid has a total of 50 A grid import current capacity for EV charging, and the Ctr-aggr assigns this capacity among Nodes 5 and 15 based on the energy still needed to fulfil each node's EV charging target.However, if one node has too small a remaining energy target value compared to others, the allocated capacity for this node could be lower than the minimal EV charging current setpoint 6 A. To prevent this, a minimal grid import current limit is reserved to ensure at least one EV can still charge with the minimum current.Besides, the grid should always be able to supply the local load demand.The grid capacity determination equation is listed in (11).
The charging current of each EV is tuned between 6 A and I EV n, j proportionally to the local node voltage [56], when the voltage falls between 0.92 and 0.95 p.u..The illustration of how the EV charging setpoint is determined is given in Fig. 8.

V. RESULTS AND ANALYSIS A. BASE CASE
The performance of Case 0 and Case 1 regarding grid behavior impacted by UNC and SC is reflected in Fig. 9, and the EV charging behavior comparison is presented in Fig. 10.

1) OVERALL PERFORMANCE
First of all, it can be observed in Fig. 9(a) that SC-Alg significantly flattened the grid import power at Node 5 and it shifts the EV charging demand J 1 p Act 5, j from morning to the afternoon when the PV generation is high and the energy price is cheaper, as shown in Fig. 7. SC-Alg also improves the voltage drop provoked by simultaneous EV charging, especially in Node 5.
However, Fig. 10 depicts that the calculated EV charging current setpoint i e+,Set n, j oscillates.This can potentially stress the hardware in the charger, especially when the setpoint shifts between zero and nonzero too regularly which requests a too frequent open/close of the relay in the charger, and in turn decreases the charger's lifetime in the long run.Thus, a function to reduce the zero/nonzero charging current alteration frequency is helpful.

2) EV CHARGING DEMAND FULFILMENT
Another thing that can be perceived in Fig. 10 is that none of the EVs can be charged to 100% upon departure, and two factors cause this.The first factor is related to the nature of the EVSE-EV communication practice.As explained in Section IV-B2, the actual EV charging current with the same given setpoint deviates from EV to EV, differences in charging efficiency, embedded charging strategy, CV switch point, and the nature of current dropping in CV region.This setpointreal charging current value discrepancy deviates the actual charging progress away from the optimal plan.Even though the periodic SoC update between EV and the Sub-aggr is supported by the SC-Alg, it is still impractical for the SC-Alg to correct the energy deficiency in time due to the lack of actual charging power and SoC relation.The second factor is that the optimal charging profile calculation is based on the voltage value at the optimization trigger moment.However, the node voltage inevitably drops when the charging process starts with sudden EV power drawn.This voltage drop in turn, leads to a lower actual EV charging power than what is calculated by the SC-Alg.Both factors produce the same outcome: The actual charging power is lower than what is calculated by the SC-Alg, and as a result, the EVs are not fully charged.
A potential solution for the first factor is to add a feedback loop to detect and correct the setpoint-real charging current value discrepancy.Another simpler and more effective solution is to accommodate this potential error in the SC-Alg, which is to set a slightly higher charging energy goal or a sooner charging completion time limit.

3) GRID IMPORT POWER RIPPLES
In Fig. 9(a), especially between 13:00 and 16:00, the grid import power fluctuates intensively around the grid input power limit.
It can be observed in Fig. 11 that the grid import limit is breached for approximately 5 s due to the actual hardware (EV1) delay in response and ramp down its power following the given setpoint.This behavior will be missed in a pure software simulation and highlights the importance of HIL experimental demonstration.The high-resolution RT-PHIL simulation manifests another factor leading to the grid import power oscillations, i.e., discrete optimization combined with continuously evolving environmental parameters such as PV generation, as shown in Fig. 12.In real applications, communication delay has a wide range from less than 5 to 60 s depending on the characteristics of the transceiver, the network, and the protocols [17], [57], [58].Preventing the grid power ripples caused by various communication delays is effortful due to its unpredictability.It is thus worth exploring the grid impact induced by discordant communication latency and how to moderate it in the future.

B. IMPACT OF STOCHASTICITY
This section analyzes the results of the SC-Alg operating with inaccurate PV/load demand prediction (Cases 2 and 3) and mismatched EV information (Cases 4 and 5).Fig. 13 presents the 5-min moving average grid import current of Node 5 under the influence of inaccurate forecasts.The dissonance of the actual and predicted PV/load profile (in Fig. 7), is reflected in the grid import current results, even though the difference is moderate.On the other hand, if the predicted-actual profile error of both PV and load happens at the same time, they may cancel each other out or in reverse, add up and worsen the situation.It is thus appealing to view the multivariable inaccuracy as a whole and investigate the impact of joint stochasticity in the future.This investigation can be demonstrated with the experimental testbed implementing actual PV and load conditions with minor adaptions.
The EV charging current and their corresponding SoC values of Cases 4 and 5 are illustrated in Fig. 14(a) and (b).The comparison of 5 min moving average grid loading of Cases 1, 4, and 5 are shown in Fig. 14(c).It can be noticed from Fig. 14(a) and (c) that the 10% lower actual charging current i e+,Act than the setpoint i e+,Set of Case 4 leads to a reduced grid loading at the cost of a lower departure SoC than Case 1.In Case 5, the battery degradation provoked imprecise SoC estimation and leads to an unnecessarily rushed charging when the electricity price is not the lowest relative to Case 1, as presented in Fig. 14(b) and (c).In other words, battery-aged EVs require less energy to be fully charged, and the SC-Alg can use this information to yield a better solution.Yet, this inaccurate usable battery size information leads to a pleasant by-product that the battery is fully charged, even earlier than expected.
Cases 4 and 5 advocate that the self-correction function mentioned in Section V-A is essential for the SC-Alg's passive stochasticity handling capability.For example, a feedback loop regularly reads the measured i e+,Act could help the SC-Alg to count the i e+,Set /i e+,Act offset value in the setpoint computation.Although it is difficult to obtain the actual battery size information for an aged EV, regularly updated SoC information together with measured charging power could help rectify the SC-Alg's internal SoC tracking system.Unfortunately in practice, neither the IEC 61851-1 protocol nor the High-Level Communication Control protocol ISO 15118 supports the dynamic SoC information exchange during ac charging [17], [58].However, there is a possibility to work around it if both EV manufacturer and CPO support the direct bilateral communication between the EV and the CPO.In summary, a closed-loop self-correction function is crucial and beneficial to add to the future version of the SC-Alg.

C. EFFICACY OF INCORPORATING GRID LIMITATION
Finally, the results of two GRI scenarios are analyzed and compared.The sum of EV setpoint, the 5 min moving average grid import power, and the node voltage of Nodes 5 and 15 are illustrated in Fig. 15.
Fig. 15(b) and (c) show that GCA decreases the grid peak power and improves the voltage drop better than the VDM.In contrast to Case 1's "charge as late as possible" outcome due to the price and PV generation trend, the EV charging processes are already initiated in the morning in Case 6 as can be seen in Fig. 15(a).That is because limited grid capacity cannot fulfil all EV charging requests at the lowest price even when the PV generation reaches its peak due to the employment of extra grid constraints.This spread-out charging phenomenon is especially distinct for Node 15.
As for the VDM's grid congestion mitigation performance, the voltage drop improvement is not as good as expected.One possible explanation is the voltage droop response range is relatively low.To achieve a better voltage increase effect, the voltage adjustment range can be expanded to, e.g., 0.95-1.05p.u.. However it also means the users would experience a higher unfinished charging demand [56].
The centralized GCA could create an unfair situation where nodes with less total requested energy get less power and in turn, have less flexibility to shift the charging windows of its connected EVs.For example, Node 15 has a much lower grid capacity than Node 5, causing EV4 to only charge with minimal power.This limited charging power subsequently forces EV4 to charge almost the whole of its parking duration, which covers the high price moment, and the user has to bear this cost.This unfairness can be alleviated by adjusting the centralized capacity distribution principle.For example, equally share the power among all active EVs instead [59].
The averaged departure SoC of Case 6 is 97.63%, less than the 96.68% for Case 7.With GCA, the Sub-aggr is informed about the future grid limitation through Ctr-aggr upon EV connection.With this information, the Sub-aggr tends to expedite the charging process to ensure a full departure SoC.However, the grid constraint information is not in place with VDM until the high power demand-like EV charginginduced node voltage dip appears.This gives the SC-Alg a tight schedule to plan the charging to fulfil the energy demand in time.
A feature of VDM worth mentioning is that it can provoke low-frequency voltage oscillation if the parameters of the VDM are not carefully set.Fig. 16 exhibits the circle of node voltage oscillation.Three potential solutions can ease this phenomenon; the first one is to use historical moving average voltage value as the VDM reference voltage; the second one is to add a time threshold that activates the VDM only if the voltage dips longer than a certain amount of time; and the third method is to adapt hysteresis control in the VDM.

D. COMPARISON
The key performance indexes of two EV-connected nodes with all eight simulated cases are listed in Table IV.It includes departure SoC of each EV, the per unit charging cost of all EVs C EVch sum , the minimal node voltage value V min node , the peak overloading percentage Pl peak node , and the overloaded import energy E ol node of Nodes 5 and 15.E ol node is the energy obtained by the node from the part of the imported current which exceeds the limit.The illustrative explanation of E ol node can be found in Fig. 13(i) in [60].On top of that, the relative value of each scenario compared to the UNC scenario (Case 0) is listed in the right part of this table.Test cases with the best peak values are highlighted in green, and the worst ones are indicated in red in the table.
This comparison shows that the proposed SC-Alg can significantly reduce the charging cost and alleviate grid congestion compared to UNC.Even though inaccurate input data lead to less optimal outcomes, the SC-Alg still outperforms the UNC in Cases 2-5.Case 3 could reduce the least grid peak values, and Case 2 shares a very close outcome.This is because PV and load profile are purely input parameters and are the ones most likely to cause power ripples among all parameters in this study, especially when there are high uncertainties.Regarding the charging cost reduction, Case 4 has the lowest charging cost, although the difference among Cases 1-4, and 7 are negligible.The EV capacity fading issue in Case 5 leads to a noticeable charging cost rise, and this is because the SC-Alg missed the optimal charging window with outdated EV capacity data.Note that the charging cost variation impacted by the charging time shift away from the ideal time window strongly relates to the electricity price trend.A rushed or delayed charging which falls into an equally good or even cheaper price window would not necessarily be inferior to the optimal results.Therefore, a sensitivity analysis on applied input data, like electricity price is worth exploring in future work.
Results of Cases 6 and 7 suggest that incorporating grid constraints on top of the SC-Alg further improves the grid congestion mitigation performance.Results of Case 6 suggest GCA-incorporated SC-Alg has the best grid congestion prevention as this case gives the highest V min node and the lowest Pl peak node , E ol node among all cases.

VI. CONCLUSION
This article introduces a hierarchical MIP EV smart charging algorithm designed for LV distribution grid applications.
The proposed SC-Alg incorporates the implementational constraints and is equipped with a flexible receding horizon scheme to manage the stochasticity passively.Afterwards, the SC-Alg is verified and thoroughly assessed in an RTDT-based PHIL testbed that uses models of real LV distribution grids.Lastly, recommendations to further upgrade the SC-Alg's are given.
The SC-Alg presents promising and steady outcomes with or without external stress factors.The results show that the SC-Alg reduces the per-unit charging cost by over 22% in five out of seven scenarios.Even with a 30% EV capacity input error, the charging cost is still 12% less than the UNC scenario.The SC-Alg also proves its substantial capability in alleviating grid congestion with an average of 39.35% peak power reduction, a 1.41% average minimal voltage increase, and a 95.32% reduction in overloaded energy for Cases 2-5.Additionally, the GRI implemented in Cases 6-7 enhances the peak power reduction by 33.5% and curtails the overloaded energy by 65.9% further than Cases 2-5.
This research has identified several intriguing factors that impact the SC-Alg's performance.These findings provide valuable insights for future studies.It is highly recommended to conduct sensitivity analyses on how input data influences the SC-Alg's behavior.The suggested input data are the joint uncertainty of multiple input parameters and the timing/geographical/seasonal variability of input profiles, especially the price volatility.Due to the multiprotocol nature of the EV charging ecosystem, communication latency is very common in diverse applications.Investigating how much the communication latency interferes with the SC-Alg's performance is meaningful.
Several recommendations on how the proposed SC-Alg can be upgraded in the future are also defined in this study.Implementing the SC-Alg should not impose undue strain on the hardware, ensuring the frequency of switching between zero/nonzero setpoint values is within a reasonable range.A self-correction function is needed to overcome EV information mismatch issues and to track the actual charging progress with higher accuracy.We recommend using the actual EV charging current and the regularly updated actual EV SoC to decipher the i e+,Seti e+,Act -S Act correlation and revise the internal SoC tracking system dynamically.Besides, a slightly higher charging energy or an earlier charging completion target can always be set to suffice the EV users' requests.
Concerning the GRI methods, the SC-Alg's sensitivity to the grid constraint can be lowered to reduce the grid power oscillations.One example is to selectively disclose grid capacity information and trigger reoptimization only when constraints experience substantial and sustained magnitude variations over a specific duration.Additionally, using a moving-average historical record as the GRI reference and the hysteresis control can also be added.The further development of Ctr-aggr level advanced GRI methods is worth exploring as a separate topic in the future.
Finally, this study can be extended to encompass different grid types, using real EVs, incorporating different chargers and adapting the latest communication protocols such as IEC/ISO 15118 and OCPP.

FIGURE 1 .
FIGURE 1. Schematic of the hierarchical algorithm structure.

FIGURE 2 .
FIGURE 2. Schematic of the algorithm execution and the flexible receding horizon.

FIGURE 3 .
FIGURE 3. Overview of the HIL testbed setup.

FIGURE 4 .
FIGURE 4. Schematic of the SC-Alg/RT model interface.

FIGURE 5 .
FIGURE 5. Photo of the HIL setup in the lab.

FIGURE 6 .
FIGURE 6.Schematic of the simulated Dutch rural grid.

FIGURE 11 .
FIGURE 11.Grid import current spike caused by delayed EV response.

FIGURE 12 .
FIGURE 12. Node 5 Grid import current spike in between optimization intervals.

FIGURE 13 .
FIGURE 13.Impact of inaccurate PV/load demand prediction: Grid import current comparison (5 min moving average).

FIGURE 14 .
FIGURE 14. EV charging performance and grid loading results with mismatched EV information (a) charging performance of EV1, Case 4, (b) charging performance of EV1, Case 5, (c) EV information mismatch impact on the grid import current.

FIGURE 15 .
FIGURE 15.EV charging performance and grid impact comparison between two GRI methods.

TABLE III . Parameters for All Simulation Scenarios parameters
for all simulation scenarios are summarized in TableIII.