# Dynamic Energy Management Strategy of a Solar-and-Energy Storage-Integrated Smart Charging Station
## 4 Smart EMS Control
### Dynamic Energy Management System Strategy  
The EMS employed in this solar-and-energy storage-integrated charging station is designed to optimize the usage of solar energy, particularly for EV charging. This prioritization aligns with the overarching goal of maximizing renewable energy utilization, reducing dependence on grid-supplied electricity, and minimizing the carbon footprint of the charging process. The EMS dynamically manages the power flow, giving precedence to EV charging during periods of high solar energy availability. This strategy not only leverages the environmental benefits of solar power but also aims to lower operational costs by using self-generated energy, which is generally more cost-effective compared to grid electricity, especially when considering the long-term investment in solar infrastructure. The EMS systematically addresses the charging needs of electric vehicles based on several parameters, including the current SOC of the EV, desired SOC, battery capacity, current time, and planned departure time. The system incorporates a 5 min buffer period to approximate actual EV charging behavior, enhancing the accuracy of its demand forecasts. This information, along with the ESS's SOC and the current TOU electricity tariff, is integrated into Equation (5). In considering the losses of the ESS, as mentioned in the previous battery content, given the difficulty in accounting for and accurately calculating numerous physical parameters, these are initially omitted to facilitate the feasibility of model computation and construction. When the cumulative charging demand surpasses the station's contracted capacity, the EMS proportionally allocates power among the EVSEs based on individual EV requirements Equation (6), facilitating the computation of each vehicle's charging power Equation (7). The total power demand of the station is then determined by summing the individual charging powers Equation (8). \[P_{\rm{EV-i}}=\frac{(\text{SOC}_{EV-id}-\text{SOC}_{EV-i}(t))C_{EV-i}}{t_{di}-t- \Delta t} \tag{5}\]  
\[p_{i}=\frac{(\text{SOC}_{EV-id}-\text{SOC}_{EV-i}(t))\text{C}_{EV-i}}{t_{di}- t-\Delta t}\times\frac{1}{P_{det}} \tag{6}\]  
\[P_{\rm{EV-i-limit}}=p_{i}\times P_{max} \tag{7}\]  
\[P_{det}=\sum_{i=1}^{N_{EV}}P_{\rm{EV-i}} \tag{8}\]  
where \(P_{\rm{EV-i}}\) is the charging power under typical circumstances, \(\text{SOC}_{EV-id}\) is the desired state of charge, \(\text{SOC}_{EV-i}\) is the current SOC of the EV at the charging station, \(C_{EV-i}\) is the battery capacity, \(t\) is the current time, \(t_{di}\) is the departure time, \(\Delta t\) is the buffer period before the charging ends, \(p_{i}\) is the ratio of charging power, \(P_{dem}\) is the total station power demand, \(P_{\rm{EV-i-limit}}\) is the individual electric vehicle charging power, \(P_{max}\) is the maximum power that can be provided to the charging station by the system, and \(N_{EV}\) is the total number of electric vehicles. The overarching control strategy of the EMS gives priority to EV charging, aiming to maximize the use of solar energy. Following this, it addresses the charging of the energy storage system. Any excess electricity is then flexibly allocated to other loads within the system or fed back into the grid. In instances where the energy in the ESS is depleted (SOC lower than 20%), the EMS will source power from the grid to maintain continuous operation. Furthermore, the EMS also executes real-time adjustment strategies based on the conditions of solar energy, ESS, and the grid. This encompasses utilizing the ESS to smooth out solar energy fluctuations, achieved through a Moving Average method (MA) where the average of the preceding n instantaneous solar power values is calculated, as depicted in Equation (9). \[P_{MA}(t)=\frac{P_{PV}(t-1)+P_{PV}(t-2)+\cdots+P_{PV}(t-n)}{n} \tag{9}\]  
where \(P_{MA}(t)\) is the \(PV\) output power achieved through a Moving Average method at time t, \(P_{PV}(t)\) is the \(PV\) output power at time t, and \(n\) is the division number of time.