## 4 Modeling of the Microgrid
Prosumer A\({}^{\prime}\) is an improved version of Prosumer A, with a 30% increase in efficiency. As a result, its residential load is 30% lower than Prosumer A's, which serves as our benchmark. Prosumer A\({}^{\prime}\) could also represent a newly constructed house compared to an older one being represented by Prosumer A. The new house would have better insulation, reduce the need for heating and cooling, and be equipped with high efficiency appliances, decreasing overall energy consumption. The purpose of introducing Prosumer A\({}^{\prime}\) in the model is to investigate the impact of a reduced load, with the same PV system capacity, on the use of P2P. This allows us to determine if it is a cost-effective option or not. Prosumer B is a type of residential load where the owners only utilize the house for vacation during the summer season, specifically for 3 months from June 22 nd to September 21 st. The energy consumption for the remainder of the year is represented by a small and constant load, including gardening and operating the security system. Prosumer B is a unique type of load that may have different outcomes when subjected to incentive programs compared to a full-time load. It would be intriguing to investigate the effects  
Figure 4: Simulated microgrid model. of installing a PV system on this particular load, potentially resulting in surplus energy during the unoccupied period. Both Prosumer A/A\({}^{\prime}\) and Prosumer B have a rooftop solar PV system with a capacity of 12.8 kWp. However, to evaluate the effect of the solar PV peak power on the three models, we have decided to analyze a situation where the 12.8 kWp system is replaced with a 10 kWp system. This particular scenario is referred to as scenario #2, while the original scenario will be referred to as scenario #1. We initially assumed that neither prosumer has a battery energy storage system (BESS). Therefore, we have simulated a scenario where a BESS was added for both prosumers. In this case, the BESS consists of 220 Ah, 12 V solar batteries, with 2 strings of 6 batteries connected in series, resulting in a total of 12 batteries. At a depth of discharge of 80%, the total capacity of the batteries is equivalent to 4.22 kWh. The purpose of including a BESS is to evaluate the impact of storing excess energy during hours of solar availability and selling it back to consumers during periods of low demand. This scenario is known as scenario #3. The blockchain-based P2P energy trading model allows prosumers to sell their excess energy to two consumers. Prosumer A/A\({}^{\prime}\) prioritizes using their own produced energy for their own use before selling any remaining excess to Consumers 3 and 4 at a negotiated rate. Similarly, Prosumer B uses the energy it produces for its own needs and then sells any extra to Consumers 1 and 2. It is assumed that consumers would be interested in buying excess energy from prosumers, whenever it is available, as it would typically be priced lower than the utility's tariff. However, any excess energy beyond the market demand would be wasted. Algorithm 1 summarizes the blockchain-based P2P energy trading model. ```
1:Initiate algorithm at time \(t\)
2:if PV power available, then
3:if Load of Prosumer < PV Generation, then
4:if the first consumer has a consumption, then
5:Pizk = min (Pk, PPV, \(i-\) Pij); \(k\) = 1
6:else, if the second consumer has a consumption,
7:thenPizk = min (Pk, PPV, \(i-\) Pii - Pii 21); \(k\) = 2
8:else, no transfer of energy
9:else, PV generation totally consumed by load of Prosumer and complemented, if needed, by energy from the grid; no transfer of energy
10:else, no PV generation; no transfer of energy
11:\(t\) = \(t+1\)
12:Goto 2//restart the algorithm
```  
**Algorithm 1**P2P Energy Trading  
Under the NEM billing system, any excess solar PV generation is injected into the grid at the same rate as the applicable utility tariff. Any excess energy that surpasses the prosumer's total yearly consumption will not be compensated at the end of the year.