## 4 Tests and Numerical Results
### Grid Connected Tests  
The first set of tests aim to simulate either cases with low voltage magnitudes, or with high voltages and aims to mitigate the negative impacts. Single line diagram of the grid connected test case drawn is given in Figure 3. The line parameters are provided in Appendix A. In the first test, the initial status are chosen in order to analyze the behavior of the developed control to manage the undervoltage condition in the microgrid. In particular the initial values for the controllable components are given in Table 2. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \(P_{\text{Lithium}}\) & \(Q_{\text{Lithium}}\) & \(P_{\text{Lead}}\) & \(Q_{\text{Lead}}\) & \(P_{\text{NaNiCl}}\) \\ \hline \(-\)30 kW, 30 kW & \(-\)10 kVar, 10 kVar & \(-\)5 kW, 15 kW & \(-\)3 kVar, 3 kVar & \(-\)10 kW, 10 kW \\ \hline \(Q_{\text{NaNiCl}}\) & \(P_{\text{CHP}}\) & \(Q_{\text{CHP}}\) & \(P_{\text{Load}}\) & \(Q_{\text{Load}}\) \\ \hline \(-\)5 kVar, 5 kVar & 25 kW, 50 kW & \(-\)5 kVar, 5 kVar & 0 kW, 90 kW & 0 kVar,60 kVar \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Upper and lower limits of the control devices. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**Load** & \(\mathbf{PV_{load}}\) & \multicolumn{2}{c}{**Lithium**} & \multicolumn{2}{c}{**Lead**} & \multicolumn{2}{c}{**NaNiCl**} & \multicolumn{2}{c}{**CHP**} \\ \hline P (kW) & P (kW) & P (kW) & Q (kVar) & P (kW) & Q (kVar) & P (kW) & Q (kVar) & P (kVar) & PF \\ \hline
75 & 0 & 20 & \(-\)2 & 0 & 0 & 0 & 0 & 25 & 1 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Initial values set for Test 1. Under these initial conditions, voltage magnitudes of the PCC's node (reference node) and of the other components of the microgrid are shown in the upper part of the Figure 4. One may easily observe that the voltage magnitudes are lower compared with the PCC's voltage and need to be increased. For this aim, lithium-ion battery inputs (both active and reactive powers) were controlled and as shown in the figure around the 45 th second. The control allows the detection of near optimal values for the active and reactive power outputs that realize a better voltage profile. Note that in the initial condition lithium-ion battery was absorbing active power and supporting a small amount of reactive power, after the control operation is performed it is obvious that a better voltage profile is obtained. Figure 4: Voltage magnitude in test system over time and active and reactive power outputs in undervoltage condition and with the control of only a lithium-ion battery. Figure 3: Single line diagram of the grid connected test case. Considering the same conditions, a further test was performed taking into account the control of all the controllable resources. In Figure 5 the related results are shown. It is worth noting that resorting to all the controllable resources it is possible to reduce again the gap between the PCC's voltage and the other node's voltage in the microgrid. The second test was performed to observe the behavior during an overvoltage. For this aim the initial load values were set to 0 and as expected the voltage magnitudes in the system increased. The power values of Lead and NaNiCl batteries and the active loads on PV are controlled. Initial settings for this test case are given in Table 3.  
Under these initial conditions, voltage magnitudes of several components are shown in Figure 6. Opposite to the previous test case, the voltage magnitudes are high and need to be lowered. This test case optimizes all the controllable resources in terms of active and reactive power. Around the 45 th second, the control operation is applied and may be easily seen from the figure most of the components starts to charge themselves, and hence the voltage magnitudes in the system decrease and the gap between the PCC's voltage and the other node's voltage in the microgrid is reduced. Figure 5: Voltage magnitudes in test system over time and active and reactive power outputs in undervoltage condition and with the control of all the resources.