Relay protection mirror operation technology based on digital twin

When conducting relay protection research, research costs can be significantly reduced if protection principle development, protection parameter verification and debugging can be carried out without relying on actual protection devices. The concept of ‘digital twin’ has made this possible, but the existing research has shortcomings in real-time data interaction ability, protection logic transparency, interface standardization, human–computer interaction etc., and consequently, mirror operation of relay protection in digital space has not been fully realized. Therefore, referring to the characteristics of digital twin, and combining with the practical application requirements in relay protection, this paper proposes the concept and characteristics of relay protection mirror operation based on digital twin. Key solutions are proposed to address the difficulties that may be encountered in the implementation of relay protection mirror operation in terms of protection principles, interfaces, real-time operation of the system, and human–computer interaction function simulation. Finally, an example of 110 kV double-bus and double-branch bus protection is used to verify the feasibility and progressiveness of the scheme proposed in this paper by comparing the action behavior and external characteristics of the twin protection and the actual protection device. The presented research can provide a reference for further in-depth research and application of relay protection using digital means.


Introduction
Under the framework of "double-carbon" target, the construction of China's new power system has been accelerating in an all-round manner.Compared with the traditional power system, in the new power system, its power supply installation structure and power generation mode, power grid function and shape, and load structure and characteristics have undergone significant changes.The microsecond power electronic switching process, and the AC motor transition process at millisecond and second time scales, interact with each other, and the complexity, nonlinearity and uncertainty of the power grid operation have increased [1][2][3].As the first line of defense for safe and stable operation of a power grid, relay protection will face major challenges in its original technology manifestation and management mode, with emerging new requirements in terms of protection principle, data interaction form, action behavior and operation and maintenance mode.
Research of relay protection shows that there are many inconveniences using actual protection devices.For example, the checking and setting of protection-related parameters often involve the assessment of various extreme operating conditions.The cost of using actual protection devices to conduct research is very high, especially when conducting tests of a power grid including HVDC transmission systems, as the number of actual control and protection cabinets required is nearly 200-400 while the wiring is complex and the test efficiency is low.When developing and testing new protection principles, researchers often need to burn the compiled program into the control chip of the actual protection device many times, and the relay protection test instrument is then used to simulate and analyze the action behavior of the actual protection device to verify the correctness of the design scheme.This method requires a long development cycle.In addition, when the protection device needs to be tested at the system level, it requires a large number of pieces of secondary control and protection equipment for cooperation, and the cost of human and material resources is relatively high.Therefore, it is necessary to build a digital model consistent with the actual protection device to realize the mirror operation of relay protection in digital space, so the development of new protection principles, system-level testing, protection setting verification, parameter debugging and other work can be completed without relying on the actual protection devices.This can further provide constructive guidance for the optimal operation of actual protection devices.'Digital twin' builds accurate simulation or full digital representation of physical entities through simulation, data perception, hybrid modeling, virtual reality and other technologies, with real-time, closed-loop, fidelity and other characteristics.For traditional simulation, at the level of model construction, the models built are universal and tend to reflect the internal laws and operating mechanisms of physical objects.In comparison, the models built by digital twin are high-fidelity and more biased towards the individual differences of physical objects.At the model operation level, in traditional simulation, models are mostly operated offline with parameters also updated offline, and the data between physical objects and models are mostly a one-way flow.However, digital twin can realize the real-time operation of models and automatic update of parameters, and the data flow between physical entity and twin is a two-way interaction.
In recent years, thanks to the rapid development of industrial informatization and digitalization, digital twin has been widely used in intelligent manufacturing [4,5], building construction [6], energy power [7][8][9], urban management [10] and other fields to support product scheme validation, equipment performance analysis and 3D visualization of scenes.In power system relay protection, there are also some embryonic applications of digital twin.For example, at the level of protection principle, for AC protection, researchers take the mathematical model of the protection object and conduct protection action behavior discrimination by dynamic state estimation of the model [11,12].Subsequently, this idea is applied to DC line protection in [13], and the corresponding digital twin model is established according to various physical laws of the protection object.Comparing the difference between the measured electrical quantity and the state estimation of the twin model, the protection action behavior is judged, and the simulation results show that this method can effectively alleviate the "four characteristics" contradiction in DC protection.At the level of data interaction, reference [14] constructs the primary and secondary joint simulation digital system based on PSCAD/EMTDC and VC++ , from the four aspects of fault data acquisition, external data interface, fault data conversion and protection algorithm.However, because there is no closed-loop between the protection action behavior and the primary simulation system in this system, while the primary system only collects analog quantities such as fault voltage and current without involving state quantities such as switch position, the action behavior of the protection in the simulation has limitations and does not truly reflect the actual protection device.Reference [15] proposes a relay protection modeling method based on virtual relay.By feeding back the protection action information to the dynamic simulation program, the circuit breaker operation event is formed while the topology of the network is changed accordingly.Thus, it can address the problem that the output of the dynamic simulation program and the protection model cannot be closed-loop.However, it focuses more on the consistency between the protection logic and the actual device, and does not involve the external characteristics, signal interface and other contents of the device.The engineering mirror simulation method proposed in [16], with the help of the SIMADYND and RTDS platforms, builds a simulation model that is consistent with the actual DC control and protection functions and external characteristics, and forms a complete AC/DC closed-loop simulation test environment with the primary system of RTDS.However, the system cannot interact with the control and protection systems of other manufacturers, and cannot access the control and protection logics of other manufacturers on this platform.
Digitization is the direction of future social development and power grid development.The emerging technology represented by "digital twin" can provide key means to support the digital transformation in the field of relay protection.However, the application of digital twin in the field of relay protection is relatively scattered and immature, and there are general deficiencies in real-time data interaction ability, protection logic transparency, interface standardization, human-computer interaction etc.Thus, it fails to truly realize the mirror operation of relay protection in digital space.Therefore, this paper refers to the characteristics of digital twin, and combined with the practical application requirements in relay protection, it clarifies the characteristics of relay protection mirror operation based on digital twin.This paper proposes the key technologies to address the difficulties that may be encountered in the implementation process.Finally, through comparison with an actual relay protection device, the feasibility and progress represented by the scheme proposed in this paper are verified.

