## 2 EV Power Controlling (EVPC) Scheme  
### MG Energy Management and Control  
The stochastic behavior of RESs might cause inevitable concerns for the reliable operation of an islanded-MG. Any power fluctuation in such energy resources may lead to imbalance between load and generation, and, as a result, the frequency may deviate from its nominal value. On the other hand, an appropriate EV energy management strategy can respond to system frequency deviation and thus provide primary frequency regulation. EVs can supply (absorb) energy to (from) the network considering two possible operating modes: grid to vehicle (G2V) mode (charge and absorb power) and V2G mode (discharge and inject power to the network). Thus, from the MG operator's point of view, EVs can act both as load and generation. EVs participate in frequency control to charge in low load or high generation hours and discharge during high load or low renewable generation hours. In order to measure the power mismatch between demand and renewable resources generation, an indicator is introduced here as demand not supplied by renewable sources (\(DNS_{\text{Ren}}\)) and defined as below:  
\[DNS_{\text{Ren}}(t)=D(t)-P_{\text{Ren}}(t)\quad\forall t\in T, \tag{1}\]  
where \(D(t)\) and \(P_{\text{Ren}}(t)\) are total demand and generation of renewable resources in period \(t\), respectively. In an isolated MG without energy storage, \(DNS_{\text{Ren}}\) should be supplied by dispatchable generators (DGs). The difference between the maximum installed capacity of DG units and \(DNS_{\text{Ren}}\) stands for the spinning reserve capacity of MG. Here, the normalized value of this capacity is defined as stability margin index (\(\mathit{SMI}\)):  
\[\mathit{SMI}(t)=1-\frac{DNS_{\text{Ren}}(t)}{\sum\limits_{i\in\text{NG}}P_{i} ^{\text{max}}}\quad\forall t. \tag{2}\]  
The SMI index value at each time period depends on the installed capacity of DG units, output power of renewable resources and customers' demand. As an illustrative example, the variation of SMI during 24 h of a given day is shown in Figure 1. When the total demand is supplied by renewable resources, SMI value is 1 and it is zero if \(DNS_{\text{Ren}}\) is equal to the total installed capacity of DGs. If the generated power of RESs is more than the total demand, then SMI will be more than 1 (e.g., point \(P_{1}\) in Figure 1). In this case, as it can be observed, the system frequency is unstable, and, in order to keep frequency within its nominal value, dump load (DL), which is comprised of a set of three-phase resistors connected in series, is used in order to be activated to absorb that excess power. Moreover, if a portion of load is supplied by RESs, the SMI index takes a value between 0 and 1. In this case, the system frequency remains within its nominal values, but its variation differs in various points of SMI. For example, as it can be observed from Figure 1, the frequency at points \(P_{2}\) and \(P_{3}\) has different variations but is still in the accepted range. Furthermore, when SMI value is less than zero (i.e., point \(P_{4}\) in the system frequency drops, thus it is required to inject power to the network (for example, by discharging of EVs)). In the next step, SMI is applied to obtain electricity buying and selling prices for EVs' energy management.  
The cost signal should follow the SMI index in such a way to encourage EV owners to charge or discharge their vehicles for keeping the power balance of the system and improving the frequency. Thus, cost signal should track the SMI trend with considering the range of electricity buying price (EBP) and electricity selling price (ESP) obtained from electricity market. On the other hand, the maximum (minimum) value of electricity price represents the highest (lowest) value of SMI. Other prices are fitted between these two limitations based on the values of SMI with the application of numerical analysis.  
Figure 1: A typical stability margin index (SMI).