A SIMULINK implementation of a vector shift relay with distributed synchronous generator for engineering classes

In recent years, the concerns regarding global warming have encouraged an increase in research on renewable energy and distributed generation. Different renewable resources are currently being used, and bioenergy is one among them. Biogas can be produced via digesters, and its energy is converted into electricity and injected into the electrical power system for supplying to meet the local or distant demands. Nevertheless, the generation of electricity via biogas on the consumer side brings new problems and challenges to the power system controller. Protection devices, such as a vector shift relay, are one of the most important components needed to connect a bioenergy system using synchronous generators into the mains. Although distributed synchronous generators are widely used and simulated in software tools, especially in MATLAB/SIMULINK, there is still a gap in technical literature detailing how to design or model a Vector Shift Relay. In view of this subject’s importance, this article aims to assist students, researchers, and engineers by proposing a step-by-step method on how to model and implement a vector shift relay in MATLAB/SIMULINK, although the methodology may easily be used in other simulation tools. A review of the topic is presented along with a detailed description of all needed blocks and expected results.


Introduction
Economic growth has a straightforward relationship to the necessity of energy expansion. A higher percentage of renewable energy (RE) sources has been encouraged by worries about global warming [1]. Every day, the importance of the research about RE resources as well as the importance of addressing this issue as electrical engineering discipline is growing [2]. To meet this requirement, the students and researchers need to be prepared to find, understand, and solve new problems on this subject. The engineers need to be able to solve problems about the use of the devices to convert the RE into electrical energy and share with the electrical power system [3]. This sharing is done with the use of generators connected to the consumer facilities, known as distributed generation (DG) [4]. There is a current demand of graduate specialization courses on DG, and universities should address this gap.
Lectures of DG courses, either in undergrad or graduate classes, can be performed with the support of hardware-based or software-based experiments. Hardwarebased experiments are restricted due to concerns of security and cost. For the hardware-based laboratories, some difficulties can be listed as follows: for security concerns, the students are requested to perform specific tests following step-by-step procedures and are not being allowed to try different proposals; there is the necessity of space availability for the equipment that usually constrains the use of the equipment for a couple of students; and for the hardware experimental implementation the system is greatly simplified [5]. On the other hand, with the use of software programs, the students can perform the simulation of any scenario without risk of damage. The students can be induced to perform any "what-if" type of test and to learn by their own experiences [6]. Among the software programs used in research about electrical power systems, the utilization of MATLAB/SIMULINK is swiftly growing [7]. Classes and methodologies that defy and motivate students to apply their multidisciplinary knowledge into solving real problems are becoming more important, especially using computer simulation [3]. To capture the interest of the students, real problems tend to be more attractive. So, related to the worries about RE, which scenario could be proposed? What kind of troubles can be handled by the students?
Regarding RE, the energy produced with biogas obtained by the anaerobic digestion is becoming more attractive [1]. The biogas is converted to electricity using a gas engine as primary machine coupled to a synchronous or asynchronous generator [8,9]. Despite the benefits of the DGs, their use has some associated risks. When a DG is installed in a consumer facility, due to some failure in the transmission line, there is a risk of a fraction of this line losing the connection with the main grid. In this case, the local load could be fed by the DG, and this is known as an unintentional islanding event [10]. The unintentional islanding operation can bring many troubles with respect to the quality of the energy issues and also puts the staff, working in the distribution line, at risk [11]. The detection of an unintentional islanding event is known as anti-islanding protection [12]. In Brazil, one of the biggest companies that works with the electrical distribution is the Companhia Paranaense de Energia, COPEL. This company follows the standard NTC 9,05,200 [13] to guide the DGs to connect parallel to the grid. In its October 2018 revision, it is defined that the DG should use an anti-islanding method, suggesting the use of vector shift relay, or, also known as vector shift relays or vector surge relays (ANSI 78V). So, unintentional islanding detection is a quite important issue for the feasibility of the use of synchronous machines with biogas engines. Besides that, the studies related to islanding detection supply to the students of electrical engineering a good view of some issues related to the DGs as follows: worries about safety of the maintenance staff; worries about voltage and frequency stability; and a possibility to exercise the knowledge about control and protection of power systems.
Even though MATLAB/SIMULINK is being used as a powerful tool for the power system analysis, in its libraries there is non pre-built block with a vector shift relay. In a research with the key words most used in articles about anti-islanding detection the following ("islanding" and "vector shift," "islanding" and "vector surge," "islanding" and "vector jump," "loss of mains" and "vector shift," "loss of mains" and "vector surge," "loss of mains" and "vector jump") were found as listed in Table 1.
Current literature regarding the use of vector shift relays, given in Table 1, does not go into the details of    how to implement it from scratch when using a software that does not contain this type of protection device in its default library, nor how to design it when applied to a synchronous generator. Simulation software is a powerful tool to help students, engineers, and researchers study these systems, and it is used to overcome the difficulties of safety, cost, and space that exist in implementing DG experiments. Thus, this article, giving complete step-bystep modeling of a vector shift relay applied in distributed bioenergy systems, is proposed and demonstrated in MATLAB/SIMULINK. The organization of this article is done as follows: in Section 2 is first done a review about the standards related to the islanding detection, so that this information guides in choosing the components to the proposed diagram as well as their settings. After this, a second subsection is used to do a review about the vector shift relay working principle and to explain its implementation in MATLAB/SIMULINK. Later, each subsection is used to describe in detail each of the others blocks necessary to the simulation. Within each subsection, some suggestions of problems and possible research to be performed with the students are presented. Conclusion is given in Section 3.

