## 3 Modeling of Backup Systems
### Battery Storage System  
The BESS is crucial for providing immediate power supply and balancing energy demand within the HEMS. By accumulating energy in batteries when there is an excess and discharging it during shortages, the BESS ensures a stable power output. This system is defined by its high efficiency, quick response time, and the ability to deliver power instantly. The BESS helps mitigate fluctuations in energy supply from renewable sources, contributing to a stable and reliable energy system. Additionally, the SOC of the batteries is continuously monitored and managed to maximize their lifespan and performance. The BESS offers a versatile solution that enhances the overall reliability and efficiency of the HEMS by providing both short-term and long-term energy storage. The SOC of the battery while charging can be determined using the following formula, which represents the energy stored at time t during the charging cycle [55; 56].  
\[C_{batt}(t) =C_{batt}(t-1)\times(1-\sigma)+\bigg{(}P_{PV}(t)+P_{W}(t)+P_{FC}(t)- \frac{P_{L}(t)}{\eta_{inv}}\bigg{)}\eta_{batt} \tag{15}\]  
The SOC of the battery during the charging process is calculated using a formula that accounts for the energy stored at the previous time step, the self-discharge rate, and the net energy available from RESs and FCs after meeting the load demand. Specifically, the SOC at time t is determined by adding the energy contributions from PV, WTs, and FCs, while subtracting the load demand adjusted for inverter efficiency, and then applying the battery's charging efficiency. This equation ensures an accurate representation of the battery's energy storage level, reflecting both the energy inputs and losses, and is crucial for managing the battery's performance and optimizing energy storage in a renewable energy system. The energy stored in the battery during discharge mode can be determined using this equation:  
\[C_{batt}(t) =C_{batt}(t-1)\times(1-\sigma)-\left(\frac{P_{L}(t)}{\eta_{inv}}- \left(P_{PV}(t)+P_{W}(t)+P_{FC}(t)\right)\right) \tag{16}\]  
The equation calculates the SOC of a battery during discharge mode by considering both the energy used to meet the load demand and the contributions from RESs such as PV, WTs, and FCs. The SOC at the current time t is derived by first accounting for natural self-discharge, then subtracting the net energy drawn from the battery after renewable generation has been applied. This equation ensures that the battery's energy depletion is accurately tracked, reflecting the actual power requirements and the support provided by other energy sources, thereby optimizing the battery's role in maintaining the system's energy balance. The energy storage in the battery is governed by the following constraints:  
\[C_{batt-min}\leq C_{batt}(t)\leq C_{batt-max} \tag{17}\]  
\[C_{batt-min} =\text{DOD}\times C_{batt-nom} \tag{18}\]  
The battery SOC constraints ensure that the battery operates within safe and efficient limits, maintaining the SOC between a defined minimum and maximum level. The minimum SOC (\(C_{batt-min}\)), is calculated based on the DOD and the nominal capacity of the battery (\(C_{batt-nom}\)), indicating the lowest level to which the battery can be safely discharged. The maximum SOC (\(C_{batt-max}\)), prevents overcharging, which could damage the battery. These constraints are essential for preserving battery health, optimizing performance, and extending the battery's lifespan by preventing harmful conditions such as deep discharging or overcharging.