## 2 EV Power Controlling (EVPC) Scheme
### EVPC Structure  
In calculating the payments to (by from) the MG operator when EVs are charged (discharged), EBP (ESP) value is introduced to reflect both the wholesale electricity prices and domestic tariffs [20]. Generally, once an EV is connected to the MG, it will be charged and thus has to pay for the consumed energy based on the EBP. However, when it discharges, it receives payments based on the ESP for providing the service. The high level of ESP is considered as a high electricity selling price (HESP), and, here, it is set at 85% of the maximal ESP. Moreover, the high level of EBP is considered as high electricity buying price (HEBP), and it is set at 60% of the maximal EBP. In the islanding operation mode of MG, the major goal is to keep the system power balance and, consequently, to limit frequency variations within the allowed range. Considering the same objective, this paper presents an EVPC scheme as an energy management strategy in order to manage the participation of EVs in charging/discharging process with considering the intermittent behavior of renewable resources. Figure 2 shows the algorithm of an EVPC scheme for optimal scheduling of the MG, and it includes three stages. In the first stage, the difference between day-ahead load and the forecasted power of renewable resources would be calculated to obtain stability margin index and the electricity cost signal that are utilized for managing the power of EVs. This stage includes the following parts:  
* Forecasted load and output powers of RESs (wind and solar); it is assumed that the day-ahead load demand and renewable generations are determined.
* Index calculation part; in this block, SMI is calculated using Labels (1) and (2).
* Price calculation part; the electricity prices are obtained based on SMI index.  
Figure 2: Algorithm of the electric vehicle power controller (EVPC) scheme for optimal scheduling of the microgrid (MG).  
In the second stage, an optimal scheduling of the generating units is done to match the demand for the scheduling horizon properly through a unit commitment algorithm and optimal power flow procedure by considering system's objectives and constraints (technical and security).  
In the third stage, the MG emergency operation is determined and the frequency behavior is evaluated. Since, the MG is operating in islanded mode, the power unbalance (\(P_{t}^{dist}\)) will result from the changes in loads or generation. The emergency active power of unit \(i\) at the certain time \(t\) (\(dP_{i,t}\)), is defined as:  
\[\left\{\begin{array}{ll}dP_{i,t}=P_{t}^{dist}\cdot\frac{R_{i,t}}{R_{t}}\\ \sum\limits_{i=1}^{N_{G}}dP_{i,t}=P_{t}^{dist}\end{array}\right.\forall t, \tag{3}\]  
where \(R_{i,t}\) is the reserve capacity of unit \(i\) at time period \(t\), and \(R_{t}\) is the total available generation reserve at time period \(t\).  
The demand load, EV power and the generation emergency dispatch are applied as inputs to the MG dynamic model, in order to evaluate the energy balance within the MG for a given period and the expected frequency deviation in the event of a disturbance. Based on the dynamic model results, if the MG does not have enough reserve capacity, it is necessary to exploit emergency load curtailment (LC). Moreover, DL is applied when RESs' generated power is high and a portion of it is not consumed.