Overview of digital twin
A digital conceptual model was proposed by Professor Michael Grieves of the University of Michigan in the course of product lifecycle management (PLM) in 2003: "virtual digital expression equivalent to physical model" [17].The model has three elements of virtual and physical space, and the interface between them conceptually [18].Because of the technical limitations at that time, digital twin remained at the conceptual stage.In 2010, considering the particularity of a spacecraft's working environment and high production costs in the aerospace field, NASA and the United States Air Force began research on digital twin for aerospace.
A lot of research has been carried out on digital twin, forming many white papers, reports, monographs, industrial solutions and other research results.Given the diversity of studied physical objects, it is difficult to give a unique definition of digital twin.At present, the most widely accepted definition is: "Digital twin is to make full use of physical model, sensor update, operation history and other data, integrating multi-disciplinary, multiphysical, multi-scale, and multi-probabilistic simulation process, and complete mapping in the virtual space, thus reflecting the whole life cycle process of the corresponding physical equipment" [19].
As the mapping of physical entities in virtual space, the primary feature of digital twin is to keep consistent with the operational rules and internal mechanism of physical entities.As for other characteristics of digital twin, although different studies offer different descriptions, they all imply the idea that digital twin can interact with physical entities in real time, and realize data sharing between twins through unified standardization.They can be independent of physical entities, and can provide constructive guidance for the optimal operation of physical entities through inversion, forward, prediction and other operations [19][20][21][22][23].It should be noted that the real-time and frequency of interaction between digital twin and physical entities depends on the characteristics and application requirements of the physical entity objects [24].For example, when planning a power system, the grid structure of the power system remains unchanged for a long time, so there is no need to conduct frequent realtime interaction on the system topology and parameters.

Characteristics of relay protection mirror operation based on digital twin
From the characteristics of digital twin, combined with the practical application requirements in the field of relay protection, this paper proposes the concept of relay protection mirror operation based on digital twin.This can realize the functional alternative of real relay protection devices and real-time data interaction.The schematic diagram is shown in Fig. 1.The twin protection shown in Fig. 1

Difficulties of relay protection mirror operation based on digital twin
Deriving from the above four characteristics, the mirror operation of relay protection based on digital twin mainly has the following difficulties:

