## 4 Modeling of the Microgrid
Similarly, in the FiT billing model, the extra energy will be injected back into the grid at a lower rate based on current market trends. However, under this model, the yearly quantity of energy that exceeds the prosumer's total annual consumption is compensated at the applicable FiT rate. The power equations that govern the model are defined hereafter:  
If solar PV AC power is greater than or equal to the prosumer load, the latter is met solely by solar PV power. The power provided via the utility grid \(P_{U,i}\) is zero. \[P_{i}=P_{PV,\ i} \tag{1}\]  
The excess energy injected back into the grid or sold via the P2P energy trading model is calculated using Equation (2):  
\[P_{sold}\ =P_{PV,\ i}-P_{i} \tag{2}\]If solar PV AC power is less than the prosumer load, the latter is met by the solar PV power complemented by the utility grid power. \[P_{i}=P_{PV,i}+P_{U,i} \tag{3}\]  
where  
\(P_{i}\) is the power demand of the consumer;  
\(P_{U,i}\) is the power provided by the utility company;  
\(P_{PV,i}\) is the power provided by the solar PV system;  
\(P_{sold}\) is the excess power that can be used for trading. In P2P energy trading models, managing the energy balance between supply and demand is crucial for ensuring stability and efficiency. When participants in a P2P network sell excess energy, this surplus is allocated to other users who need additional power. However, if the total amount of excess energy sold falls short of meeting the demand of buyers, the deficit must be supplemented from the traditional grid. This mechanism ensures that while P2P trading maximizes the use of locally generated renewable energy, it also maintains a reliable power supply by drawing from the grid when necessary. This integration helps to balance the fluctuating nature of renewable sources and ensures that energy needs are met even when P2P transactions alone cannot satisfy the demand. By effectively managing these scenarios, P2P systems can contribute to a more resilient and flexible energy infrastructure, supporting both sustainable energy use and grid stability. In a real-world scenario of P2P energy trading, prices are determined through negotiations based on the balance of supply and demand, along with individual preferences and limitations. Despite the dynamic nature of markets, the presence of competition and price variations among markets or sources typically prevent drastic fluctuations, leading to price stability at a certain average level. An average negotiated rate was utilized to exchange energy in the blockchain-based P2P energy trading system to simplify the simulation model. Furthermore, in cases where electricity is not produced by the utility itself, such as in deregulated markets or P2P energy trading situations, the utility typically charges for electricity transmission through its networks. This charge, known as the wheeling charge, typically accounts for 15% of the applicable tariff. The tariffs and rates used in our simulation scenarios are defined in Table 1.  
Figure 5 depicts a flow chart demonstrating our simulation model's sequential processes and exchanges, providing a more organized and concise understanding of the workflow. To simplify the calculations and maintain this paper's main objective, we have made certain assumptions in the model. The impact of holidays, where consumer loads may vary, has not been considered. This is because the proportion of holidays to the total number of days in a year is minimal and does not significantly affect the calculation results. As the PV system is connected to the main power source and operates in synchronization with it, it is assumed that the quality of the main source is standard in terms of voltage and frequency. The calculation does not consider energy transmission losses which occur when energy is transported over long distances from the source of generation to the point of consumption. These losses are usually significant at a transmission level. However, in our microgrid model on a regional distribution level, the distanc