*1.1. Motivation*

The rapid increase in energy demand, destruction of the earth's resources, and discharge of carbon dioxide are the leading causes of environmental pollution and climate change in the world. Further, transportation is more attentive, considering the fact that it causes more than 15% of carbon dioxide discharge, which is critical for all the people [1,2]. As a result of that, the transition from the Internal Combustion Engine (ICE) to hybrid and full-electric vehicles has been an immense focus for the reduction of greenhouse gases [2]. Due to pollution and energy crisis, many studies in the field of Electric-Drive Vehicles (EDVs), including Battery Electric Vehicles (BEVs), Hybrid Electric Vehicles (HEVs), and Plug-in Hybrid Electric Vehicles (PHEVs) have appeared worldwide [2–4]. However, developments in the field of electric vehicles are restricted by the technology of the batteries and Energy Storage Systems (ESSs), there are many positive signs of progress in this field [5–7]. A good number of alternative energy sources, which are renewable, are already being harnessed and utilized to meet the energy demand in the world [8,9]. This paper mainly focuses on PHEVs to study the impact of EVs and their interconnection to the power system.

The arbitrary connection of PHEVs to the power grid leads to the complicated operation, planning, and control of the power system. There are different charging mechanisms for PHEVs to be charged. IEC Std. 61851 is one of the common standards, which is established for PHEVs charging [8]. Regardless

of the charging mechanism, the availability of charging stations is an essential factor that should be considered for power system control, operation, and long-term planning. The common and low-cost procedure for charging PHEVs is slow charging, which drains less power from the grid. However, the main drawback of this mechanism is that it takes more time to fully charge the batteries of PHEVs. On the other hand, the fast charging mechanism, based on the new developments in power electronics devices and restructuring both of both ESSs and chargers, can expedite the charging process and charge a depleted battery from 10 to 80 percent in half an hour [10]. However, this mechanism drains more current at a high voltage level from the network and has a negative e ffect on the other loads connected to the same bus, e.g., the voltage drop at the end of the power line.

In modern power systems, microgrids are defined as interconnected local energy centers with control and managemen<sup>t</sup> capabilities and clear boundaries. They enable bidirectional and autonomous power exchange to prevent power outage by providing high-quality operation and more reliable energy supply to the load centers. Aging electric power grid infrastructures, continuous increase in the load demand, integration of renewable energy resources and electric vehicles, transmission power losses, and improving the e fficiency of the power system, are several challenges in modern power systems. Therefore, to overcome the mentioned challenges, macro and micro-grids are utilized to both enhance the power quality and increase the reliability of the grid side and the load side. There are several studies in the field of microgrids, considering their di fferent manifestations, such as Smart Grids (SGs) and Virtual Power Plants (VPPs), etc. [11]. One of the main concerns in modern power system analysis is the dependency on the power from microgrids by using the grid power along with their developments. As a result, microgrids can interconnect to the power grid and improve the power quality and reliability. From another perspective, microgrids can connect to/disconnect from power grids to enable themselves and operate in both grid-connected and islanding modes.

Based on the expansion of the interconnected power grids through the long transmission lines, increasing the load demand, and the need for a supervisory control system for the power generation units, electric utilities are moving toward the decentralized and deregulated power systems, focusing on independent microgrids. Non-traditional power generation sources (e.g., wind farms, solar power plants, diesel generators, etc.) in microgrids are allowed to trade electricity with the local consumers. In addition, microgrids in a centralized structure no longer rely on a single power source. On-site generations can be utilized as emergency backups in the event of blackout or load shedding to mitigate disturbances and increase power system reliability. Figure 1 illustrates the concept of modern microgrids. As shown, there are several ways to utilize Distributed Generations (DGs), such as wind, solar, ESSs, etc. in the power system to support the grid and supply the load demand.

**Figure 1.** The concept of modern microgrids.

#### *1.2. Literature Survey and Contributions*