Accurate modeling of protection principles
The existing modeling methods of relay protection principles can be roughly divided into two categories: modeldriven and data-driven.When using the model-driven modeling method, the focus is on the digital reproduction of the operation mechanism of the protection device.For example, for protection data processing, reference [14] proposes an improved full-wave Fourier algorithm to eliminate the calculation error caused by the attenuated DC component in the fault signal during the protection operation, making it closer to the protection algorithm of the actual protection device.In terms of protection function logic replication, common methods can be roughly divided into code implementation and graphical modeling.For protection manufacturers, they have their own source code of various protections.This can be processed and encapsulated slightly to realize the replication of protection function in virtual space.This method can restore the function of the actual protection device to the maximum extent, but the disadvantage is that the protection logic is not intuitive enough and the visibility is poor.For relay protection practitioners who do not have protection source code, they can also build corresponding protection and control logic in a graphical way to meet their own needs according to the State Grid Nine unified standard and the manufacturer's instructions.However, because some experiences and detailed processing problems in the protection logic will not be reflected in the manufacturer's instructions, the protection logic built in this way is slightly different from the actual protection device, so it is only applicable to occasions with low requirements for protection logic.
When using the data-driven modeling method, the key is to use big data, artificial intelligence, machine learning and other means to fit the relationship between input and output, so as to construct a mathematical model consistent with the actual action behavior of the protection device.For example, reference [25] regards the power flow equation as the process of solving some parameters with known parameters, thus realizing the system power flow calculation by means of in-depth learning without relying on the network topology.Comparing it with the results calculated by the power flow method, the reliability of data-driven modeling to calculate the power flow is verified.
Compared with the model-driven modeling method, the data-driven modeling method omits the research process of the complex operation mechanism of the actual protection device, and establishes a black-box model.With the increasing number of training samples, the model can be further improved, but because of its high dependence on data, it is vulnerable to bad data.
In new power systems, new equipment and new technologies in the power grid are constantly emerging, and the mechanism models of some pieces of equipment are difficult to obtain accurately, and the traditional mechanism-based modeling method finds it difficult to reflect the individual differences of physical objects.Therefore, based on existing modeling methods, it is necessary to study the corresponding graphical, hierarchical and hybrid modeling technologies by summarizing the program implementation methods of relay protection principles so that the built twin protection principle model can meet the requirements of transparency, compatibility and easy maintenance.

Interface modeling and data real-time interaction
Twin protection needs real-time data interaction with the primary simulation system, the actual protection device, the communication subsystem of station control layer and the oscillograph, etc.The data interaction diagram is shown in Fig. 2.
As can be seen, the twin protection and the primary simulation system mainly carry out the transmission of analog and switching quantity, SV, GOOSE and other information.The twin protection collects the SV message or analog quantity of the primary system for protection logic calculation, and the circuit breaker position and tripping signals interact with each other through the GOOSE message or switching quantity.The twin protection and the actual protection device mainly transmit the tripping and startup failure signals and other information through a GOOSE message or switching quantity.The oscillograph obtains the action information of twin protection through the GOOSE message or switching quantity, and achieves the acquisition and control of information through an MMS protocol.The communication subsystem of the station control layer also realizes the acquisition and control of twin protection information through the MMS protocol.
To meet the signal interaction requirements, twin protection shall have both conventional and digital interface capabilities.For conventional interfaces, it shall ensure that the interface function, conversion accuracy and delay meet the requirements of twin scenarios, while the number of interface input/output channels can be configured and expanded.For the intelligent interface, it shall ensure that it adopts IEC61850-8-1, IEC61850-9-2, IEC60870-5-104, GB/T18657, GB/T22239, GB/T26865.2,DL/T860 and other common communication standards and protocols of the power system.The communication bandwidth and channel delay shall meet the requirements of twin scenarios, while the communication interfaces shall adopt modular design, and the number of channels shall be configurable and expandable.

