## 4 EMS Optimization
### Grid Power and Grid Price  
Grid power (Figure 4) displays the variation in grid power over 24 h, with a time scale ranging from 0 to 25 h for comprehensive data representation. The power scale spans from \(-50\) to 100 kW. Starting around 75 kW, the grid power fluctuates throughout the day, peaking at approximately 30 kW and occasionally reaching 75 kW again, before ending around \(-5\) kW at the 24 th h. This figure illustrates how grid power supply varies over time, influenced by demand fluctuations and operational adjustments within the power network. Figure 4 illustrates the grid power variations (in kW) over a 24 h period, as managed by the energy management system (EMS). The horizontal axis indicates time from 0 to 24 h, while the vertical axis shows power in kilowatts (kW), ranging from \(-50\) kW to 100 kW. * Daytime Period (6:00 AM-6:00 PM, 6 to 18 h): During the day, the grid power demonstrates significant fluctuations, with frequent shifts between positive and negative values. These variations are due to the integration of solar energy, which can cause sudden changes in the power supplied to the grid. The EMS works actively during this period to balance the grid by adjusting power levels to match the variable generation and demand. * Nighttime Period (6:00 PM-6:00 AM, 18 to 6 h): At night, the grid power continues to fluctuate but generally within a narrower range. The absence of solar energy input leads to more stable power management, although the EMS still responds to changes in load demand and other grid conditions. Figure 4 highlights the dynamic nature of grid power management across a 24 h cycle, with distinct patterns corresponding to daylight and nighttime hours. Understanding these fluctuations is essential for optimizing EMS operations, improving grid stability, and ensuring efficient integration of renewable energy sources. Figure 3: Battery Power. In the context of grid power, negative power values indicate instances where the power flow is reversed, meaning that power is being sent back to the grid instead of being drawn from it. This can happen in systems that incorporate renewable energy sources and energy storage systems, where surplus generated power is exported to the grid. In the described scenario, grid power varies between \(-\)50 kW and 100 kW over a 24 h period. Initially, the value is around 75 kW, suggesting that the system is drawing power from the grid. As the day progresses, the amount of power drawn from the grid fluctuates, peaking at approximately 30 kW and occasionally returning to 75 kW. The significant point is the ending value of around \(-\)5 kW at the 24 th h, indicating that at this point, the system is exporting 5 kW of power back to the grid. This reverse flow of power can occur for several reasons:  
1. Excess Renewable Energy Generation: During periods of high renewable energy production, such as peak sunlight hours for solar panels, the generated power may exceed the immediate consumption needs. The surplus power is then fed back into the grid. 2. Optimal Energy Management: The energy management system (EMS) may be designed to export excess stored energy from battery energy storage systems (BESSs) or hydrogen energy storage systems (HESSs) when grid prices are high or to balance overall grid demand and supply. 3. Demand Response Strategies: Negative power flow can also be part of demand response strategies, where the EMS decides to supply power to the grid at specific times to help stabilize grid operations or take advantage of favorable pricing conditions. Negative power values in the grid power data reflect times when the system is not drawing power from the grid but instead contributing power to it. This capability is crucial for enhancing grid stability, optimizing energy costs, and making efficient use of renewable energy resources. Grid price (Figure 5) shows the fluctuation in grid price over the same 24 h period, with a time scale and range matching Figure 4. The grid price scale ranges from 75 to 120 USD/kWh.