Performing the simulation
In the simulation of a vector shift relay, the excitation system and the speed governor have a key function on the circuit and can significantly affect the obtained results. Thus, dedicated subsections are written for them. For a clear understanding, this section is divided into seven subsections. Each of them brings the most relevant information for better understanding and addresses some possible discussions to be carried on with the students in the classes.

Standards related to islanding detection
A well-established regulatory framework is needed in order to make the DG systems feasible and attractive to the investors [14]. One of the most important standards for handling this issue is the IEEE 1547-2018 standard. To guarantee the safety of workers who operate the energy distribution grid, the IEEE 1547-2018 standard states that, as soon as a loss of DG connection with the interconnected power system occurs, the DG must be able to detect this loss and automatically disconnect the generator from the system in less than 2 s [15]. The IEEE 1547.6, in the chapter "7.1.2 DR Electric power generation technologies," classifies generator units into three types: induction generators, synchronous generators, and inverters [16]. Among these, the most concerning are the synchronous generators because they have frequency and voltage controllers that allow these generators to continue operating with nominal voltage and frequency values of the local grid, even after loss of connection with the system. Furthermore, the IEEE 1547.1 standard defines test procedures to be performed with anti-islanding protection devices to ensure safe operation [17]. In some countries, as an example of Brazil, the distribution companies make their standards to guide the requirements to connect the DGs. One of the biggest distribution energy companies in Brazil, called Companhia Paranaense de Energia, COPEL, has the standard NTC 905200 [13] to guide the DGs to connect parallel to the grid at the low voltage. In the revision of October 2018, it is defined that the DG should use an anti-islanding method, suggesting the use of vector shift relay (ANSI 78V), but, it is not informed of the setting value to this protection device. The designer responsible for the project, who connects the DG on the grid, has to define the values to be set on the protection relays. It implies a huge responsibility on the designers. How could the designer know the correct settings for this device? Would it be possible for the students to develop a procedure to help the engineers to quickly access these settings for the vector shift relays?