Technically, modern microgrids are a small part of low voltage distribution networks that are located far from the substation and interconnected through a Point of Common Coupling (PCC) [12]. Based on the nature of microgrids operation (e.g., ownership, location, reliability requirements, and trading purposes), significant developments are carried out by researchers, industrial and commercial factories, and military bases. According to the Power and Utilities Navigant Research, the capacity of the global microgrid has been projected to grow from 1.4 GW in 2015 to 7.6 GW in 2024 under a base scenario [12]. Modern microgrids not only offer grea<sup>t</sup> promises owing to their significant benefits but also result in tremendous technical challenges. There is an urgen<sup>t</sup> need to investigate the state-of-art control and energy managemen<sup>t</sup> systems in microgrids.

One of the main challenges in microgrids technology is to manage and balance the generation and consumption of energy [13]. The power imbalance is a typical scenario in microgrids, which comes from the nature and availability of renewable energy resources to discontinuously generate power and available loads connected to microgrids. The control system should manage these imbalances to prevent electrical damage and maintain AC/DC grids stable [14–17]. As a result, recent studies have focused on proper power managemen<sup>t</sup> and control strategies to manage the generation and consumption of energy. These control strategies are mainly targeted at: (i) controlling the interconnected DGs and ESSs, (ii) DC bus voltage regulation, (iii) minimizing the cost of imported/exported energy from/to the main grid by optimizing the power dispatch between converters and DC bus voltage, (iv) management, and optimization of ESSs operation, and (v) current sharing managemen<sup>t</sup> between parallel converters in DC grids [17–20].

In order to optimize the power dispatch, proper communication infrastructure between the microgrids and the grid operator are required [21,22]. However, real-time simulation and monitoring can be implemented by the communication infrastructure, the outage of the communication links/signals can cause many complicated problems. The droop control method is a well-known strategy to maintain the power balance in DC microgrids [17,22–26], which does not require communication infrastructure [17]. The power managemen<sup>t</sup> of microgrids can be classified into centralized, decentralized, and distributed control categories [25–29]. The energy dispatched in the centralized control systems can be monitored and managed by an intelligent centralized (master) controller, which receives and analyzes the data, manages the power among the converter stations under operation, and forecasts the power and voltage references to all the power devices of the microgrids. [30,31]. These systems usually offer precise power-sharing among converters in microgrids [28,29]. In case of loss or outage of the master controller, local autonomous controllers (decentralized structure) are needed to fulfill the master controller failure [32–35]. In a distributed control system, each microgrid is allowed to only communicate with its nearby neighbors. Therefore, there is still a need for communication infrastructure. Further, there are many loops in a distributed control system, which make its design more complicated [36].

However, installing new components and/or upgrading the existing components are two methods to overcome the negative impacts of PHEVs in power grids, high investment costs prevent the mentioned solutions to be implemented. If the high penetration level of PHEVs is connected to the system, up to a 15% increase in the cost of upgrading the existing grid to guarantee the adequacy of the power system can be expected [37]. Therefore, more investigations are required to find a suitable and cost-effective solution. Utilizing proper ESSs and appropriate charging/discharging mechanism to control the power flow in PHEVs are preferable to installing new components and/or upgrading the existing infrastructures in power grids. High penetration chargers can be designed and implemented to allow bidirectional power flow between ESSs and power grids.

PHEVs can assist in improving the load-leveling profile and reducing power losses [38]. Further, utilizing efficient Voltage-Source Converters (VSCs) in power system allows transferring reactive power, as well as active power into the power grid. The DC-link capacitor and a proper switching mechanism can improve the quality of the transferred power into the grid [39]. Therefore, several

studies have investigated different control strategies to implement the concept of a bidirectional charger and solve the charging issues of PHEVs [40–43].

