Electric Vehicle Aggregate Power Flow Prediction and Smart Charging System for Distributed Renewable Energy Self-Consumption Optimization

: In the context of electric vehicle (EV) development and positive energy districts with the growing penetration of non-programmable sources, this paper provides a method to predict and manage the aggregate power ﬂows of charging stations to optimize the self-consumption and load proﬁles. The prediction method analyzes each charging event belonging to the EV population, and it considers the main factors that inﬂuence a charging process, namely the EV’s characteristics, charging ratings, and driver behavior. EV’s characteristics and charging ratings are obtained from the EV model’s and charging stations’ speciﬁcations, respectively. The statistical analysis of driver behavior is performed to calculate the daily consumptions and the charging energy request. Then, a model to estimate the parking time of each vehicle is extrapolated from the real collected data of the arrival and departure times in parking lots. A case study was carried out to evaluate the proposed method. This consisted of an industrial area with renewable sources and electrical loads. The obtained results show how EV charging can negatively impact system power ﬂows, causing load peaks and high energy demand. Therefore, a charging management system (CMS) able to operate in the smart charging mode was introduced. Finally, it was demonstrated that the proposed method provides better EV integration and improved performance. pronounced. of dependence for


Introduction
Energy systems are experiencing an evolution towards new planning and management paradigms, among which the integration into energy networks (electrical grid, heat, gas, and transportation networks) will play a key role in guaranteeing an energy future and sustainable urbanization from an economic, environmental, and social point of view. This transformation process concerns an increase in the overall energy conversion efficiency and a simultaneous reduction in pollutants (CO 2 , SO 2 , NOx, particulates, etc.). An essential role in the global energy transition is attributed to the so-called positive energy districts (PEDs). From the reference framework [1], the definition for PED is as follows: "PEDs are energy-efficient and energy-flexible urban areas or groups of connected buildings which produce net-zero greenhouse gas emissions and actively manage an annual local or regional surplus production of renewable energy". According to the strategic energy technology (SET)-plan [2], European strategies aim to support the planning, deployment, and replication of 100 PEDs by 2025 for sustainable urbanization.
In this context, electric vehicles (EVs) play an important role in PED development and growth. With the transition from internal combustion engine (ICE) to electric drive, a large amount of energy

EVs Power Flows Forecasting Methods
To better understand the PED's structure, Figure 1 shows its schematic model. Referring only to the electrical aspect, a PED or, in general, an energy district (ED) might be composed of a cluster made out of [35,36]: • Electrical loads, for example, householder consumers, buildings, offices, and industries that absorb the power P L from either the grid or the power sources inside the PED; • Internal power sources, which generate the power P G from a non-programmable source such as wind and sun, or controllable plants such as cogeneration, biogas, and hydropower plants; • Energy storage systems (ESS), such as battery ESS (BESS) which can consist of a centralized system or many decentralized power storage units. Storage units exchange power P S with loads and the grid; • One or more points of grid connection, through which it is possible to absorb/inject the power P PCC from/to the grid. Equation (1) of the ED's power balance shows the relationship between the total power exchanged with the grid, and the total EVs' power, . By managing , the CMS could control the power flows exchanged between the ED and the grid. (1) The storage power can be both positive (discharging) and negative (charging) based on the battery charging or discharging. In the same way, the DC chargers could be capable of supplying power from the EVs' battery to the grid and loads. This mode of operation is generally called V2G and vehicle-to-X (V2X) [29], and it considers the bi-directional power flows of the charger. However, the AC charger, which can only absorb power from the grid and internal power sources, might be capable of modulating absorption to help the grid and the district for power balancing and other services. This mode of operation, which considers the unidirectional power flow of the charger, concerns both the V1G [31,32] and the SC mode [26]. The CMS could manage the EVs' power flows for achieving optimization goals such as:


Optimizing self-consumption to minimize the charging cost and maximize the charging from internal RES (SC);  EV owners and TSO (V1G and V2G) could maximize profits providing ancillary services to the grid.
The CMS's logics for smart charging mode is better described in Section 3. CMS control for being implemented needs both load and production power measurements. Furthermore, to implement grid power-sharing, the data of the power that the ED exchange with the grid are required as well. The load and the generation of daily power flows are extracted from annual data measurements. A similar procedure is done for the point of common coupling (PCC) power profile. On the other hand, EVs' daily power flows are more challenging to be extrapolated because of the difficulties in finding data and the statistically weak number of electric vehicles. However, EV penetration is quickly growing [4], and the current data are expected to strongly increase in the next years. For these reasons, current measurement data are not sufficient to extrapolate the EV charging power profile. As shown in Equation (2), instant by instant, the EV charging power is given by the aggregation of N charging power of each within the ED ( ): If the EVs charging is not managed, electric vehicles behave as non-controlled loads for the district. For transforming EVs into active elements for the district's energy balance, it is necessary to manage the EVs' charging power. The purpose of this paper is to introduce a charging management system that is capable of controlling the power flows of the distributed charging stations in a centralized way. Figure 1 shows the PED's power flow's exchanges among the grid, the loads, the internal generation, and the stationary energy storage. The figure also shows the possibility of using both AC and DC chargers for treating EVs as controlled loads and distributed battery storage.
Equation (1) of the ED's power balance shows the relationship between the total power exchanged with the grid, P PCC and the total EVs' power, P EVs . By managing P EVs , the CMS could control the power flows exchanged between the ED and the grid. P PCC = P L − P G ± P S ± P EVs (1) The storage power can be both positive (discharging) and negative (charging) based on the battery charging or discharging. In the same way, the DC chargers could be capable of supplying power from the EVs' battery to the grid and loads. This mode of operation is generally called V2G and vehicle-to-X (V2X) [29], and it considers the bi-directional power flows of the charger. However, the AC charger, which can only absorb power from the grid and internal power sources, might be capable of modulating absorption to help the grid and the district for power balancing and other services. This mode of operation, which considers the unidirectional power flow of the charger, concerns both the V1G [31,32] and the SC mode [26]. The CMS could manage the EVs' power flows for achieving optimization goals such as: • Optimizing self-consumption to minimize the charging cost and maximize the charging from internal RES (SC); • EV owners and TSO (V1G and V2G) could maximize profits providing ancillary services to the grid.

of 25
The CMS's logics for smart charging mode is better described in Section 3. CMS control for being implemented needs both load and production power measurements. Furthermore, to implement grid power-sharing, the data of the power that the ED exchange with the grid are required as well. The load and the generation of daily power flows are extracted from annual data measurements. A similar procedure is done for the point of common coupling (PCC) power profile. On the other hand, EVs' daily power flows are more challenging to be extrapolated because of the difficulties in finding data and the statistically weak number of electric vehicles. However, EV penetration is quickly growing [4], and the current data are expected to strongly increase in the next years. For these reasons, current measurement data are not sufficient to extrapolate the EV charging power profile. As shown in Equation (2), instant by instant, the EV charging power is given by the aggregation of N charging power of each EV i within the ED (P EVi ): (2) where N is the total number of EVs within the ED, and EVi is a generic electric vehicle belonging to the district. To evaluate the P EVi (t) for each vehicle, it is necessary to analyze all the factors that affect the EV's charging power. The daily charging power profile of an electric vehicle may depend on the following variables [37]: 1.
The maximum available power which is provided by the charging station (CS) P CS [kW]; 2.
The maximum power that the vehicle batteries can absorb P max [kW]. This power depends on the constant current-constant voltage (CC-CV) stage and can change during the charging process; 3.
The maximum energy that the vehicle's battery can store. It is the maximum available capacity of the battery C max [kWh]; 4.
The initial state of charge (SOC 0 ), i.e., the SOC value that corresponds to the start of the charging moment; 5.
The time of arrival (t arr ) and departure (t dep ) of the vehicle at/from the parking lot. Utilizing t arri and t depi of the i-th vehicle, one could obtain daily parking time (T pi ) as in Equation (3): All these variables could be different for each vehicle, resulting in a multitude of various charging events. Aiming to fetch variables from an aggregate population of EVs, this paper proposes different analyses on the basis of the Italian EV fleet, drivers' behavior, charging infrastructure, and on the parking and charging times.