Working principle of vector shift relays
Islanding detection can be performed quickly using vector shift relays [18]. The vector shift relays available in the market measure the voltage of each phase and compute the duration of each cycle of the grid. Then, the duration of the last period is compared with the duration of the previous period. An increase or decrease in the duration of the period would be identified as a vector shift causing the relay to act. Thus, the typical settings for this protection ranges from 2°to 20° [19].
The basic principle of operation of a vector shift relay can be explained with the help of Figure 1 [19]. In this diagram, Ē I represents the internal voltage of the synchronous machine, V Δ̄represents the voltage drop in the reactance of the synchronous machine X d as a function of the current Ī s , VT represents the voltage at the coupling point between the generator and the grid, known as the point of common coupling (PCC), and Ī Gr represents the current flowing from the grid. CB is the switch that will be used to disconnect the grid, thus allowing the generator to supply the islanded load. VS Relay represents the switch that must be connected to the generator output to disconnect it when the anti-island circuit detects loss of connection to the grid.
In ref. [19], it is demonstrated that during the period in which the DG operates in parallel to the grid, the load connected to the PCC will be fed by + Ī Ī s G r . The internal voltage of the machine Ē I will be at a displacement angle to the voltage at PCC represented by VT. The angle between Ē I and VT is known as the load angle, which is represented by θ. When a loss of connection to the grid occurs, simulated by the opening of the switch CB, the load will be exclusively fed by Ī s ; thus, the voltage at the PCC will be represented by ′ V̄T. In this case, there is a change in the load angle. This change is represented by θ Δ . Figure 2a represents the voltage vectors before the opening of the CB switch, whereas Figure 2b represents the voltage vectors after the opening of the switch. This displacement in the angle of the voltage at the PCC is called the vector shift.
The change in the load angle of the machine can be easily assessed by measuring the displacement in the phase of the voltage at PCC. Therefore, this displacement is proportional to the change in the load angle. Figure 3 illustrates the voltage at the PCC immediately after the opening of the CB switch. For the purpose of simulation, the single line diagram of Figure 1 was implemented in SIMULINK, as illustrated in Figure 4.
The generator G1 is connected to the infinite bus through the switch CB. Parallely connected to the G1 there is the local load. The vector shift relay is also illustrated. For simulation purposes, as the analysis would be done in symmetrical faults, it is considered that the measures for the vector shift relay are being performed in a single phase. The configuration of the G1 and of the block of "Excitation and speed governor" is done in Sections 2.3 and 2.4.
A single line diagram of Figure 4 is shown in Figure 5.
The subsystem used to simulate the vector shift relay block of Figure 4 is illustrated in Figure 6.
In this simulation, the system was considered balanced, and only one phase was analyzed. This subsystem takes the voltage of the phase "a" as a reference and applies it to the block "zero crossing." Thus, this block gives an impulse of unity each time the voltage crosses to zero. After this, the "off delay" block is applied to solve any problems associated with the time step of the simulation. This signal is applied to an "AND" port to check if the crossing occurred during the raising period or the falling period. Therefore, it will only compute the zero crossing in the raising period. For a better understanding of the diagram in Figure 6, a flowchart is illustrated in Figure 7. At the point "A" of Figure 6, there is a zero crossing signal reference for the beginning of each cycle. This signal is applied to four synchronized subsystems. The first one, at each falling edge will capture the current crossing time. This information will be available at the point "C." But, before the current time is updated, the second subsystem will save the last crossing time at the rising edge in "B." A subtraction of the current time from   the last time will be done putting at the point "D" the information of the duration of each full cycle. In a similar way, the duration of each cycle will be updated at "F" as well as the duration of the past cycle will be stored in "E." The difference between this time duration is available at "G." This difference will be divided by the duration of the last cycle to calculate the percentage variation of the cycle time, which is available at "H." Once a full cycle corresponds to a 360°, the variation in degrees can be obtained by multiplying the percentage by 360. This information is available at "I." The RMS value of the voltage measured at input 1 is divided by the phase voltage. In "K" there is the voltage measured in percentage. This value is compared to a reference, in this case, 90% and, if the voltage of the phase is greater than this, the signal at "L" will be one. Otherwise, if the voltage is smaller, the signal will be zero disabling the vector shift relay. Another condition is implemented in "J" where a unity step is applied after 1.5 s. This has the function to disable the vector shift relay during the initial transient period of simulation. Past the transient period of simulation, if the voltage is greater than 90%, the module of the information of the phase displacement will be available in "M." This value will be compared to a triggering value adjusted in the input 2. If the measured value is greater than the triggering value, the output 3 will become high at "O." This information can be used to stop the simulation. At the output 1 will be available the information about the phase displacement measured in the instant where the simulation was stopped. In the output 2, point "N," will be available the  information about the time that the simulation was stopped. So, time information available at the output two can be used to compare with the time that CB switch was set to open. With these, the duration that the vector shift relay spent to feel the loss of main can be captured.
For good accuracy of the results, the time step for the simulation must be considered. For a frequency of 50 Hz, if an accuracy of ∘ 0. 2 is desired, the time step should not be greater than × − 1 10 5 .