Real-time operation and execution efficiency of the system
The sampling interval of twin protection is usually 250-833 μs, which requires the software and hardware platform to have strong real-time performance to complete data acquisition and calculation.The real-time operation of twin protection depends on the real-time performance of the computing unit, so it is necessary to study that performance.
The real-time operating system (RTOS) refers to the operating system that can accept and process external events or data at a fast enough speed when they are generated, and its processing results can control the production process or make a quick response to the processing system within the specified time, and control the coordinated operation of all real-time tasks.
As a general operating system, Windows cannot provide the real-time operation performance required because its interrupt response time can be hundreds of milliseconds which is poor for real-time.The current mainstream real-time operating systems include PSOS, VxWorks, QNX, VRTX, etc.Although their characteristics of real-time performance, technology accumulation, hardware support, being friendly and easy to use can also meet the requirements of the simulation test platform, they are commercial operating systems, which require high licensing costs.As an open source operating system, Linux has a very good user community and document support.Because of its open source code, it is relatively easy to conduct in-depth analysis from the code level when encountering problems.In addition, the way of patching can make the real-time performance of the Linux kernel reach the level of the commercial real-time operating systems.Therefore, this paper selects the Linux system for research and transformation.
In addition to the impact of the system software level, the impact of the hardware level can also cause the response time of the twin protection to be unstable, such as power management, interrupt sharing, interrupt throttling, etc. [26], and need further study.At the same time, to ensure that a single computing unit can run multiple sets of typical twin protection at the same time, it is also necessary to study CPU multi-core parallel computing technology and the communication technology between cores.

Human-computer interaction function simulation
To achieve the acquisition and control of twin protection information, human-computer interaction technology research is also required, including: • Research on protection interface simulation and control.It needs to display the analog quantity of protection, signal light and other information, and be able to perform protection reset, protection setting and parameter modification, protection strap on/off and other operations.It also needs the functions of monitoring of protection status, refreshing of protection message, and generation of protection recording, all in real-time.• Research on automatic generation of protection model files.The SCD file is the carrier to describe the data interaction of a relay protection device, and plays a key role in the operation of relay protection in an intelligent substation.Because of its complex structure and the large amount of information in the file content, with up to hundreds of thousands or even millions of lines of text, it can hardly be edited manually.Therefore, the SCD file of twin protection must be automatically generated and meet the requirements of relevant standards, with the format and content being standardized.After the twin protection model is updated, the SCD file and MMS server service should also be updated automatically.• Research on service technology of virtual station control layer.The twin protection shall be able to run an MMS server for the connections between station control layer clients, oscillograph, security sub-stations, etc., so as to read the parameters, settings, straps, telemetering, telesignalisation and other information of the twin protection at the station control layer, and send the protection function status, protection events, protection alarm signals, telemetering and telesignalisation information in real time.• Research on protection interface configuration technology.It shall be able to parse the SCD file of the twin protection, and realize the corresponding connection of SV, GOOSE, input and output information between the twin protection side and the primary simulation system and hardware channel in a specific way.

Key technologies for realizing relay protection mirror operation based on digital twin
In view of the difficulties listed in Sect.3.2, this paper proposes the following solutions to realize the mirror operation of relay protection based on digital twin.

Protection principle twin technology
To achieve accurate modeling of protection principles and take into account the requirements of model transparency, this paper proposes hierarchical modeling theory and carries out graphical modeling of protection logic using the Simulink modeling platform as the development tool.The specific protection logic refers to the relevant books, professional papers and manufacturer's instructions of relay protection.

Hierarchical graphical modeling technology
In this paper, the protection logic is built according to the hierarchical modeling structure shown in Fig. 3, which mainly includes libraries of the basic element and intermediate elements and of the protection element.
For the basic element library, it mainly includes the arithmetic, logic, mathematical function, comparison and selection, integral, and delay elements etc., required for building the relay protection logic.The basic element library can be built by combining simple elements or M code elements, among which the simple elements can be directly copied from the Simulink library and then renamed accordingly.By building the algorithm logic of simple elements and using the atomic subsystem in Simulink, the integration, delay and other composite elements can be further generated.In addition, the function of elements can also be described directly through M code and converted into M code elements by using the atomic subsystem in Simulink.This method is often used to build basic elements with complex logics.
From the basic element library, from the protection action logic specified in the manufacturer's instructions, the intermediate element library is built.This mainly includes the elements of protection starting, phase selection, impedance, differential, failure protection, complex voltage discrimination, overcurrent protection, direction, ranging, oscillation, harmonic detection, CT saturation discrimination, CT disconnection, and PT disconnection, etc. Taking the PT disconnection discriminant element shown in Fig. 4 as an example, it clearly shows the logic of "PT disconnection" with a delay of 1.3 s when the device is not started and meets any of the following three conditions: "zero sequence voltage is greater than 8 V", "positive sequence voltage is less than 18 V and any phase has current", and "positive sequence voltage is less than 18 V and TWJ does not act".After the intermediate element library is completed, to improve the efficiency of model compilation, it can be encapsulated into S-Function elements to finally form the protection element library, with protection such as of common line, transformer, bus, etc.