A practical power electronics grid interface that can provide the Vehicle-to-Grid (V2G) bidirectional power flow with a high power quality is necessary to perform the grid-connected vehicle battery application. This interface should respond to the charge/discharge commands that are received from the monitoring system to enhance the reliability of the power grid. Moreover, essential requirements, such as reactive power injection and tracking the reference charge/discharge power, should be met [44,45]. A comprehensive review of the bidirectional converters is presented in [46], and discusses their advantages and disadvantages. In [47], the energy efficiency in PHEV charges along with the evaluation and comparison of the AC/DC topologies, such as the conventional Power Factor Correction (PFC) boost converter, including a diode-bridge rectifier followed by a boost converter, an interleaved PFC boost inverter, a bridgeless PFC boost converter, a phase-shifted semi bridges PFC boost converter [48], and a bridgeless interleaved boost converter [49] is presented. In addition, some non-inverted topologies are presented in [50–60], some of which require two or more switches to be operated in Pulse Width Modulation (PWM) mode, which causes higher total switching losses [50–52,54–61]. However, bidirectional power flow cannot be achieved in the topologies of [50,54,57,61–64].

Different DC charging station architectures for PHEVs are proposed in [65–67]. For instance, the control of the individual EV charging processes introduced in [65] is decentralized, while a separate central supervisory system controls the power transfer from the power grid to the DC link. With sufficient energy stored in the battery of PHEVs, the bidirectional charging/discharging power control of PHEVs can be applied to reduce the frequency fluctuation [68–74]. A power charging control system to control the frequency in the interconnected power system with wind farms is considered in [68]. The controller in [68] is capable of stabilizing the system frequency during the charging period. Further, the bidirectional power control of PHEV applied for frequency control in the interconnected power systems with wind farms is proposed in [69]. The proportional-based PHEV power controller in [69] provides satisfactorily control, but its performance may not tolerate such uncertainties, and it may fail to handle the system frequency fluctuation.

Further, the system parameters may not remain constant and continuously change when operating conditions vary [75]. The system parameter variations, such as the inertia constant and damping ratio, are conventionally considered to check the performance and robustness in the Load Frequency Control (LFC) approach [76]. Hence, the robustness of the controller against system uncertainties is a vital factor that must be considered.

This paper presents a precise bidirectional charging control strategy of PHEVs in power grids to simultaneously regulate the voltage and frequency, as well as reducing the peak load, and improving the power quality by considering the SoC and available active power in power grids. Different events that may occur during a 24-h scenario in the studied DG-based system consisting of different microgrids, diesel generator and wind farm, PHEVs with several charging profiles, and different loads are considered. The simulation and analysis are performed in MATLAB/SIMULINK software.

#### **2. Principles of Bidirectional Power Flow**

Figure 2 shows a basic model of a power system consisting of two generators and a transmission line which is connected to two generation buses. In this figure, each bus has its voltage magnitude and phase angle, where *V*1∠θ1 and *V*2∠θ2 are the corresponding voltage magnitude and phase angle of buses 1 and 2, respectively. The impedance of the transmission line is *Z*∠γ, where:

$$Z = R + jX \tag{1}$$

and

$$\gamma = \tan^{-1} \frac{X}{R} \tag{2}$$

Therefore, by considering voltage magnitude and phase angle di fferences between buses, the active power, *P*, and reactive power, *Q*, can be transferred, bidirectionally. In order to study the bidirectional power flow, it should be assumed that both buses are capable of supplying and absorbing active and reactive power.

**Figure 2.** Single diagram of a two-bus system.

Based on the direction of power flow, the active and reactive power equations can be written as:

$$P\_{12} = \frac{|V\_1^2|}{|Z|}\cos\chi - \frac{|V\_1||V\_2|}{|Z|}\cos(\chi + \theta\_1 - \theta\_2) \tag{3}$$

$$Q\_{12} = \frac{|V\_1^2|}{|Z|}\sin\chi - \frac{|V\_1||V\_2|}{|Z|}\sin(\chi + \theta\_1 - \theta\_2) \tag{4}$$

Assuming *X R*, Equations (3) and (4) can be re-written as:

$$P\_{12} = \frac{|V\_1||V\_2|}{X} \sin(\theta\_1 - \theta\_2) \tag{5}$$

$$Q\_{12} = \frac{|V\_1|}{X} [|V\_1| - |V\_2| \cos(\theta\_1 - \theta\_2)] \tag{6}$$

