## 4 Proposed Methodology
### Hosting Capacity Evaluation (Optimal Location and Sizing) by PSO Algorithm  
There are four ways to evaluate the capacity added to the network:  
Figure 3: Proposed (M-EMS). 1 Deterministic
2 Stochastic
3 Optimization
4 Streamlined  
All methods use the power flow calculation as a standard tool to determine the voltages and currents in distribution networks. The general procedures for the HC calculation are the same for all approaches as shown in Figure 4, despite the flow chart showing that their implementations varied greatly. The DG size is increased step by step unless there is a violation of a performance requirement. Renewable energy sources (RESs) are medium- to small-sized power sources that are placed close to the site of power use or directly connected to the low-voltage (LV) distribution network. By 2026, 528.4 GW of RES capacity is projected worldwide [29]. Natural resources like wind speed and sun irradiation have a significant impact on the output power of some RESs. As a result, there is a chance that the RESs' generation patterns and the load's consumption patterns will not match. In this instance, the distribution network, intended to supply power in a unidirectional manner, experiences a reverse flow of the excess energy generated during the period of low energy use. Therefore, difficulties in integrating RES into distribution networks arise from the sporadic nature of RES technologies and the reverse power flow. In order to overcome the challenges of integrating RES into distribution networks, it is essential to calculate how much RES can be added to the network without violating the operational standards. This is called hosting capacity [11]. These standards are as follows:  
1. Bus over-voltage. 2. Thermal overload. 3. Power loss. 4. Power quality. 5. Reliability. Figure 4: The flow chart for the calculating HC. To determine the HC that maximizes the RES integration while minimizing the costs or losses associated with distribution, a multi-objective function is constructed. Because the solar system can alter in response to changes in the weather and environment, it is based on temperature and sun irradiation. In addition to being necessary for energy storage, the battery can provide electricity if the PV system experiences an abnormality. The main issues with the distribution systems are the PV size, DG location, and charging-discharging processes. The power and voltage have an impact on the PV panels' capacity. Estimate the power that a single panel can produce, as this will be the same for all types of panels. Initially, let us talk about optimization methods that minimize the ideal size. A population-based search technique, the particle swarm optimization (PSO) algorithm, simulates the social behavior of birds in a flock. These optimization methods have the drawback of requiring multiple iterations in order to obtain an ideal solution. The battery is made to both store and release energy. IEEE 34 bus is used to assess the system. The battery stores the necessary power, which changes every 24 hours due to its dynamic nature. Start by running the fast decoupled load flow, which detects loss, voltage, and active and reactive power injection and hours analyzing the 24 h load flow for IEEE 34 bus systems. Equations (4) and (5) illustrate the energy and voltage limitations, and the energy is balanced above this. The PSO algorithm, which simulates the social behavior of birds in a flock, is a population-based search method. The original goal of the particle swarm concept was to simulate the elegant and erratic dancing of a flock of birds graphically. The idea was to find the patterns that control a bird's ability to fly in unison and to change course while regrouping in the best possible formation abruptly. The idea developed into an easy-to-use and effective optimization algorithm based on this original goal. Through the PSO algorithm, the PV size and the best placements are established. Equations (4) and (5) indicate the size of the PV (kW) in any location.