Model variable naming rule
There are a large number of intermediate variables in the complete relay protection model.To facilitate understanding, it is necessary to develop a set of standardized naming rules for model variables and conform to the usage habits of the industry.
Taking the above hierarchical modeling method as an example, first of all, we refer to the abbreviations of some commonly used words in DL/T860.74-2006 and Q/ GDW 1396-2012 standards to enumerate the abbreviations of all basic variables that may be used in the modeling process, e.g., Str for start, Val for value, etc.Then the intermediate element attribute is named through the combination of basic variable abbreviations, e.g., the abbreviation of starting value is StrVal.Finally, it enumerates all intermediate variables and specifies abbreviations for them, such as PTOC for AC time overcurrent protection and PDIS for distance protection.Note that when variables are transferred between different elements, the naming method of "intermediate element abbre-viation_attribute" is adopted.For example, the name of overcurrent protection starting value is PTOC_StrVal, and the name of distance protection starting value is PDIS_StrVal.

Fault data processing and interface standardization technology 4.2.1 Fault data processing technology
Twin protection collects SV9-2 message information for logical calculation.The SV9-2 message is sampled at 4000 points per second.In order to moderately reduce the calculation requirement, this paper divides the SV9-2 message into two frequencies, i.e., twin protection uses 2000 points per second for fixed interval sampling.However, the actual protection devices traditionally use the frequency tracking sampling of 24 points per cycle, while the instantaneous value differential criterion is closely related to the number of sampling points, and thus it is necessary for the twin protection to simulate the classical 24 point sampling.
When using 2000 fixed sampling points per second, the number of sampling points per cycle is 44.44 with a system frequency of 45 Hz, and 36.36 with a frequency of 55 Hz.In both cases, the number of sampling points per cycle is greater than 24, so it is possible to skip some redundant points without calculating them.However, the sampling value calculated 24 times cannot use the original sampling value of 2000 points.Therefore, in this paper, a set of 24-point sampling data is obtained again through a linear interpolation method for subsequent logical calculation.
There are many kinds of relay protection algorithms.In this paper, we use the following algorithms to process the sampled data: full-cycle/half-cycle Fourier, differential Fourier, frequency tracking Fourier, instantaneous value differential, etc.These are consistent with the actual protection devices.

IO interface technology
The twin protection should be consistent with the actual protection device, with the human-computer interaction interface, the input/output interface and the wave recording functions.To distinguish different interface types when generating code, we define five interface modules, FromHMI, ToHMI, FromPKT, ToPKT and ToREC, to standardize the interface types.
The FromHMI module is defined to receive the information of the twin protection and background interaction, such as device parameters, protection settings, protection soft straps, etc.The ToHMI module defines the information of background monitoring, such as effective value, full-cycle Fourier value, frequency, protection intermediate and output nodes, etc.For the FromPKT module, it defines the switching quantity that the protection needs to receive, such as switch and knife switch position, failure input, remote trip, lock reclosing signal, etc.The ToPKT module defines the switching quantity that the protection needs to output, such as trip and start failure signals, etc., while for the ToREC module, it defines the wave recording of the protection, such as various analog and switching quantities.Taking the From-HMI and ToHMI as examples, the data types defined in their interface modules are shown in Table 1.
Simulink signals are usually transmitted between modules by "From Goto" or "Data Store Memory", both of which can transfer signals from one module to another without actually connecting them.Based on the signal transmission characteristics of these two methods, the "From-Goto" transfer method is more suitable for the case where there are few model variables and no reuse is required.When there are many model variables and the same model needs to be reused multiple times, the "Data Store Memory" transfer method is more advantageous.
Considering that there are many model variables in the twin protection interface modeling, to reduce the workload and improve the reusability of the module, we use the "Data Store Memory" method to transfer the relevant variables in the above five interface modules, as shown in Fig. 5.