Small changes in the voltage magnitude have a direct impact on the reactive power flow, while deviations in phase angle can change the active power flow in power grids. If θ1 > θ2, the active power can be transferred from bus 1 to bus 2 and vice versa. Further, if *V*1 > *V*2, the reactive power can be transferred from bus 1 to bus 2 and vice versa. Therefore, the voltage magnitude and phase angle play the important roles in power transfer in power grids.

#### **3. Control Strategy and Power System Modeling**

#### *3.1. Bidirectional Charging Station*

PHEV chargers should be installed o ff-board and onboard in a vehicle. Onboard chargers are built with a small size, low power rating, and can be used based on a slow charging mechanism. O ff-board PHEV chargers are located at specific places and provide either a slow or fast charging mechanism. As a result, charging networks play an important role to support PHEVs. In addition, there are two common architectures (series and parallel) in the PHEV drivetrain. Moreover, a combination of these two (series-parallel architecture) is also used in some vehicles [1,5–8,77]. This paper has considered a generic aggregation of PHEVs with di fferent charging profiles. The number of vehicles in charge, the rated power and rated capacity, and the power converter e fficiency are the important factors in this model. This model is also capable of enabling vehicles to the grid, instantly. Table 1 shows the charging station specifications.


**Table 1.** Charging station specifications.

The fundamental configuration of the charging station consists of a centralized AC/DC converter and di fferent DC/DC converters as the charging lots. The AC/DC converter rectifies the three-phase AC input signal into a DC output signal. DC/DC converters have been used to regulate and shift the output signal to the desired level. A bidirectional charging station is capable of controlling the power flow in both directions between charging stations and power grids.

Figure 3 illustrates the single-line diagram of the case study in this paper [78]. Further, the proposed scheme of the grid-connected PHEV system is illustrated in this figure. The proposed model has a central AC/DC VSC station and di fferent controllable DC/DC converters based on a certain number of PHEVs. All DC/DC converters are in a parallel architecture and are connected to a common DC bus, which has been regulated by the central AC/DC VSC station. Two di fferent conditions have been assumed for the charging stations: (1) cars in regulation, which contribute to the grid regulation; and (2) cars in charge, which are regularly in the charging process. Therefore, there are two modes of operation for each PHEV: (1) regulation mode; and (2) charging mode.

In order to minimize the output harmonics during the operation and switching processes of converters, an RL filter has been considered between the charging station and power grid. The charging system in this paper allows transferring the active and reactive power bidirectionally with the help of a control system. The control strategy mainly focuses on the AC/DC and DC/DC converters. By proper controlling the central AC/DC VSC station, injecting reactive power into the power grid to regulate the voltage, improving the power factor, and maintaining a constant DC-bus voltage, can be achieved. Moreover, an appropriate control mechanism for the DC/DC converters can ensure controlling the charging and discharging processes of PHEVs. This paper has considered both charging and discharging operations, where the DC/DC converters are controlled by charge/discharge PHEV batteries.

**Figure 3.** Single line scheme of the modified microgrid system (case study).

#### *3.2. Converter Station Control Systems*

As stated in Section 3.1, the converter station can work in two modes: (1) the regulation mode, and (2) the charge mode, and is capable of compensating reactive power, and consequently, regulating the voltage of the power grid during the charging and discharging processes of PHEVs. This section provides details of the control systems of the converter station in different modes.

#### 3.2.1. Grid Regulation Mode

In order to contribute to the grid regulation, two controllers have been designed: (1) a grid regulation controller, and (2) a grid regulation power generation. Figure 4 shows the grid regulation controller scheme. This controller is fed by the maximum regulated active power, *Pmax*\_*reg*.

**Figure 4.** Grid regulation controller scheme.

To achieve the maximum active power regulation, a control system that consistently checks the nominal active power, *Pnom*, is proposed, as shown in Figure 5. In this controller, the nominal active power, the number of cars in regulation, *N*, and an online key to enable the V2G mode are matter. Lastly, the output power has been limited within the standard range to be considered as the maximum regulated active power. There is a threshold (0.5) for passing the first input to the second input, *C1*, of this controller.

**Figure 5.** Outer control system scheme for gaining maximum regulated active power.