Excitation control
In the IEEE 1547.1, section "5.7.1 Unintentional islanding test," the test procedures to ensure the action of the antiislanding detection device are described. In the section "5.7.2.5 Comments," it is emphasized that, the characteristics of the fuel rate (speed governor) and of the excitation devices must be considered during the unintentional islanding test procedure [15]. So, these should be considered in the simulation. The excitation control is composed of components such as the automatic voltage regulator (AVR), reactive current compensation, and power system stabilizer and limiters. The IEEE Std 421.5-2016 "Recommended Practice for Excitation System Models for Power System Stability Studies," has a collection of the most used excitation systems in synchronous machines. The excitation system can be classified into three groups according to the current source to the field winding as Type DC, Type AC, and Type ST. Each of them is further divided into different topologies according to their implemented functions, giving a total of 43 different excitation systems. A sample data for each of them is provided in the Annex H of the standard [20]. The AVR ST1A was selected for this article. Students could also be challenged into researching the advantages and disadvantages of each topology through simulation.
Another important device to be studied is the reactive power controller. It can be used to ensure a predefined power factor (PF) value or a predefined reactive power value. For the PF, there is a trouble that needs to be handled about the nonlinear function. Some normalization methods are presented in the IEEE Std 421.5-2016 [20]. As defined in the IEEE 1547-2018, chapter 5.3.1, in the general case, the DG should be set to work with a constant PF equal to one [15]. For this simulation, a "VAR type 2," as presented in the IEEE Std 421.5-2016, was considered with reactive power set to zero. The parameters used were available at the Annex H of the IEEE Std 421.5-2016 [20].
The excitation diagram implemented in the subsystem "Excitation and speed governor" of Figure 4 is illustrated in Figure 8.
By convention, the generator is considered with a lagging PF when it is supplying the reactive power, and leading PF when it is consuming reactive power. Many research studies are done comparing the effects of a generator working with unity PF or lagging PF [21]. Related to this topic, the students can be encouraged to change the control from the reactive power control to PF control. The students can also be encouraged to perform some

Speed governor
Considering the DG working with biogas, the most common topology is the use of a gas engine with a synchronous generator. For its proper operation, the speed of the synchronous machine has to be controlled. The synchronous machine can work attached to the distribution grid or islanded, and the speed governor must maintain a constant speed of the machine even in the case of islanding [22]. For this purpose, the two main methods used to control the speed of the generators, only based on local measurements, with no need of communication, are isochronous mode and droop mode. In the isochronous mode, the speed of the generator is kept constant from no load to full load, which is recommended for islanded operation. In case of parallel operation, if two generators are settled to isochronous mode, they will fight by the load and some of them will be switched off. In the droop mode, the speed is decreased as the load is increased in a proportional scale known as droop coefficient. For the operation parallel with the utility grid (infinite bus), the machines are usually set in droop mode. The usual speed droop coefficient is between 3 and 5% [8,23].
For this simulation purpose, the model used for the speed governor is illustrated in Figure 9 as a droop control. As inputs of the controller, a summing block will compare the reference speed (wref) with the measured speed of the shaft of the generator (wm). A second adding block compares the measured active power (Peo) with the commanded power (Pcommand). So, the control will try to increase the speed of the shaft until the measured power matches the commanded power with an error defined by the droop characteristics. The speed error will be applied to the control block. The dynamics of the actuator and of the gas engine are described in ref. [8,9]. For simulation purposes, the models and parameters of the control, actuator, and engine were used as described in ref. [9]. The parameters are available in the Appendix.
Some tasks to the students regarding speed governor can be to analyze the different speed droop settings as reference [24]. What would be the effects of a higher or lower droop setting? Another option to defy the students could be to improve the research about nonlinear methods to adjust the droop as developed in ref. [25]. As the isochronous mode is more appropriate for islanded operation and the speed droop mode more appropriate for grid tie operation, an automatic switching method is proposed in ref. [23]. As soon as an islanding event is detected, the generator is switched from droop mode to isochronous mode. Some research to improve this method can be proposed.

