# Optimal Energy Management within a Microgrid: A Comparative Study
## 5 Results
### Microgrid Test  
The microgrid test (MT) described previously is shown in Figure 7. The microgrid is connected to the main grid through the single PCC (Node 1). Furthermore, between the Nodes 3-6, 4-7, 5-8, and Nodes 9, 10, there are transformers connected. The elements that have the ability to provide active power are the main grid (PCC), WT, PV, PEV, and the battery. The parameters considered for modeling the components of this MT and the cost coefficients associated with imported energy through the PCC are presented in Tables A1 and A2 given in Appendix A. The PEV are composed of four EV, while the forecasting curve of load, the irradiation profile for two different clear days (summer and winter), and the speed of wind corresponding to the city of Almeria, Spain, can be observed in Figure 8. All the power within the microgrid is working on per unit (p.u. ), where the power base and voltage base were selected to be 10 kW and 100 V, respectively. The voltage magnitude limits for all nodes in the microgrid are \(0.95\leq V\leq 1.05\) p.u. The SOC limits on the battery are \(0.2\leq\text{SOC}_{B}(t_{2})\leq 0.95(\%)\), whilst the initial condition of the battery charge is \(\text{SOC}_{B}(t_{0})=0.9(\%)\). Moreover, all the cars in the PEV will be connected to the microgrid at hour 8 and disconnected at hour 18. All the cars have initial SOC as shown in Table 1. To compensate the owners of the EV for the use of the battery, at the end of hour 18, the SOC in the battery will be 100% (\(\text{SOCVH}\ (t_{\text{end}})=1\)). The SOC limits in the PEV for all the EV are \(0.05\leq\text{SOC}_{\text{PEV}}(t_{2})\leq 100(\%)\). Figure 8: Forecasting curves for the microgrid test. (**a**) Load forecast curve; (**b**) wind speed profile for Almeria, Spain; (**c**) irradiation profile for clear days in summer (blue) and winter (red). Figure 7: Microgrid test scheme. The OPF was solved using the interior point method provided by the \"fmincon\" function developed by MATLAB(r), the direct search method with interior point hybrid (GA-IP), and hybrid genetic algorithm with interior point (patternsearch-IP); their results are discussed below. Figure 9 shows the active power supplied by the battery, PEV, WT, and PV, and the imported power from the main grid. The powers of the PV and WT are for a clear summer day. This figure shows that between the stages 0 and 6 h or 20 and 24 h the power demand by the load is small (35 kW), and the generators (PV, WT) and batteries supply this power to satisfy the load demand. Nevertheless, between 8 and 10 h or 16 and 20 h, the power supplied by the generators and the batteries is not enough to supply the load demand, making it necessary to import power from the main grid to satisfy the load and avoid problems within the microgrid. In addition, the PV have the maximum power supplied between 9 and 17 h, agreeing with the forecasting profile of irradiance shown in Figure 8a; in the same way, the maximum power of WT corresponds to the maximum speed of wind predicted by the forecasting profile of wind speed shown in Figure 8b. It is noteworthy that the PEV and the battery are working in charge mode when the power supplied by the PV and PW is high. This power storage in the PEV and battery is important to reduce the energy cost when peak load demand exists (8-10 h with PEV and 16-20 h with battery)--in other words, to reduce imported power from the main grid. Figure 10 shows the state of charge of the battery and the PEV, confirming the previous idea. \begin{table}
\begin{tabular}{c c} \hline \hline
**Vehicle Number** & **Initial SOC (\%)** \\ \hline
1 & 0.40 \\
2 & 0.30 \\
3 & 0.60 \\
4 & 0.70 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Initial State of Charge (SOC) of the electric vehicles. Figure 9: Result of the power in generators for a clear summer day. In Figure 11 it is possible to see the active power supplied by the elements within the microgrid (WT, PV, Battery, PEV, and Main grid) on a clear winter day.