In order to contribute to the grid regulation, real-time measurement of the frequency, <sup>ω</sup>grid, is required. By comparing <sup>ω</sup>grid and the reference frequency, ωref, the frequency deviation can be obtained. The frequency deviation should be less than 0.05%. Otherwise, the controller stops the process. To prevent sudden changes in the frequency deviation, the controller's derivative has been utilized. By considering that the frequency deviation is within the standard range, two gains for the grid regulation controller have been set by the operator, the open-loop gain, *K*1, and the loop gain, *K*2. Changing these two gains has a direct impact on the SoC of all the cars in the charge mode. A zero-crossing detection integrator has been considered to minimize the disturbance and steady-state error of the input signal. The output signal of the integrator has been rechecked to avoid the maximum allowable regulated active power that is fed into the grid regulation power generation system. Figure 6 illustrates a detailed diagram of the grid regulation controller.

Furthermore, by controlling the voltage, and consequently, the current through another control system, the proposed control strategy can ensure a contribution to the grid regulation power generation, as shown in Figure 7.

**Figure 6.** Control diagram of the grid regulation controller.

The grid regulation power generation controller captures the voltage of pair phases. Therefore:

$$V = \frac{1}{3}(V\_{ab} - a^2 V\_{bc})\tag{7}$$

where *Vab* is the voltage between phases *a* and *b*, and *Vbc* is the voltage between phases *b* and *c*.

Moreover:

$$a^2 = e^{-j\frac{2\pi}{3}}\tag{8}$$

By using Equation (7) and decomposing the real and imaginary parts from the apparent power, *S*, the current can be derived as follows:

$$I = \frac{2}{3} \frac{S^\*}{V^\*} \tag{9}$$

where *V* and *I* denote the voltage and current, respectively. *S*∗ and *V*∗ represent the complex conjugate of the apparent power and the complex conjugate of the voltage, respectively. Accordingly, the controller feeds constant current into the power grid and regulates the voltage and frequency, simultaneously.

**Figure 7.** Control diagram of the grid regulation power generation.

## 3.2.2. Charge Mode

In order to control the PHEV station in charge mode, two states have been studied: (1) SoC, and (2) plug. The charge power generation controller requires the nominal active power and the number of cars in charge, *M*, as its inputs. Same as the grid regulation mode, a threshold (0.5) is used for passing the first input to the second input, *C*4, of the charge power generation control system. The threshold can guarantee safe operation. Figure 8 shows the outer control diagram of the charge power generation controller.

**Figure 8.** The outer control diagram of the charge power generation controller.

Same as the previous section, by regulating the voltage, and decomposing the real and imaginary parts of the apparent power of the charging system, a constant current, *Ireg*, is obtained from the controller, and fed into the power grid. Figure 9 illustrates the inner control diagram of the charge power generation controller.

**Figure 9.** The inner control diagram of the charge power generation controller.

Each group of cars has a certain charging profile. As mentioned, the car profile has been investigated by checking the SoC and plug states. Figure 10 demonstrates the control diagram of the profile of each PHEV in charge and regulation modes. In this control design, the SoC initialization and plug state have been implemented by using the Binary Search Method (BSM). Therefore, the SoC initialization and plug state have stochastic, but linear behavior. Complementary descriptions for the different profiles are provided in Section 3.7.

**Figure 10.** The control diagram of the profile of each PHEV in charge and regulation modes.

In order to control the output changes of the SoC initialization and plug state within limits, two state limiters have been considered. By capturing the SoC initialization and plug state, and the present values of the SoC in different profiles, the state estimator for each SoC controller has been designed. Figure 11 indicates the SoC controller, where the output of this controller is the State Estimator (*SE*%), and regulated for the charger controller. The SoC controller needs accurate information of the active power of the cars in charge, *Pcharge*, the number of cars in charge mode, *M*, the number of cars in the specific charging profile, *Li* (where *i* = 1, ... , 5), the number of cars in regulation mode, *N*, the active power of the cars in EV mode, *PEV*, and the regulated output of the SoC initialization and plug state.