Synchronous machine
The SIMULINK has the block "Synchronous machine-p.u. standard" in its library. In the simulation described here, it was considered a salient pole machine of 31,300 VA, 50 Hz, and 400 V. The parameters of the synchronous generator were set based on ref. [22] and are available in the Appendix. In MATLAB/SIMULINK, for the simulation of the synchronous machine is also necessary to add the "powergui" block. On this simulation, it was set to discrete solver with a time step of × − 1 10 s 2 .

Infinite bus
On the settings of the infinite bus a point to be handled is the internal impedance or, the short-circuit level. Some different scenarios can be simulated considering the generators installed in the rural, urban, or suburban areas. The distance between the generator and the distribution transformer will directly affect the circuit characteristics. A research about the minimum and maximum length as well as the minimum and maximum short-circuit level and the typical X/R relation for each different scenario is done in ref. [26] and could be used to support the simulations. With this information, the students can be defied to experiment the DG in different conditions. As the coverage of all possible topologies is beyond the focus of this article, for the proposed example, the check box of internal impedance and short-circuit level of the infinite bus are unchecked. The phase-to-phase voltage is defined as 400 V and the frequency as 50 Hz.

Simulation discussion
Once everything is set as described, the simulation can be performed. The switch CB illustrated in Figure 4 is used to simulate any event that would make the DG islanded with the load. In the IEEE 1547.1, in section "5.7.2 Unintentional islanding test for synchronous generators" a procedure to be followed to ensure the proper operation of the unintentional islanding protection is described [17]. On this standard, there is a step-by-step procedure explaining  how to choose the values to set the load and what conditions would be needed to simulate to ensure the proper operation of the anti-islanding device. The phase displacement measured at the output 1 of the subsystem illustrated in Figure 6 can be plotted using the "Scope" block from SIMULINK. If more than one simulation need to be plotted in the same graphic, a "To Workspace" block from SIMULINK can be used. As an example, four simulations were performed. In the first one, the local load was set with the same power as the settled power in the DG ( = PL P G 1.00 ). A second simulation was performed with the local load settled at 95% of the power settled in the DG ( = PL P G 0.95 ). Similarly, a third with 90% ( = PL P G 0.90 ) and a fourth with local load settled as 85% of the power settled in the DG ( = PL P G 0.85 ) were performed. For all these simulations, the CB switch was set to open with 18 s. The simulation running time was set to 20 s. The phase displacement angle, obtained as a result of these four simulations is illustrated in Figure 10. For this plot, the time was decremented from 18, thus, the time illustrated in the graphics means the time after CB opening. As illustrated in Figure  4, the triggering angle of the vector shift relay was set at 1.5 degrees, so, for the simulations with a power mismatch equal to 0%, 5%, and 10%, the relay was not triggered. In the simulation with a power mismatch of 15%, the phase displacement observed was greater than the triggering angle settled value, so, the vector shift relay has actuated. Once the vector shift relay act, the phase displacement at this moment will be stored in the output 1 of the subsystem as illustrated in Figure 4. The time that this trip had occurred will be stored in the output 2. Thus, with this information, it is possible to determine how long it took for the system to detect the islanding. The output 3 of the subsystem of Figure 6 will be used to stop the simulation.
This scenario was organized considering the studies with focus in the methods of vector shift relay to detect the unintentional islanding switching off the DG as soon as possible. In the case the user intends to analyze the operation of an islanded DG system, it is recommended to the students to do a review of the IEEE 1547.4 that describes all the tests to be performed to ensure the proper operation for some islanded area [27].

Conclusion
This article presented a vector shift relay implementation in MATLAB/SIMULINK with all components necessary to its simulation as a proposal for DG lectures to electrical engineering courses and researches. The choice of each component and all settings are justified based on standards or referenced articles. For each topic, possible challenges and difficulties for the students to research are related. Thus, the objective here was to provide a tool to help students and engineers in improving their self-learning abilities, problem solving, and analysis of DG systems. Finally, this article aims to contribute with a step-by-step orientation to students and engineers about unintentional islanding detection with vector shift relays applied to synchronous machine, specially due to the lack of technical literature and guides on this subject.