Charging Infrastructure Analysis
This Section investigates the maximum available power of EV charging stations within the energy district. From the European alternative fuels observatory (EAFO) data [3], the number of public CSs in Italy is quickly increasing. In 2019, the newly installed stations were about +170% compared to the previous year. As Figure 2 shows, the number of "normal" CSs (P CS ≤ 22 kW) is much higher than the "fast" CSs (P CS > 22 kW). Furthermore, it seems that the trend of the infrastructure service providers is, in this phase, to increase the number of AC stations with "normal" power. In fact, the total number of "normal" CSs is increased by almost 200% compared to the 2018 data. Meanwhile, "fast" CSs only increased by 50% from 2018 to 2019. Referring to the CS's population of 2019, 90% of the public charging points are AC stations, and 88% provides a maximum power that is equal or less than 22 kW. However, most of the new public installations have a 3-phase connection, with the Type-2 connector and a 22 kW rating. On the other hand, the DC "fast" CSs are 10% of the total CS population. Many of these have the combined charging system (CCS) "combo 2" and "ChaDeMo" connectors and providers is, in this phase, to increase the number of AC stations with "normal" power. In fact, the total number of "normal" CSs is increased by almost 200% compared to the 2018 data. Meanwhile, "fast" CSs only increased by 50% from 2018 to 2019. Referring to the CS's population of 2019, 90% of the public charging points are AC stations, and 88% provides a maximum power that is equal or less than 22 kW. However, most of the new public installations have a 3-phase connection, with the Type-2 connector and a 22 kW rating. On the other hand, the DC "fast" CSs are 10% of the total CS population. Many of these have the combined charging system (CCS) "combo 2" and "ChaDeMo" connectors and provide a maximum power of almost 100 kW. Meanwhile, Tesla SuperChargers are also widespread, which provide a maximum power of up to 150 kW.