Data interaction technology
Through analysis of the SV9-2 message format and transmission mechanism, the frame length of the SV9-2 message is relatively small (fewer than 400 bytes), but the transmission frequency is very fast (4000 frames/ second).If twin protection sends messages from multiple merging units through a gigabit network card, the frame rate of the network card will reach tens of thousands of frames per second.If using the method of generating interrupts per frame of message sent to notify the CPU, the CPU will respond to tens of thousands of interrupts per second.As it will take time to respond to the interrupts and save the scene each time, using the method of interrupt reception will require a lot of CPU time to process the interrupts [27].Thus, we adopt the transmission mode of shielding network card interrupt.
The CPU stores multiple merging unit messages into the ring storage area, and notifies the network card to use DMA batch transmission mode.It then analyzes whether the batch transmission is successful in the next calculation step.
In the SV9-2 point-to-point test mode, a single computing unit is required to output multi-interval SV data synchronously.This requires the simulation system to have multiple network cards, and each network card outputs data for one interval.This is an ideal point-topoint mode.However, this mode brings great difficulties to the protection test, which not only increases the cost of the hardware of the multiple network cards, but also increases the difficulty of the data control of the cards.This is one of the important factors that restrict the digital test and the station domain protection test.So in this paper, the data transmission method shown in Fig. 6 is proposed.As seen, the computing unit packages and sends out messages at multiple intervals through the network card, converts the received messages into optical signals through the private exchange, and divides the messages into data with different intervals through VLAN grouping technology.Because the time jitter of the computing unit and the private exchange is very small, the interval jitter of the 30 interval data output by the test system is less than 10 μs, which meets the requirements of standard point-to-point testing.

Model real-time running service engine technology
To make the twin protection more universal and easier to implement, we use a server based on ×86 CPU and the open source Linux operating system.However, these general software and hardware systems are not designed for real-time use.Therefore, the key points affecting the realtime performance of the system are modified as follows.

Real-time improvement of Linux system
Linux itself is a general-purpose operating system, while the main purpose of a real-time operating system is to respond to an external event (such as analog sampling interrupt) within the specified deadline.At least one realtime task is running in the real-time system, and highpriority real-time tasks can interrupt the execution of low-priority real-time tasks and non-real-time tasks to meet their own deadline requirements.The general Linux kernel takes throughput as its main optimization goal.Only when the system calls and interrupt response ends can task preemption occur, resulting in high-priority interrupts that cannot be responded to in time.Therefore, it is necessary to apply a preempt_rt patch to the kernel.This patch threads all interrupt service routines (ISR), and users can freely adjust the priority of the ISR, such that the ISR with high priority can preempt execution at any time.In addition, the original spinlock is transformed into a dormant spinlock, and the larger non-preempt area is changed into several smaller non-preempt areas, thus transforming Linux into a realtime operating system.

Instability modification of interrupt response time
In addition to the above ISR threading, other software and hardware factors may also cause the instability of interrupt response time, such as CPU power management, PCI interrupt sharing, and poor quality system code.CPU power management can be turned off through the BIOS option, PCI interrupt sharing can be avoided through message signal interrupt (SMI), and system code with poor quality can be assigned to a separate CPU for operation through the Linux task isolation mechanism.For example, adding the kernel parameter isocpus = 1-7 on an 8-core system can assign all non-real-time tasks to CPU0 for operation.
In addition, it is worth mentioning the interrupt throttling mode of the network card.This mode can reduce the number of interrupts per unit time, thus greatly improving the throughput of received messages.However, this will affect the timeliness of receiving SV9-2 messages.Therefore, it is necessary to turn off the interrupt throttling mode of the network card, so that each packet of message interrupt can trigger the ISR in time.This usually requires adding the driver parameter InterruptThrottleRate = 0.

Multi-core parallel computing technology
The computing power of a single core is always limited.In order to ensure that a server can run multiple (such as 20) twin protections at the same time, we use core 1 to receive and parse SV9-2 and GOOSE messages.For cores 2⁓5, each core runs five typical twin protections.After core 1 completes the message parsing and obtains the analog and switching quantities required for protection, cores 2-5 start parallel computing at the same time, and the throughput is 4 times higher than that of the serial computing, and 20 twin protections can be calculated in a limited step.In addition, multi-cores transfer data through shared memory.At the same time, in order to ensure the integrity of data transmission, Linux semaphores are used for synchronization.

