## 4 Simulation and Results
The optimized features of FCs are detailed in Figure 13. Moreover, the fuel consumption during FC energy management is a noteworthy aspect, and its details are presented in its characteristics. Figure 14 depicts the characteristics of the battery system during simulation. This illustration emphasizes the significant role of SoC in the battery storage system. SoC depends entirely on two factors: voltage and current level of battery. When the current level of battery lags behind the voltage level, the battery's state of charge should be high. Meanwhile, when the current level starts to rise, more current is drawn from the battery to meet the load requirements. So, SoC in batteries plays a vital role within hydrogen-based microgrids. Through precise energy management, the state of charge for the battery stabilizes at approximately 65% and maintains this level through continuous system optimization. Figure 11: Cost estimation of the system with PSO. Figure 12: Optimized output of the entire system. Ultimately, the voltage convergence is determined and displayed in Table 3.0 Each phase of voltage reaches its specific convergence point. Three phases are dealt separately with color discriminates like red, yellow, and blue. All convergences are found within the 30 iterations as prescribed for the entire system. The converged voltage complies with a predefined constraint, ensuring it falls within the range of \(-2\) to \(2\) for the respective phase. The convergence criterion was established using the PSO technique. Complete convergence was achieved within 30 iterations. In this context, voltage represents the local best quantity, while the output power of the hydrogen-based microgrid serves as the global convergence value. An optimized voltage profile has been developed for the system. By improving the voltage quality, the output power is optimized, leading to increased system reliability. The power variations have been mitigated by enhancing the system's power quality. As the system's voltage converges, the overall power quality of the entire system is improved. This aligns with the second objective of the paper. Figure 16 illustrates the variation in electrical generation throughout the day, specifically from solar and wind sources. It also indicates any surplus power generated and presents the combined output of both sources. Figure 17 illustrates the hourly voltage profile over a typical day, describing the voltage for the load, solar, and wind sources. Table 3.1 Optimized battery characteristics. Table 3.2 Optimized fuel cell characteristics. The comparison of this research with different studies is described in Table 5, with a graphical representation provided in Table 3.3 The representation of results has been significantly improved, and voltage convergence has been ensured in the research. The results, however, highlight the effectiveness of our approach, which surpasses previous methods in terms of voltage convergence and enhancing power quality. The generation mix for 1 day totals approximately 4.2 MW, while the voltage profile for a typical day illustrates the load coverage with the ease of hydrogen storage with 100 kW. The system is optimized through efficient optimization techniques, ensuring the fulfillment of load requirements at reduced costs in the long run. All the results are much better than the aforementioned studies and advanced conferring to power profile improvement as well. As depicted in Table 5 above, the proposed model outperforms the previous studies in terms of both convergence speed and accuracy. When the power quality is enhanced to meet demand, the convergence and accuracy occur sooner, as detailed in this article. However, in the face of increased load unpredictability, both the microgrid's current cost and energy efficiency decline. Table 5 clearly illustrates that the applied methodology reduces the cost for an MG system from 24.4 to 22.9 million dollars while simultaneously enhancing power quality with 100 iterations.