Electric Car Fleet Analysis
In order to evaluate the charging power, the batteries' capacity and the daily consumption for each vehicle belonging to a wide EV population, the Italian electric fleet has been considered and analyzed. Table 1 shows the EV data, referring to the vehicles registered in 2019 [38]. The table shows the battery capacity, the estimated consumption (referred to the world harmonized light-duty vehicles test procedure-WLTP) declared by manufacturers [39], and the max AC and DC charging power for each vehicle model. Some of these models have different options for battery capacity and engine size (such as Zoe ZE40 and Zoe ZE50, which have batteries of 44 kWh and 55 kWh). To simplify the analysis in this paper, the characteristics of the most popular models for each brand are only considered.  Figure 3 shows an elaboration of the table's data. From the data in Table 1, the weighted average capacity of the EV batteries is 40.31 kWh. Figure 3a shows that the majority of EVs (63.2%) have a battery capacity between 40 kWh and 50 kWh. Only 7.1% of EVs have a capacity greater than 90 kWh. However, a good part of EVs have a capacity of about 20 kWh, which refers to the high number of Smart cars (29.6%) registered in Italy in 2019. Figure 3b shows the EVs specific consumptions in the WLTP driving cycle compared to the percentage of registered models. Figure 3 shows an elaboration of the table's data. From the data in Table 1, the weighted average capacity of the EV batteries is 40.31 kWh. Figure 3a shows that the majority of EVs (63.2%) have a battery capacity between 40 kWh and 50 kWh. Only 7.1% of EVs have a capacity greater than 90 kWh. However, a good part of EVs have a capacity of about 20 kWh, which refers to the high number of Smart cars (29.6%) registered in Italy in 2019. Figure 3b shows the EVs specific consumptions in the WLTP driving cycle compared to the percentage of registered models.   Table 1 shows the maximum AC charging power of each EV model, which depends on the onboard converter. The weighted average of the maximum AC charging power is 11.13 kW. The charging power depends on both the onboard charger and the AC charging stations, and it is equal to the minimum power between the and (e.g., because of the onboard converter's size limit, the max AC charging power of the Nissan Leaf is 6.6 kW even if it charges through a 22 kW  Table 1 shows the maximum AC charging power P maxAC of each EV model, which depends on the onboard converter. The weighted average of the maximum AC charging power is 11.13 kW. The charging power depends on both the onboard charger and the AC charging stations, and it is equal to the minimum power between the P CSmax and P maxAC (e.g., because of the onboard converter's size limit, the max AC charging power of the Nissan Leaf is 6.6 kW even if it charges through a 22 kW station). By analyzing the data, only 21.73% of EVs (Renault ZOE) can exploit all the maximum available power from the 22 kW AC stations, 55.62% of EVs for the 11 kW AC stations and 57.72% for the 7 kW stations. However, almost all EVs (70.34%) can exploit all the available power from the 5 kW AC stations.
The daily charging power's profile of each EV i depends, as well as on the onboard converter and charging stations, on the CC-CV charging algorithms, then on the SOC's value during charging: The standard charging protocol consists of two phases. During the CC phase, the battery is charged by a constant current and a quasi-constant power. As a result, the SOC linearly increases, and the power assumes a constant profile in the plot "charging power [kW]" versus "SOC (%)", whose value depends on both P CSmax i and P maxi . When the battery voltage reaches the cut-off value, the voltage is kept constant and the current consequently decreases (CV phase). As a result, the power decreases following the current profile, and the SOC increases slowly. Considering the same battery, the SOC's value that coincides with the start of the CV phase depends on the charging rate, and therefore on the charging power. Different charging powers provide different profiles as a function of the SOC. Figure 4 shows the characteristics of a 40 kWh battery during charging through three levels of power: 50, 22 and 7 kW that correspond to a C-rate of about 1.25 C, 0.55 C, and 0.18 C, respectively. The data were extrapolated by battery characteristics and the charging behavior of the Nissan Leaf [39]. Figure 4a shows that the charging of 7 kW (<0.2 C) is less affected by the CV phase limitation. However, as the charging power increases, the CV phase is more pronounced. This paper analyzes this kind of dependence for each EV models' battery.  Figure 4 shows the characteristics of a 40 kWh battery during charging through three levels of power: 50, 22 and 7 kW that correspond to a C-rate of about 1.25 C, 0.55 C, and 0.18 C, respectively. The data were extrapolated by battery characteristics and the charging behavior of the Nissan Leaf [39]. Figure 4a shows that the charging of 7 kW (<0.2 C) is less affected by the CV phase limitation. However, as the charging power increases, the CV phase is more pronounced. This paper analyzes this kind of dependence for each EV models' battery.

Analysis of Drivers' Behavior and Consumptions
For evaluating the charging time for each EV, it is necessary to know the vehicle's SOC value at the beginning of the charging process ( ). For this reason, this Section analyzes the daily energy consumption of the aggregated EV population. The energy consumed during the k-th day ( ) by the i-th vehicle is called kWh . depends on the specific consumption kWh/ 100 km and on the daily travailed distance km : The specific consumption of each EV (in WLTP rating) is shown in Table 1. Figure 3b shows the for each EV model compared to the percentage of the registered model. The weighted average for the EV population under investigation is 16.67 kWh/100 km. To extract the data of the daily distance traveled, it is necessary to investigate the driver's behavior.

Analysis of Drivers' Behavior and Consumptions
For evaluating the charging time for each EV, it is necessary to know the vehicle's SOC value at the beginning of the charging process (SOC 0i ). For this reason, this Section analyzes the daily energy consumption of the aggregated EV population. The energy consumed during the k-th day (d k ) by the i-th vehicle EV i is called Ec i (d k ) [kWh]. Ec i (d k ) depends on the specific consumption Csp i [kWh/100 km] and on the daily travailed distance D i (d k ) [km]: The specific consumption of each EV (in WLTP rating) is shown in Table 1. Figure 3b shows the Csp for each EV model compared to the percentage of the registered model. The weighted average Csp for the EV population under investigation is 16.67 kWh/100 km. To extract the data of the daily distance traveled, it is necessary to investigate the driver's behavior.
From the statistics in the report [40], the average distance traveled by a vehicle in a year is 12,240 km. Therefore, the average distance traveled per day is about 33 km. The statistics in the document [41] report an overview of the mobility and drivers' behavior in terms of the number and length of daily travels. From the extrapolation of the report's data, Table 2 shows, with good approximation, the percentage of daily distance traveled, categorized by length groups: close distance, short distance, medium distance, and long distance. Through analyzing Table 1, and according to [42], the probabilistic distribution that better estimates the daily distance travel of vehicles is the Weibull function. Figure 5a shows the Weibull distribution with λ = 37.5 and k = 1.7. This distribution provides a reasonable estimation of the drivers' behavior, especially for close and short distances, which represent 70% of total travel. It can be seen in the cumulative curve (at the bottom of Figure 5a) that 10% of vehicles travel below 8 km per day, 60% of them between 8 and 40 km, and the remaining 30% travels more than 40 km per day. Figure 5b shows Energies 2020, 13, 5003 9 of 25 the daily distance D i (d k ) traveled by each driver belonging to a population of 100 vehicles, during the k-th day. The data were obtained by applying the Weibull function. It can be seen in Figure 5b that the average traveled distance is about 33 km per day.
Through analyzing Table 1, and according to [42], the probabilistic distribution that better estimates the daily distance travel of vehicles is the Weibull function. Figure 5a shows the Weibull distribution with λ = 37.5 and k = 1.7. This distribution provides a reasonable estimation of the drivers' behavior, especially for close and short distances, which represent 70% of total travel. It can be seen in the cumulative curve (at the bottom of Figure 5a) that 10% of vehicles travel below 8 km per day, 60% of them between 8 and 40 km, and the remaining 30% travels more than 40 km per day. Figure  5b shows the daily distance traveled by each driver belonging to a population of 100 vehicles, during the k-th day. The data were obtained by applying the Weibull function. It can be seen in Figure  5b that the average traveled distance is about 33 km per day. Knowing the specific consumption and the daily distance traveled by each vehicle, using Equation (5) it is possible to calculate the energy consumed by the i-th vehicle in the k-th day. To calculate the ) (%), which is the initial SOC of the i-th EV at the k-th day, this paper proposes the following hypotheses: is the day the has the last total charging, in which = , then the is given by Equation (6): where ∑ is the energy consumption referred to the days before the day . For example, the considers the consumption of the previous three days, , , and ), starting from the initial SOC's value of the last full charging day ( ). For each vehicle, the energy consumed in depends on the distance . This distance could be or not the same each day. For Knowing the specific consumption and the daily distance traveled by each vehicle, using Equation (5) it is possible to calculate the energy consumed by the i-th vehicle in the k-th day. To calculate the SOC 0i (d k ) (%), which is the initial SOC of the i-th EV at the k-th day, this paper proposes the following hypotheses: d 0 is the day the EV i has the last total charging, in which SOC 0i (d 0 )= SOC max , then the SOC 0i (d k ) is given by Equation (6): Ec i d j is the energy consumption referred to the days before the day d k . For example, the SOC 0i (d 3 ) considers the consumption of the previous three days, Ec i (d 0 ), Ec i (d 1 ), and Ec i (d 2 ), starting from the initial SOC's value of the last full charging day (d 0 ). For each vehicle, the energy consumed in d j depends on the distance D d j . This distance could be or not the same each day. For instance, the distances traveled by EV i during three days could be D i (d 0 ) = 20 km, D i (d 1 ) = 24 km and D i (d 2 ) = 8 km. However, every day, the average value (33 km per day) and distribution (Weibull) of the traveled distances must be the same for the total vehicles' population, according to Table 2 and Figure 5. These concepts will be better explained in Section 4 using data from a real vehicle population's scenario.

Parking Time Analysis
To evaluate the charging time, it is necessary to know the time that each vehicle spends plugged to the charging station absorbing power. For each vehicle EV i , this paper considers the daily charging time (referred to the day d k ) as the period between the initial time of charging t ch0i (d k ) that is the instant in which EV i is plugged in, and the final time of charging t ch f i (d k ) : where T chi (d k ) is the charging time of EV i referring to d k . The t ch f i (d k ) is the instant where EV i ceases to absorb power from the CS and it may depend on two conditions:

1.
The vehicle is plugged, but the SOC reaches the maximum value, the charging stops, The vehicle is unplugged because the users left the parking lot even if the charging is incomplete, The hypothesis introduced is that the instant of arrival in the parking lot coincides with the beginning of the charging, as shown in Equation (8). On the other hand, the final charging instant could coincide or not with the departure time of the vehicle from the parking lot, as in Equation (9): The arrival and departure times of each vehicle and all of them together with the parking time were obtained by monitoring the users' access to the parking lots. The data were collected considering private and public parking lots. Data refer to several typologies of parking scenarios: mall, station, airport, city center, municipal parking, office building, working place, and companies' parking lots. The distribution and numbers of data can be very different for each scenario, as well as the parking times. By analyzing each vehicle's access (in and out), it is possible to extrapolate the users' behavior and the parking time distribution for each different scenario. This paper focuses on the working place parking scenario (companies, office building, etc.), as extensively shown below.
The scenario under consideration concerns a population of 160 vehicles, and the input data are t arr and t dep . The arrival and departure times were subsequently sampled every 15 min. Figure 6a shows the input data; for each vehicle (y axis), the arrival and departure times (x axis) are registered. By processing these input data, it is possible to extrapolate Figure 6b, which shows the number of arrivals (top-frame) and departures (bottom-frame) within each 15 min interval of the day. It can be seen in the figure that the vehicle arrivals can be divided into two major sub-groups: first arrivals, which are the events within the time interval [00:00-12:00] and concern about 80% of users; and the second arrivals, that refer to the time interval [12:00-24:00] covering the remaining 20% of vehicles. In the same way, departure events can be divided into two sub-groups: first departures that cover 30% of users and are registered before 14:00; and second departures, which belong to the interval [14:00-24:00] and concern 70% of vehicles. For each group, the probabilistic distribution that better simulates the users' behavior is extrapolated. In this way, it will be possible to extend this kind of behavior as well for a population of a larger or smaller number of vehicles. Table 3 shows in detail the probabilistic distribution obtained for each sub-group of events. The total distribution of arrivals and departures is given by the sum of its two respective sub-groups. As shown in Figure 6b and Table 3, the distribution of the total arrival is provided by the sum of two normal functions (NFs). On the other hand, the overall departures distribution consists of two Weibull functions (WFs) with different parameters. By using these data, the number of vehicles that are present in the parking lot in each 15 min interval is calculated. Figure 6c shows the number of presences in the parking lot. It can be seen that the probabilistic function of presences (blue line), which is obtained by using the parameters in Table 3, matches well with the real data curve (red line). Figure 6d shows the parking times of each vehicle, which are calculated by Equation (3). The average parking time, referring to real data, is about 5 h (4 h and 57 min); on the other hand, the average parking time obtained by the probabilistic distribution is 5 h and 3 min. Besides, the figure shows the parking time error for each vehicle, which is obtained by the difference between the probabilistic and actual data. The average error is 7 min which corresponds to less than 3% of the average value of the real data, while the root mean square error (RMSE) is 7%. As can be seen in the figure, since the actual and probabilistic data are sampled in 15 min intervals, the error has been quantized every 15 min as well. The maximum error value is 45 min, which corresponds to a Energies 2020, 13, 5003 11 of 25 15% error and concerns only 8% of the population. Most of the population has an error that is less than 15 min (5% error referred to the average), and 30% of the population has 0% error. These parameters further confirm the good overlay between the real and the stochastic behavior.
Energies 2020, 13, x FOR PEER REVIEW 10 of 24 parameters. By using these data, the number of vehicles that are present in the parking lot in each 15 min interval is calculated.

EVs' Power Flow Calculation Algorithms
This Section explains the logic and methods that allow calculating the daily EV power flows for different scenarios and populations. Once the population's number of vehicles, their characteristics, and the parking lot scenario are all identified, this algorithm is capable of forecasting and calculating the power that each EV requires for charging in each time interval of the day. Furthermore, it can forecast the total EVs' charging power, which could be related to the aggregate group of vehicles that belongs to the single parking lot or the entire energy district. According to Section 2.4, the sample time of the algorithm is set to 15 min, then the generic day d k consists of 96 intervals of 15 min each. The algorithm's input data are obtained by the previous analyses done in Section 2.1, Section 2.2, Section 2.3, and Section 2.4.
As mentioned above, the scenario under investigation is the working place parking lot, where N is the number of total EVs that used the parking during the day. Through the Section 2.2 analysis, it is possible to define an N-sized array, named ID. The ID array contains information about the EVs' model and is made using the percentages of registered EVs that are reported in Table 1. For example, if N = 100, the ID vector would consist of 100 elements of which 22 correspond to Renault ZOE, 19 to Tesla Model 3, 13 to Nissan Leaf, and so on. In the same way, from Table 1 it is possible to define the N-size array of the batteries' capacities (C max [kWh]), of the max on-board charger powers (P max [kW]), and the specific consumptions (Csp [kWh/100km]). By the 0analysis in Section 2.3, the N-size array of the distances traveled in d k is defined and named D(d k ) (km). Finally, the array of the maximum powers that are available on the charging stations (P cs [kW]) is defined. The elements of each vectors' row refer to the vehicle which is present in the corresponding row of the ID array. For example, Equation (10) shows that the i-th vehicle (n • ID = i) is a Tesla Model 3 that traveled 70 km during d k (D i = 70). The i-row of all other vectors refers to the Tesla Mod. 3's parameters. The P CS array depends on the charging infrastructure, however, the i-row of P CS refers to the charging station plugged into the i-th vehicle (in this case, by Tesla M.3).
Model By Section 2.4 analysis, it is possible to define the matrix of the vehicle presences in the parking lot (PK), which contains information about the arrivals, departures, and parking times of each EV in the day d k . The matrix is shown in Equation (11) and is calculated using the arrival (blue) and departure (red) times for each vehicle. The time range within t arr and t dep represents the parking time (T p ).
Energies 2020, 13, x FOR PEER REVIEW 12 of 24 PK is calculated at each time interval Δ , and since Δ = 15 min, considering a population of N vehicles and a period of 24 h, PK results in an 96 matrix. Generally, if the time step resolution is higher (Δ < 15 min), the number of the matrix's columns is higher than 96. Following the order of the ID array, each row corresponds to a vehicle, while each column corresponds to a time interval of . As shown in Equation (11), the value of the matrix elements is 1 only if the vehicle is parked; otherwise, it is 0. For each interval Δ (which refers to time 1 ⋅ Δ to time ⋅ Δ ) and each , the following conditions apply: where j is the PK column, and i is the PK row. By Equation (12), for each PK row, the first non-zero element corresponds to the arrival times. On the other hand, the last non-zero element corresponds to the time interval preceding the departure time, and all the elements within this time-range are equal to one. If = 160, the sum of the row-elements for each column ( ∑ , ) provides the plot in Figure 6c, as well as the sum of the elements only relating to and , which provides the plots in Figure 6b.
For describing the forecasting algorithm, this Section focuses on calculating the daily power flow referring to a single , . The algorithm's output must be an 96 matrix which contains the charging power value [kW] of each vehicle for each time interval, this output matrix is called and , ∈ . Then, from Equation (2), the total parking charging power, for each time interval Δ is a row-vector (96-sized) named and is given by , The forecasting logics are shown in the flow chart in Figure 7.The model starts calculating at the beginning of , considering the first-time interval (j = 1, which time belongs to [00:00-00:15]). As long as , remains equal to zero, the output , is zero because the vehicle is not in the parking lot and cannot be plugged on the charging station. As soon as the vehicle arrives in the parking lot, , switches to one and keeps this value while the vehicle is parked. By Equation (8), the charging starts at the arrival times, and the initial charging power , is set to the minimum value between and . After that, the initial value of the power is multiplied by a scalefactor . The scale factor considers the variation of power during charging which depends on the CC-CV phases. Therefore, as shown by Equation (4) and Figure 4a, the power could decrease during the charging process depending on the SOC value. Using a lookup table, which depends on each vehicle's battery capacity, is calculated as a function of the SOC and the initial charging power value for each time interval Δ . In fact, represents the value of the charging power in per-units (p.u.), which is reported to the rated power in the CC phase. Therefore, the scale factor is about =1 during the CC phase and decreases during the CV phase to reach zero as soon as the charging ends, , = 0. From Figure 7, the algorithm's input (black input arrows) and output data (green output arrow) can be observed. On the other hand, the red signals consider the logics of start and stop charging. As previously explained in Equations (8) and (9), the charging can end ( , 0 if the vehicle leaves the parking (PK switches from 1 to 0) or if the battery reaches the maximum SOC value ( reaches zero). Therefore, the scale factor (blue signal) is used for both calculating the end charging instant, (11) PK is calculated at each time interval ∆t, and since ∆t = 15 min, considering a population of N vehicles and a period of 24 h, PK results in an N × 96 matrix. Generally, if the time step resolution is higher (∆t < 15 min), the number of the matrix's columns is higher than 96. Following the order of the ID array, each row corresponds to a vehicle, while each column corresponds to a time interval of d k . As shown in Equation (11), the value of the matrix elements is 1 only if the vehicle is parked; otherwise, it is 0. For each interval ∆t j (which refers to time [( j − 1) · ∆t] to time [ j · ∆t]) and each EV i , the following conditions apply: where j is the PK column, and i is the PK row. By Equation (12), for each PK row, the first non-zero element corresponds to the arrival times. On the other hand, the last non-zero element corresponds to the time interval preceding the departure time, and all the elements within this time-range are equal to one. If N = 160, the sum of the row-elements for each column ( i PK[ j, i] ) provides the plot in Figure 6c, as well as the sum of the elements only relating to t arr and t dep , which provides the plots in Figure 6b. For describing the forecasting algorithm, this Section focuses on calculating the daily power flow referring to a single EV, P EVi (t). The algorithm's output must be an N × 96 matrix which contains the charging power value [kW] of each vehicle for each time interval, this output matrix is called P EV and P EV [ j, i] ∈ P EV . Then, from Equation (2), the total parking charging power, for each time interval ∆t j is a row-vector (96-sized) named PEVs and is given by The forecasting logics are shown in the flow chart in Figure 7. The model starts calculating at the beginning of d k , considering the first-time interval (j = 1, which time belongs to [00:00-00:15]). As long as PK[ j, i] remains equal to zero, the output P EV [ j, i] is zero because the vehicle is not in the parking lot and cannot be plugged on the charging station. As soon as the vehicle arrives in the parking lot, PK[ j, i] switches to one and keeps this value while the vehicle is parked. By Equation (8), the charging starts at the arrival times, and the initial charging power P EV [t ch0 , i] is set to the minimum value between P CS [i] and P max [i]. After that, the initial value of the power is multiplied by a scale-factor k c . The scale factor considers the variation of power during charging which depends on the CC-CV phases. Therefore, as shown by Equation (4) and Figure 4a, the power could decrease during the charging process depending on the SOC value. Using a lookup table, which depends on each vehicle's battery capacity, k c is calculated as a function of the SOC and the initial charging power value for each time interval ∆t j . In fact, k c represents the value of the charging power in per-units (p.u.), which is reported to the rated power in the CC phase. Therefore, the scale factor is about k c =1 during the CC phase and decreases during the CV phase to reach zero as soon as the charging ends, k c t ch f , = 0.
Finally, according to the objective of calculating the daily charging power of the single-day , the forecasting process ends when j = 96 (time step [23:45-24:00]). Once the matrix P is determined, Equation (13) calculates the total daily power profile of the parking lot (PEVs).

The Charging Management System: Logic and Aims
The objective of the CMS is to manage the EV charging power flows to follow and to reach specific optimizations targets. The targets are set according to environmental policies (such as decarbonization in urban contexts and the development of PED [2,36]), but especially to minimize the charging cost. According to Figure 1, the CMS has the role of managing the (consequently, it can also modify the ) following the specific logics and operating criteria. The incoming data of this management system can come either from the generation sources and electrical loads that are inside the energy district or from the external grid as well. For example, the aggregated system of EVs can participate in the dispatching services market [16,20,32], by modulating the charging power according to the TSO's requests. Furthermore, the PEDs or micro-grids, which have non-controllable loads and a relevant penetration of non-programmable generation sources, may use the EV batteries to modulate the profile [14] following the dispatching orders. This would not be possible without the storage system behaving as a buffer between the generation and load (as in Equation (1)). Moreover, in return, the dispatching users (in this case, the EVs' owners or the charging infrastructure providers) receive financial compensation for their services. This practice, generally called V1G/V2G [29][30][31][32] can ultimately result in a decrease in the charging cost. Moreover, since the price of energy depends on the energy market and can vary during the day, the CMS can shift charging when absorbing energy from the grid is more convenient following the same optimization target [10,[43][44][45]. However, these logics, which receive external input such as dispatching orders and energy prices, are not treated in the current article.
This paper focuses on a CMS that aimed to optimize the charging cost by the maximization of the PED's self-consumption. Since the inputs of this control system only come from measurements inside the district, this control topology can be called stand-alone CMS (SA-CMS). By introducing an SA-CMS in PED it is possible to operate in Smart Charging mode, i.e., the aggregate charging power, which is given by Equation (2), is controlled to follow the daily power profile of the internal generation sources. This can result in an EV's load shifting during the hours of more internal generation or may involve a decrease in each EV's charging power to smooth the EV's load profile during peak hours [24][25][26][27]. Of course, this operating mode aims to minimize the power that the system absorbs from the grid, by prioritizing the internal and non-programmable RESs, which present a lower energy price. Thus, the improvement of self-consumption results in a reduction in charging costs.  Figure 7, the algorithm's input (black input arrows) and output data (green output arrow) can be observed. On the other hand, the red signals consider the logics of start and stop charging. As previously explained in Equations (8) and (9), the charging can end (P EV [ j, i] = 0) if the vehicle leaves the parking (PK switches from 1 to 0) or if the battery reaches the maximum SOC value (k c reaches zero). Therefore, the scale factor (blue signal) is used for both calculating the end charging instant, and to calculate the EV charging power in each time interval through Equation (14):

P EV [j,i]=P EV [t ch0 ,i]·k c [j,i]·PK[j,i]
Finally, according to the objective of calculating the daily charging power of the single-day d k , the forecasting process ends when j = 96 (time step [23:45-24:00]). Once the matrix P EV is determined, Equation (13) calculates the total daily power profile of the parking lot (PEVs).

The Charging Management System: Logic and Aims
The objective of the CMS is to manage the EV charging power flows to follow and to reach specific optimizations targets. The targets are set according to environmental policies (such as decarbonization in urban contexts and the development of PED [2,36]), but especially to minimize the charging cost. According to Figure 1, the CMS has the role of managing the P EVs (consequently, it can also modify the P PCC ) following the specific logics and operating criteria. The incoming data of this management system can come either from the generation sources and electrical loads that are inside the energy district or from the external grid as well. For example, the aggregated system of EVs can participate in the dispatching services market [16,20,32], by modulating the charging power according to the TSO's requests. Furthermore, the PEDs or micro-grids, which have non-controllable loads and a relevant penetration of non-programmable generation sources, may use the EV batteries to modulate the P PCC profile [14] following the dispatching orders. This would not be possible without the storage system behaving as a buffer between the generation and load (as in Equation (1)). Moreover, in return, the dispatching users (in this case, the EVs' owners or the charging infrastructure providers) receive financial compensation for their services. This practice, generally called V1G/V2G [29][30][31][32] can ultimately result in a decrease in the charging cost. Moreover, since the price of energy depends on the energy market and can vary during the day, the CMS can shift charging when absorbing energy from the grid is more convenient following the same optimization target [10,[43][44][45]. However, these logics, which receive external input such as dispatching orders and energy prices, are not treated in the current article.
This paper focuses on a CMS that aimed to optimize the charging cost by the maximization of the PED's self-consumption. Since the inputs of this control system only come from measurements inside the district, this control topology can be called stand-alone CMS (SA-CMS). By introducing an SA-CMS in PED it is possible to operate in Smart Charging mode, i.e., the aggregate charging power, which is given by Equation (2), is controlled to follow the daily power profile of the internal generation sources. This can result in an EV's load shifting during the hours of more internal generation or may involve a decrease in each EV's charging power to smooth the EV's load profile during peak hours [24][25][26][27]. Of course, this operating mode aims to minimize the power that the system absorbs from the grid, by prioritizing the internal and non-programmable RESs, which present a lower energy price. Thus, the improvement of self-consumption results in a reduction in charging costs.
The CMS consists of hardware (HW) and software (SW) systems. The HW system collects all the elements necessary to implement the power flows that are managed by the SW central system. In detail, HW consists of power electronics converters, measurement sensors, and other elements that are necessary for communicating and receiving signals from the central control system. In the case of DC-charging (off-board charger), it is the CS that directly manages the charging power following the power reference from the control system (within the vehicle's battery limits). On the other hand, in the case of AC-charging (on-board charger), it is the on-board charger that provides power to the batteries. The AC-CS operation consists in communicating to the vehicle the maximum current (and therefore the maximum power) that the charging station can provide in that instant. For the CMS with AC-CS, it is necessary to have a communication system between the charging station and the on-board charger. For example, it could be provided by the Type-2 connector that communicates with the vehicle through a PWM signal (control pilot "CP" in [46]). In particular, by managing the duty cycle of this PMW voltage signal, it is possible to control the maximum current (and the power as well) that the vehicle can absorb from the CS so that it can follow the reference signal. The SW system receives in input the data shown in Table 4 and returns as output the reference charging power (P * EVi ) for each CS i on which is plugged the EV i with a reference time resolution (such as 15 min). The effects and how the CMS operates on power flows will be better shown in Section 5.

Reference Scenario and Results of the EVs Power Flows' Calculation Method
In order to test the EVs' power demand prediction method and to evaluate the CMS's effect on these power flows, this Section takes into account the reference scenario shown in Figure 8. The reference scenario consists of a metalworking company with two main parking areas, each having a capacity of 100 stands. The company also has a PV plant of 500 kWp. Figure 8a shows the main building of the company and the nearby PV plant. The hypothesis is that the parking lot n • 2 provides a charging point for each vehicle. The charging infrastructure consists of 50 AC-CSs having two 22 kW charging ports each. The parking users are the company employees, and their behavior, in terms of arrival and departure times, belongs to the scenario that is analyzed in Section 2 (the working place parking lots). Figure 8b shows the daily profile of the electrical load and PV generation of the company. The data refer to the daily measurements across the year 2019. For evaluating CMS performances, the self-consumption parameter ( ) is introduced by Equation (15). The is 100% if the internal generation (in this case the PV plant) manages to supply all the energy required by the charging; on the other hand, is 0% if the charging energy is entirely provided by the grid (external power source): min , Since the PV power, as shown in Figure 8b, has variable profiles (depending on the daily and seasonal irradiation), to evaluate the , three different PV profiles are taken into account to simulate three operating conditions: the "worst condition" refers to a low-production winter day; the "meancondition" is the power profile which refers to the equivalent sun hours (ESH) energy of the plant, and it is obtained by the annual average of daily production (red signal in Figure 8b); the "best condition" refers to a high production spring day. Figure 10   The following figures show the results of the forecasting method and the algorithm that are reported in Section 2. Input data are adapted to the reference scenario. Figure 9a shows the SOC 0 values of each EV, which are calculated and analyzed in Section 2.3 concerning the consumptions of d k = [1;3;7]. Therefore, d k also allows evaluating the EVs' charging load based on the users' behavior. For example, d k = 3 means that the charging takes place once every three days. Consequently, the initial value of the SOC, together with the total power flows and the entire energy, changes depending on d k . Figure 9b shows the total power flows (P EVs ) of the reference EVs' population for more d k values. From the figure, the peak value of P EVS can drastically change and under the worst conditions, might even double the electrical load request of the plant for a few hours. For evaluating CMS performances, the self-consumption parameter ( ) is introduced by Equation (15). The is 100% if the internal generation (in this case the PV plant) manages to supply all the energy required by the charging; on the other hand, is 0% if the charging energy is entirely provided by the grid (external power source): For evaluating CMS performances, the self-consumption parameter (η SC ) is introduced by Equation (15). The η SC is 100% if the internal generation (in this case the PV plant) manages to supply all the energy required by the charging; on the other hand, η SC is 0% if the charging energy is entirely provided by the grid (external power source): Since the PV power, as shown in Figure 8b, has variable profiles (depending on the daily and seasonal irradiation), to evaluate the η SC , three different PV profiles are taken into account to simulate three operating conditions: the "worst condition" refers to a low-production winter day; the "mean-condition" is the power profile which refers to the equivalent sun hours (ESH) energy of the plant, and it is obtained by the annual average of daily production (red signal in Figure 8b); the "best condition" refers to a high production spring day. Figure 10  profile considering the EVs' charging. As mentioned above, the power required by the system depends on the PV generation and the EVs charging rate, therefore, it can drastically change based on the daily request, seasonal RES availability, and the users' charging behavior. The figure reports the percentage value of the peak load (Δ %]) referred to the maximum value without EVs charging (red line) for the different conditions.  In worse cases, the profile might assume relevant peak values and high ramp-rates, causing breaches in the operative limits, increasing losses, congestion, simultaneous loads issues, failure probability, and negative impact on the power quality [5]. Finally, to compare the charging performances, Table 5 was introduced. The parameter is the maximum value of the self-consumption that can be reached through the available PV energy, while is the daily energy required for charging and is the daily PV energy, both expressed in (kWh per day).  Below, for evaluating the EVs' effect on the absorbed power from the grid, utilizing Equation (1), the PCC power is calculated and shown in Figure 11. The red curve is the P PCC without EVs charging and is obtained considering the average load profile (dark blue signal in Figure 8b) and the three PV generation conditions (worst, mean, best). On the other hand, the blue curves show the PCC load profile considering the EVs' charging. As mentioned above, the power required by the system depends on the PV generation and the EVs charging rate, therefore, it can drastically change based on the daily request, seasonal RES availability, and the users' charging behavior. The figure reports the percentage value of the peak load (∆P PCC [%]) referred to the maximum value without EVs charging (red line) for the different conditions.
In worse cases, the P PCC profile might assume relevant peak values and high ramp-rates, causing breaches in the operative limits, increasing losses, congestion, simultaneous loads issues, failure probability, and negative impact on the power quality [5]. Finally, to compare the charging performances, Table 5 was introduced. The parameter η SCmax is the maximum value of the self-consumption that can be reached through the available PV energy, while E ch is the daily energy required for charging and E PV is the daily PV energy, both expressed in (kWh per day).  3;7], and the percentage value in the legend shows the in: worst condition (blue areas, left plot); mean condition (green areas, center plot); best condition (orange areas, right plot). Figure 11. The PCC power profiles calculated without EVs (red) and with EVs charging (blue) according to the different values of the initial SOC. The PV generation changes according to the worst condition (left), the mean condition (center), and the best condition (right), as well as the Δ values.
In worse cases, the profile might assume relevant peak values and high ramp-rates, causing breaches in the operative limits, increasing losses, congestion, simultaneous loads issues, failure probability, and negative impact on the power quality [5]. Finally, to compare the charging performances, Table 5 was introduced. The parameter is the maximum value of the self-consumption that can be reached through the available PV energy, while is the daily energy required for charging and is the daily PV energy, both expressed in (kWh per day).  Figure 11. The PCC power profiles calculated without EVs (red) and with EVs charging (blue) according to the different values of the initial SOC. The PV generation changes according to the worst condition (left), the mean condition (center), and the best condition (right), as well as the ∆P PCC values.
As shown in Table 5, in worse conditions with low E PV and high E ch (red cells), the self-consumption coincides with its maximum value and it is not possible to increase it by load shifting (although it may be possible to act on P PCC by peak shaving). On the other hand, on favorable days with higher PV energy and lower EV load request (green cells), the η SC reaches its maximum value without smart charging. However, under the average conditions (fuzzy color) of production and consumption, it may be necessary to manage the EVs' power flow to optimize η SC and ∆P PCC . To quantify the share of the highly favorable days, unfavorable days, and middle days, this analysis is extended to the data belonging to a period of one year. Thus, Figure 12 is introduced. The figure shows the values of η SC and ∆P PCC . Figure 12a depicts the self-consumption parameters (blue markers) and their respective maximum values (black markers) that can be reached in each day. The EVs' power is maintained the same and refers to d k = 3, while the PV production changes based on the daily irradiance availability. The same figure also shows the maximum increment that η SC could reach in case of self-consumption optimization, which is given by the difference between η SCmax and η SC . According to the color-scale in Table 5, the histogram shows the max performance improvements that could be obtained starting on unfavorable days (η SC < 30%), highly favorable days (η SC > 90%), and the intermediate values (η SC ∈ [30-90%]). The figure shows that in the great majority of the days it is possible to increase the self-consumption reaching η SC = 100%. The average improvement that could be obtained through flows optimization, is of about 20% in spring, summer, and autumn, while dips to 12% in winter. However, it is shown that extreme PV conditions, such "worst condition" and "best condition.", when it is not possible to employ self-consumption consistently, involve very few days of the year (red and dark green columns). mediate values ( ∈ [30-90%]). The figure shows that in the great majority of the days it is possible to increase the self-consumption reaching = 100%. The average improvement that could be obtained through flows optimization, is of about 20% in spring, summer, and autumn, while dips to 12% in winter. However, it is shown that extreme PV conditions, such "worst condition" and "best condition.", when it is not possible to employ self-consumption consistently, involve very few days of the year (red and dark green columns). On the other hand, Figure 12b shows Δ considering the load, and the PV power of each working day (288 days). Unlike Figure 12a, Δ is calculated basing on the different values of , with reference to = [1; 3; 7]. Concerning to = 1, it is shown that the maximum value of Δ is about + 20% and half of the days are not affected by PCC peak increments. However, the peak could reach even + 40% ( = 3) and + 100% ( = 7) in the worst conditions, of which the half of the days have a Δ > + 20% with = 3, and Δ > + 40% with = 7. The next Section shows the possibility to improve performances by introducing the smart charging mode.

CMS Effects on Power Flow: Smart Charging Mode
The SA-CMS, which manages the reference scenario's power flows, measures the PV power and collects information about the N = 100 vehicles during charging (from the CSs). The CMS makes sure that the total EVs' power remains below the PV generation by modulating the charge of each vehicle. The system detects the number of EVs ( ) that are charging within each time interval and modulates (decreases) the maximum reference power that vehicles can absorb from the charging station, according to the PV power and . Since the EV may be connected to the CS without absorbing On the other hand, Figure 12b shows ∆P PCC considering the load, and the PV power of each working day (288 days). Unlike Figure 12a, ∆P PCC is calculated basing on the different values of SOC 0 , with reference to d k = [1; 3; 7]. Concerning to d k = 1, it is shown that the maximum value of ∆P PCC is about + 20% and half of the days are not affected by PCC peak increments. However, the peak could reach even + 40% (d k = 3) and + 100% (d k = 7) in the worst conditions, of which the half of the days have a ∆P PCC > + 20% with d k = 3, and ∆P PCC > + 40% with d k = 7. The next Section shows the possibility to improve performances by introducing the smart charging mode.

CMS Effects on Power Flow: Smart Charging Mode
The SA-CMS, which manages the reference scenario's power flows, measures the PV power and collects information about the N = 100 vehicles during charging (from the CSs). The CMS makes sure that the total EVs' power remains below the PV generation by modulating the charge of each vehicle. The system detects the number of EVs (N ch ) that are charging within each time interval and modulates (decreases) the maximum reference power that vehicles can absorb from the charging station, according to the PV power and N ch . Since the EV may be connected to the CS without absorbing power (see Section 2.4), N ch could be different from the number of plugged vehicles. The higher the N ch is, the lower the P EVi is during charging (P * EVi ∝ PV/N ch ). On the other hand, if the PV power increases, the CMS increases the charging power of each vehicle. Figure 13a shows as an example of the values of N ch with d k = 3 and with a PV mean condition. The reference profile P * CS for each charging station is shown in Figure 13b. It can be seen how the CMS reference power (black) departs from the standard value (No-CMS, red dotted-line) to follow the PV profile. Each EVs' charging power also depends on the on-board charger rating and battery SOC (see Equation (4) and Figure 7), however, the CMS is able to control utilizing the reference signal * within the on-board charger limits). Figure 14a shows the charging power of each EV considering no smart charging action. On the other hand, Figure 14b shows the charging power of the vehicles Each EVs' charging power also depends on the on-board charger rating and battery SOC (see Equation (4) and Figure 7), however, the CMS is able to control P EVi utilizing the reference signal P * CS (within the on-board charger limits). Figure 14a shows the charging power of each EV considering no smart charging action. On the other hand, Figure 14b shows the charging power of the vehicles under CMS control allowing smart charging. Different values of P EVi can be seen in the plot. They depend on the maximum on-board charger rating, on the battery capacity and on the SOC variation during the charging process. As a result, the CMS allows the load shaving during peak hours and energy shifting towards hours of more significant internal generation.
(a) (b) Figure 13. Input and output CMS (SA) parameters: (a) the PV power measurement (red) and the number of EVs charging (blue); (b) the output reference power for each charging station.
Each EVs' charging power also depends on the on-board charger rating and battery SOC (see Equation (4) and Figure 7), however, the CMS is able to control utilizing the reference signal * within the on-board charger limits). Figure 14a shows the charging power of each EV considering no smart charging action. On the other hand, Figure 14b shows the charging power of the vehicles under CMS control allowing smart charging. Different values of can be seen in the plot. They depend on the maximum on-board charger rating, on the battery capacity and on the SOC variation during the charging process. As a result, the CMS allows the load shaving during peak hours and energy shifting towards hours of more significant internal generation. To evaluate the CMS effect on the total power flows, the aggregated EVs' load was calculated and compared with the results that were previously obtained in Section 4. Figure 15 shows the total EVs' load under the same initial and boundary conditions: = [1; 3; 7] and the PV generation conditions (worst, mean, and best condition). The figure shows that the smart charging allows the load shifting following the PV profile. The EVs' power remains below the PV profile, thus leading to an increase in the system's self-consumption. As before, colored areas in the figure show the self-consumption energy. In all simulated scenarios, the entire EV charging energy is provided by internal sources, consequently, the reaches 100%. Of course, this kind of control decreases the daily energy To evaluate the CMS effect on the total power flows, the aggregated EVs' load was calculated and compared with the results that were previously obtained in Section 4. Figure 15 shows the total EVs' load under the same initial and boundary conditions: d k = [1; 3; 7] and the PV generation conditions (worst, mean, and best condition). The figure shows that the smart charging allows the load shifting following the PV profile. The EVs' power remains below the PV profile, thus leading to an increase in the system's self-consumption. As before, colored areas in the figure show the self-consumption energy. In all simulated scenarios, the entire EV charging energy is provided by internal sources, consequently, the η SC reaches 100%. Of course, this kind of control decreases the daily energy provided for charging services on the base of PV availability (the denominator in Equation (15)). For this reason, the η SC may result in 100% even in the negative conditions (where it previously exceeded its maximum value). Thus, to evaluate the effectiveness of the CMS on the management of power flows, it is also necessary to measure the variation of the daily charge energy. provided for charging services on the base of PV availability (the denominator in Equation (15)). For this reason, the may result in 100% even in the negative conditions (where it previously exceeded its maximum value). Thus, to evaluate the effectiveness of the CMS on the management of power flows, it is also necessary to measure the variation of the daily charge energy.  Figure 16 shows the CMS effect on PCC power flows. It is readily clear from the picture that the system's load is much more balanced. The CMS acts on the load peak that previously occurred during the morning hours (around 10:00 a.m.). Moreover, as well as the peak shaving, this shifts the load energy towards the middle of the day and evening hours. The results show that the peak values do  Figure 16 shows the CMS effect on PCC power flows. It is readily clear from the picture that the system's load is much more balanced. The CMS acts on the load peak that previously occurred during the morning hours (around 10:00 a.m.). Moreover, as well as the peak shaving, this shifts the load energy towards the middle of the day and evening hours. The results show that the peak values do not exceed +10% more than in scenarios without EVs. Smart charging allows reaching peak reductions, even up to −50% compared to no-CMS results (see Figure 11). However, it is essential to note that, even in worst peak case ∆P PCC = 10%, the PCC power remains within the power limits of the plant's electrical load, and at most, if the PV energy is totally used for vehicle charging, the PCC power coincides with the load power (P PCC = P L ) shown in Figure 8b. This means that the system should already be correctly dimensioned and also designed to provide aggregate EVs charging. Figure 15. Comparison of the total power flows with SA-CMS. The red curves are the PV power, the blue curves are with = [1;3;7], while the dotted blue curves are the standard (No-CMS) EV load profiles. The colorized areas show the self-consumption energy according to the PV generation conditions: worst condition (left), the mean condition (center), and the best condition (right) Figure 16 shows the CMS effect on PCC power flows. It is readily clear from the picture that the system's load is much more balanced. The CMS acts on the load peak that previously occurred during the morning hours (around 10:00 a.m.). Moreover, as well as the peak shaving, this shifts the load energy towards the middle of the day and evening hours. The results show that the peak values do not exceed +10% more than in scenarios without EVs. Smart charging allows reaching peak reductions, even up to −50% compared to no-CMS results (see Figure 11). However, it is essential to note that, even in worst peak case Δ = 10%, the PCC power remains within the power limits of the plant's electrical load, and at most, if the PV energy is totally used for vehicle charging, the PCC power coincides with the load power ( ) shown in Figure 8b. This means that the system should already be correctly dimensioned and also designed to provide aggregate EVs charging.

Discussion
The proposed CMS aims to maximize the EVs' charging self-consumption by modulating each EV's power during the charging process and operates in smart charging mode. The logic is to make the EVs charging load controllable in order to provide the greatest overlap between the daily demand curve and the RES generation profile (in this case, a PV source). However, the PV power, which is non-programmable, depends on the solar daily and the seasonal availability. Meanwhile, the charg-

Discussion
The proposed CMS aims to maximize the EVs' charging self-consumption by modulating each EV's power during the charging process and operates in smart charging mode. The logic is to make the EVs charging load controllable in order to provide the greatest overlap between the daily demand curve and the RES generation profile (in this case, a PV source). However, the PV power, which is non-programmable, depends on the solar daily and the seasonal availability. Meanwhile, the charging energy demand depends on the users' behavior and EV characteristics, such as the battery capacity and the specific consumption (as Section 2 shows). For these reasons, the power flows could be strongly different based both on the PV generation and the energy request. For providing the possible cases' overview, three different conditions for both the daily PV power and EVs' charging power, have been considered. Consequently, the proposed conditions are given by the combination of the "worst", the "mean", and the "best" PV conditions with the "high demand" (d k = 7), the "medium demand" (d k = 3), and the "low demand" (d k = 1) of the EVs' daily load. For each condition, the simulation results have been collected considering the operation in the standard mode (no-CMS) and smart charging mode (CMS). To evaluate the effects of the smart charging on the self-consumptions and power flows, Table 6 and Equations (16)- (18) are introduced. Table 6 shows the CMS effects on the performance parameters through a comparison with their values in the case of a no-smart charging mode (no-CMS): where ∆η SC compares the self-consumption, ∆P peak compares the PCC peak load and ∆E ch evaluates the difference in the charge energy between the CMS and no-CMS mode. Based on the initial conditions, the parameters show scenarios in which the self-consumption presents a relevant improvement (up to + 70%) and the PCC load peak a drastic reduction (about −50%), as shown in green cells in Table 6, at the expense of the daily energy provided to the vehicles (up to about 80% less). On the other hand, the results also show conditions in which the CMS does not improve charging performances, such as the cell (d k = 1, best condition), red cells in Table 6. However, under average conditions, Table 6, in reference to the yellow and fuzzy color cells, the growth of the self-consumption can reach a reasonable compromise with the reduction of E ch and with the peak shaving values. Considering the PV mean condition and the SOC 0 (d k = 3), where the average of the initial EVs' SOC is about 50 %, the self-consumption reaches 100% (∆η SC = +24%), and the PCC peak power is only about + 10% (∆P peak = −14%). Furthermore, the CMS decreases the EV charging energy by only 9%. Moreover, as shown in Figure 12a, this type of scenario (average conditions) occurs in the vast majority of the days of the year. Therefore, the results just presented (∆η SC ≈ +24%, ∆P peak ≈ −14%, ∆E ch ≈ 9%), in terms of performance improvement, might be the most relevant results.

Conclusions
This paper provides a methodology to predict aggregate power flows of EVs charging in positive energy districts and a smart charging system to optimize the self-consumption from distributed renewable energy sources. The forecasting method takes into account the main factors and parameters that influence the charging process. Both the characteristics of EVs and CS infrastructures were considered to evaluate the daily power flow of an EV's population. In addition to the CSs and EVs chargers' power rating, each charging event was calculated by also considering the power variation due to the vehicles' battery characteristics, which depend on the SOC and C-rate. In this respect, the initial values of SOC for each vehicle were obtained by a statistical analysis of daily consumptions. The charging duration and the initial and final time of each charging event depend on the drivers' behavior. For these reasons, in this work, the data on arrivals and departures time in working place parking lots were collected and processed. Then, it was possible to extrapolate a probabilistic function that emulates the users' behavior in terms of parking times. Through that, it is possible to extend this behavior to any population with a different number of vehicles. Thus, the prediction algorithm has been tested on a population of 100 EVs.
The reference scenario, on which the simulations were run, consisted of an industrial area having one charging point for every parking place. The case study presented a non-programmable generation source (PV plant) and a non-modulable electrical load that absorbs energy from the grid. Aggregated EV load and its impact on the daily plant power profile were evaluated considering several conditions of PV profile and EV drivers' behavior.
Then, performance parameters such as the charging self-consumption and the peak percentage value were introduced. Initial conditions greatly influence the results obtained. However, considering the average conditions, the results have shown that the charge self-consumption does not reach its maximum value, remaining less than 80%. On the other hand, for most of the analyzed days, peaks increase by more than 20%.
To improve these performance parameters, a charging management system was then introduced. The CMS regulates the power that each CS provides to the vehicle intending to operate in smart charging mode. The results show the smart charging effects on power flows: the CMS shifts the EVs' energy request towards hours when internal sources are more available. Therefore, it is demonstrated that smart charging applies the peak shaving and shifting of the EV's load that results in improved system charging performance. The self-consumption was increased by about 20% ÷ 40% (reaching 100%) in comparison with the case without the CMS, and the peak load value reduced by 10% ÷ 30%. Therefore, the proposed CMS can be considered for enhancing performances in positive energy districts.
Future works could investigate the aggregate EV power flow of other parking scenarios, such as malls, municipal parking, stations, airports, and city center parking lots. Moreover, a CMS able to operate in V1G/V2G mode (following the TSO's dispatching orders) or capable of following the price of the energy during the charging (energy-price tracking) may be implemented in the future. Finally, by processing the parking time and drivers' behavior data, it may be possible to identify the best scenario for all operating modes (SC, V1G/V2G, and energy-price tracking mode) and/or the best mode for each scenario.