Human-computer interaction technology 4.4.1 Protection interface simulation and control technology
There are two ways to achieve the acquisition and control of twin protection information by the background host, as shown in Fig. 7.
Mode 1: Real-time communication between the two is realized through the background control program.The communication protocol is a user-defined private protocol using UDP mode.In this mode, the background host can adjust the parameters and settings of twin protection.This is equivalent to the key operation of the actual protection device.At the same time, twin protection can also send telemetering, telesignalisation, protection events and fault recording to the background host.This is equivalent to the LCD screen display and background operation of the actual protection device.
Mode 2: The station control layer communicates with the twin protection through the IEC61850-MMS protocol.In this mode, the twin protection integrates the MMS server service.After the twin protection runs, the server service automatically starts and responds to the connection request of the MMS client in real time, so as to realize the real-time interaction of information such as setting, strap, event, oscillograph file, etc. under the MMS protocol.

Background host
Background control MMS Fig. 7 Information interaction between twin protection and background host

Virtual SCD modeling and automatic generation technology
The SCD file is a complex tree structure description file in XML format.The root nodes of the tree structure are shown in Fig. 8, including Header, Substation, Communication, IED, DataTypeTemplates, etc. Header is the declared information, Substation is the information of primary device topology and is not necessary, while Communication is a communication parameter describing the IP address, MAC address and other parameters of the IED.Each IED corresponds to a relay protection device, describing the function and information interaction of the device, whereas DataTypeTemplates is the data type description.
In the root node, Communication, IED and DataTy-peTemplates are the three key nodes, which contain the most information.For these three nodes, we adopt different processing schemes according to the different characteristics of their root nodes.
For Communication, it is divided into two communication subnets, i.e., SubNetwork_Stationbus and SubNet-work_Processbus. SubNetwork_Stationbus is the station control layer network, which contains the communication information of all twin protection IEDs.The IP address is automatically generated, and the rest use typical communication parameters.SubNetwork_Processbus is a process layer network, including all merging units, intelligent terminals and the GOOSE release of twin protection.
IED includes three types of devices: a merging unit, an intelligent terminal and a protection device.The merging unit automatically generates IEDs of 30 merging units using typical datasets, while the intelligent terminal automatically generates 64 IEDs using typical datasets.The protection device is generated according to the number of twin protections in the model file, and then the dataset, logical node and other information in the IED content are generated according to the data type defined in Sect.4.2.
For DataTypeTemplates, the DOType, DAType, and EnumType in the data types adopt the typical structure and are stored in separate files for loading when automatically generating the SCD files.LNodeType is generated according to different types of input and output in the model, including LPHD (device nameplate information), RDRE (disturbance record), LLN0 (data set node), MMXU (telemetering), PDIF (twin protection), TVTC (transformer parameter), GGIO (state quantity) and other data types.The member information of the different data types is determined according to the information in the twin model.

Virtual station control layer service technology
After the model of twin protection is changed, the MMS Server service automatically completes the steps of SCD file generation, MMS service startup and request response processing.The MMS service interacts with the twin protection in real time, and responds to the relevant requests of the MMS client at the same time to realize services, including reading protection parameters, settings, straps, telemetering and telesignalisation, and real-time sending protection function status, protection function locking status, protection events, protection alarm signals, telemetering and telesignalisation, as shown in Fig. 9.

Twin protection interface configuration technology
In Sect.4.2, after standardized modeling of the IO interface and generating code, the code has included information such as interface classification and variable type.With the help of big data characteristic analysis technology, by analyzing the Simulink code file, the interface classification and variable type information in the model can be classified and displayed in the background.
After the background software loads the SCD of the twin protection, we design a wired signal mapping  method.Taking the output channel of the twin protection as an example, in the interface shown in Fig. 10, the signal of the right output channel is dragged to the corresponding dataset channel according to the sequence number correspondence between the signals, viz. it completes the configuration of the output channel of the twin protection side, and configures the input channel in the same way.After the channel configuration is completed, the configuration can be exported and the ied_cfg.cfile can be generated at the same time.The configuration file contains the key information of the input IED such as dest_mac, appID and serial number of the interface.
After uploading this configuration file to the computing unit, the unit can input and output signals according to the corresponding configuration information.
5 Case analysis