**Figure 11.** The control diagram of the SoC controller.

The state estimation of batteries in PHEVs requires checking the mode of vehicles. The PHEV can be either in charge or EV mode. Therefore, there should be a switch to toggle between these two modes. By reaching the maximum level of the charge, the controller terminates the charging process. In the meantime, the controller checks the plug state dynamically, and if the PHEV is unplugged from the grid, it sends zero signal, *C*6, as shown in Figure 11, and terminates the charging process.

Assuming the PHEV is in charge mode, the charge/discharge e fficiency has been taken into consideration. These two are modeled as two direct gains, *K*14 and *K*15, so that:

$$\begin{cases} \ K\_{14} = \eta \\ \ K\_{15} = 1/\eta \end{cases} \tag{10}$$

where η shows the e fficiency.

The SoC, which is converted to real-time by multiplying the present capacity by 1000 × 3600, the plug state, and the charging state are sent to an integrator with the initial condition and dynamic saturation, and lastly, the output is multiplied by the number of cars in a particular profile to obtain the state estimation. State estimation from this stage is used as the SoC of the vehicles. Deriving the state estimation, the cars are checked whether they are either in the charge mode or regulation mode through the charger controller. Figure 12 indicates the charger control diagram. In order to guarantee a high-e fficiency output during the charging process, the state estimation has been set within the range of 85% and 95%. Otherwise, the charger terminates the process. In fact, this can ensure both injecting power with high quality to the power grid during the regulation mode and charging the batteries during the charging mode.

**Figure 12.** Control diagram of the charger.

Proper operation of the charging station of PHEVs lead to the energy balance of ESSs in PHEVs subject to the maximum and minimum operating limitations in charging and discharging power as follows:

$$E\_{s,i,(t+1)} = E\_{s,i,t} + \eta\_{s,i,c} \times P\_{s,i,t,c} - \frac{P\_{s,i,t,disc}}{\eta\_{s,i,d,isc}} \tag{11}$$

subject to:

$$0 \le P\_{s,i,t,c} \le k\_{s,i,t,c} \times P\_{s,i,c\\_max} \tag{12}$$

$$0 \le P\_{s,i,t,\text{disc}} \le k\_{s,i,t,\text{disc}} \times P\_{s,i,\text{disc\\_max}} \tag{13}$$

$$k\_{s,i,t,c} + k\_{s,i,t,disc} \le 1\tag{14}$$

$$k\_{s,i,t,c} + k\_{s,i,t,d\text{disc}} \in \{0, 1\} \tag{15}$$

$$E\_{s,i,min} \le E\_{s,t} \le E\_{s,i,max} \tag{16}$$

where indices *s*, *i*, and *t* refer to the *s*th energy storage system at the *i*th bus in the *t*th time interval. Therefore, *Es*,*i*,*<sup>t</sup>* is the energy storage of the *s*th energy storage system at the *i*th bus in the *t*th time interval in MWh. η*<sup>s</sup>*,*i*,*<sup>c</sup>* and η*<sup>s</sup>*,*i*,*disc* are charging and discharging e fficiencies, respectively. *Ps*,*i*,*t*,*<sup>c</sup>* and *Ps*,*i*,*t*,*disc* are charge and discharge power, and *ks*,*i*,*t*,*<sup>c</sup>* and *ks*,*i*,*t*,*disc* are the binary variables for charging and discharging operations of the *s*th energy storage system at the *i*th bus in the *t*th time interval, respectively.

Figure 13 shows the flow chart of the proposed bidirectional power charging strategy. According to the collected data from the installed meters, the amount of the active and reactive power in the system is checked. When V2G is not activated, the existing microgrid(s) satisfy the total load consumption, whether there is a contingency in the system or not. When V2G is activated, the SoC initialization and plug state of PHEVs are checked and based on them, the SoC can be estimated. According to the estimated SoC, PHEVs mode can be either in charge or regulations mode. By considering that there is no contingency in the system, the required power to charge PHEVs is supplied by the existing microgrid(s). Otherwise, all PHEVs in charge and regulation modes are passed through a regulation unit, and the regulated voltage and frequency are then used to update the active and reactive power.