Closed-loop simulation test platform
To verify the feasibility of the key methods described above, a real-time closed-loop simulation test platform for the primary and secondary systems is built as shown in Fig. 11 to carry out comparative tests between the twin protection and the actual protection device.
The real-time closed-loop simulation test platform for the primary and secondary systems mainly includes five parts: the host running the primary system simulation model; the host running the twin protection; the actual protection device; the intelligent interface device; and the background computer.The simulation system and the twin protection hosts communicate through SV and GOOSE messages.The simulation system host converts the voltage and current values into SV messages and sends them to the private exchange, while the private exchange then sends them to the twin protection host through VLAN grouping.The primary simulation system host sends and receives the switching quantity through GOOSE messages.The twin protection host calculates the protection logic in real time after receiving the SV and GOOSE messages, generates action messages and protection recording after meeting the action conditions of the relevant elements, and then outputs the protection related information through GOOSE messages.After receiving the SV, GOOSE messages or analog and switching quantity information sent by the simulation system, the actual protection device also discriminates the protection action behavior, and exports the protection related information through the GOOSE messages or switching quantity.The real-time interactions of protection operation mode, settings, straps and other information flowing between actual protection device and twin protection are achieved through the intelligent interface device.The background computer is mainly responsible for modeling the primary system, twin protection, and implementing human-machine interaction functions.

Closed-loop test example
Taking the 110 kV double-bus and double-branch bus protection as an example, the model is established according to the standard requirements of GB/T 26864.
The main wiring diagram of the model is shown in Fig. 12, and the twin protection model is built in Simulink according to the methods described in Sect.4.1.
The intermediate element library contains elements that can realize data processing, protection startup, differential complex voltage locking, CT saturation, CT/PT disconnection, knife switch correction, ratio differential, bus interconnection, manual dead zone fault, split operation, charging overcurrent protection, circuit breaker failure and other functions.The built model is then compiled, and the generated C code files are uploaded to the primary system simulation host and twin protection host through the primary system simulation background and twin protection background, respectively.After running the model on the twin protection side, with the help of the twin protection background control software, the protection interface can be simulated, the protection status can be monitored, the protection parameter, setting, and strap can be modified.Also the protection action message can be displayed and the protection recording can be generated in real time.In the simulated protection interface, the status of indicator lights such as "operation", "abnormal", "differential protection locking", "bus interconnection", "knife switch alarm" can be refreshed in real time according to the actual operation of the system and the protection logic.The "protection trip" light is a self-holding light and can be reset through the "reset" menu.
On the side of the primary simulation system, the MMS Server can be run by adding the IP of the twin protection to the background host of the twin protection, and then the station control layer of the twin protection can be connected through the MMS Client in the background of the simulation system.Similarly, by adding the IP of the simulation system background host to the actual protection device and running the MMS Client in the background of the simulation system, the station control layer of the actual protection device can be connected.After the connection is successful, the protection parameters, settings, straps, telemetering, and telesignalisation of the twin protection and the actual protection device can be read in the background of the station control layer.Also the protection function status, protection function locking status, protection events, protection alarm signals, telemetering and telesignalisation can be also sent in real time.

Comparison and analysis of results
Under the closed-loop test environment of Sect.5.2, according to the relevant standard requirements of the dynamic simulation test, the comparison of action behavior of twin protection and actual protection device with typical test items is shown in Table 2 (because of space limitation, only elected fault types are listed).
It can be seen from Table 2 that with the typical test items of the dynamic simulation test, the action behavior and external characteristics of the twin protection are highly consistent with the actual protection device.This verifies the feasibility and accuracy of the key technologies of relay protection mirror operation based on digital twin proposed in this paper.

Conclusion
Based on the characteristics of digital twin and the actual application requirements of relay protection, this paper defines four characteristics of relay protection mirror operation based on digital twin: consistency, interactivity, transparency and sharing.The difficulties that may be encountered in the implementation process are analyzed, and the corresponding technical solutions are proposed.These address the shortcomings of the existing digital twin design in relay protection in terms of real-time data interaction, protection logic transparency, interface standardization, human-computer interaction, etc.Through comparison tests with the actual protection device, the feasibility and accuracy

Fig. 2
Fig. 2 Schematic diagram of data interaction between twin protection and external equipment

Fig. 3
Fig. 3 Schematic diagram of hierarchical modeling of protection logic

Fig. 4
Fig. 4 Schematic diagram of PT disconnection graphical logic construction

Fig. 5 Fig. 6
Fig. 5 Schematic diagram of using Data Store Memory Fig. 8 SCD file root node diagram

Table 1
Data type definition in the FromHMI and ToHMI interface modules