**Figure 13.** Flow chart of the proposed bidirectional power charging strategy.

## *3.3. Diesel Generator*

A three-phase synchronous machine in the *dq*-rotor reference frame with the engine governor and excitation system has been modeled and considered as the diesel generator to feed 15 MW active power to the power grid. The nominal power, line-to-line voltage, and frequency of the generator are 15 MW, 25 kV, and 60 Hz, respectively. The IEEE type 1 synchronous generator voltage regulator combined with an exciter has been implemented as the excitation system. Moreover, the diesel governor has been modeled, where the desired and actual rotor speeds are the inputs and the mechanical power of the diesel engine is the output. Further, the motor inertia has been combined with the generator. The design considerations for the governor are made through the regulation of the controller and actuator as follows:

$$H\_{\rm f} = \frac{K(1 + T\_{\rm 3}s)}{(1 + T\_{\rm 1}s + T\_{\rm 1}T\_{\rm 2}s)} \tag{17}$$

where *Hc* is the controller transfer function, *K* is the regulator gain, and *T*1, *T*2, and *T*3 are the regulator time constants, respectively.

Furthermore:

$$H\_a = \frac{(1 + T\_4 s)}{s((1 + T\_5 s)(1 + T\_6 s))}\tag{18}$$

where *Ha* is the actuator transfer function, and *T*4, *T*5, and *T*6 are the regulator time constants, respectively. The engine time delay, *Td*, has been set to 0.024 sec. It should be noted that ω*re f* and *Vre f* of the diesel engine governor and excitation system have been set to 1 p.u.

Accordingly:

$$T\_m - T\_\varepsilon - D\Delta\omega = J \frac{d\omega}{dt} \tag{19}$$

where *Tm* = *Pm*ω*m* , *Te* = *Pe* ω*e* , and Δω = ω − ω*rated*. *Tm*, *Te*, ω*m*, and ω*e* are the mechanical torque of the synchronous generator rotor shaft input from the prime mover, stator electromagnetic torque, mechanical speed of the rotor, and synchronous speed, respectively. *D* indicates the damping coefficient, ω and ω*rated* are the actual electrical and rated angular velocities, respectively. *Pm* and *Pe* are the mechanical and electromagnetic power, respectively. *J* shows the rotational inertia, and θ indicates the electrical angle.

In addition:

$$E\_0 = V\_s - I(r\_a - j\mathbf{x}\_s) \tag{20}$$

where *E*0, *Vs*, and *I* are the three-phase stator winding electromotive force, the stator voltage and current, respectively. Moreover, *ra* and *xs* indicate the armature resistance and stator reactance, respectively.

## *3.4. Wind Farm*

As the second source of energy, a wind farm with 4.5 MW nominal power capacity, with 13.5 m/s as the nominal wind speed, and 15 m/s as the maximum wind speed, is studied in this paper. The wind speed fluctuations provide a situation to study the power grid under a stochastic condition (uncertainty). The generated power by the wind farm can be obtained as follows:

$$P\_{\rm wind} = \begin{cases} 0 & 0 \le \upsilon\_i < \upsilon\_{\rm cut-in} \\ \frac{\upsilon\_i - \upsilon\_{\rm cut-in}}{\upsilon\_r - \upsilon\_{\rm cut-in}} \times P\_r & \upsilon\_{\rm cut-in} \le \upsilon\_i < \upsilon\_r \\ P\_r & \upsilon\_r \le \upsilon\_i < \upsilon\_{\rm cut-out} \\ 0 & \upsilon\_r \ge \upsilon\_{\rm cut-out} \end{cases} \tag{21}$$

where *Pwind* is the active power generated by the wind farm, *Pr* shows the rated power of the wind farm, *vi* indicates the wind speed, and *vcut*−*in*, *vr*, and *vcut*−*out* are the cut-in, rated, and cut-out speeds of the wind turbine, respectively. The output power of the wind farm has been treated as a negative load so that the power factor can be kept at a constant level.
