The User-defined Modeling Method of Power System Components Based on RTDS-CBuilder

This paper puts forward a method to design the user-defined component based on the user-defined modeling environment CBuilder of RTDS simulator. And also develops the user-defined component model with algorithm described by C language, visual graphics appearance, and the component function. And it generates the dynamic link library which has the same execution efficiency as that of the included model of RTDS. This paper takes the IEEE type EXST1 static excitation system as an example to build the user-defined component. The closed-loop tests on the user-defined component and the included one of RTDS are performed to examine the accuracy of the proposed method. By comparison, the test results show that the external characteristics of the user-defined component and the included model of RTDS are basically the same in the initialization process, the step process of the terminal voltage reference value and the case of the large disturbance.


Introduction
New components and system control technique are constantly applied to power system in recent years.The power system simulation technique should be able to flexibility provides various models of system devices, including new regulating, protective devices, etc [1].The model of power system components in simulation tools was coded according to specific algorithms and then packaged, so that the user is not able to alter it [2].Consequently, when the exiting components in software component library are unable to meet the user's actual simulation requirements for primary and secondary equipments or control strategy, it is necessary for the simulation tools to provide the user with a uniform user-defined component modeling platform.Thus it can enrich the models of simulation tools and improve the ability and efficiency of simulations.Reference [3], modeled on the Line traveling wave protection of an actual DC transmission project, and presents a user-defined modeling method based on PSCAD/EMTDC and the application in DC line protection simulation.In order to solve the problem that the default DC transmission model is unable to describe the actual DC transmission feature in electromechanical transient simulation of large-scale AC/DC power system, reference [4] put for-wards the concept of DC system user-defined modeling using PSASP.Reference [5] presented the user-defined modeling method and the procedures of PSS/E in conventional and expanded transient simulation, and a userdefined model of excitation system was then developed.
Among various kinds of power system simulation tools, RTDS is the most general power system real-time digital simulator.Its user-defined modeling function component CBuilder satisfies users' demands for specific models.Reference [6,7] developed the electromechanical transient simulation model and the real-time simulation model of electronic current transducer with the air-core coil respectively.In this paper, the CBuilder modeling principles and process was analyzed and introduced, and the user-defined component model was also built based on the previous work.

RTDS-CBuilder User-defined Modeling Developing Environment
CBuilder implement the user-defined component function by taking C language-like program code as program code.And the CBuilder platform interfaces automatically with RTDS simulation program and user model library.
The user-defined C-like codes implant into the RTDS main function via components, with no need to compile or call the external subprogram frequently [8].
CBuilder user-defined modeling platform mainly include the editing methods such as graphics, parameters, IO Points and C File Associations.These editing methods define the appearance, function parameters, IO Points and mathematical models of user-defined components.Model.cfile program code compiled by the C FILE Associations is the core of the user-defined component.Codes of areas like STATIC、RAM、CODE define and realize the relative component calculation of the s by calculation.It will generate executable files automatically for the user to call after the file was compiled successfully.

RTDS-CBuilder User-defined Modeling Method
In order to build the user-defined component concisely and normatively, the developing process of user-defined component designed in this paper is shown in Figure 1, according to the characteristics of the user-defined modeling platform editing environment.CBuilder function module can build two kinds of models, the power system component and the control component.In most of the simulation test scenes, the existing power system components in RTDS component library can basically satisfy the test requirements.However, with the booming of the new control equipment, the demands to model the control user-defined component in RTDS system gradually increase.Dispensed with network solving, the program code of the control component is much easier in comparison with that of the power system component, and it affects the real-time much lesser.Therefore, this paper takes the IEEE type EXST1 static excitation system of the generator control component as an example and introduces the basic approach for RTDS modeling.

Appearance Design of Component Model
The logic block diagram of the IEEE type EXST1 static excitation system is shown in Figure 2.

Parameters Design of Component Model
The excitation system mainly consists of components such as difference adjustment unit, amplifier unit and amplitude limitation unit [9].As Figure 2 shows, the main parameters inside the IEEE type EXST1 static excitation system is shown in Table 1.
As the reference voltage at the generator terminal ref is an adjustable variable, it should change in line with various power systems operation modes.Therefore, a slider control variable should be set in the C File Associations editing environment, so that it can be called and installed on the RTDS user-defined real time operating and monitor interface RUNTIME.Meanwhile, we set the above internal parameter besides ref in the parameters editing environment of CBuilder.Moreover, we set the parameters including system name, PSS selected variable, monitor internal variable resource allocation of the processor board, etc.Details are shown in   After the above parameters were designed and stored, the parameters will be stored in the C File Associations editing environment of this user-defined component automatically, so that the results can be edited and called by the model.cfile and the model.hfile.

Code Design of Component Model
As Figure 2 shows, the IEEE type EXST1 static excitation system consist of the amplitude limit unit, the transfer function of inertial element, the transfer function actual differentiation element, the add and subtract unit, etc.Two types of these transfer functions can be described as simultaneous of differential equation and algebraic equation in their mathematical models.Yet, solu-tion of the differential equation is particularly significant for the execution efficiency of the component program.For the simulation with microsecond calculation step, it can maintain the stability of the value by using explicit solution.In addition, there is no need to solve the equation, so it reduces the amount of calculation [10].
Therefore, this paper takes the inertial element 1/(1 ) sT  as an example to program it using three explicit solutions.These three solutions for differential equations are shown in Table 2, where R and C are input and output of the equations, T is the time constant, and is the simulation step.

t 
In this section, we build the user-defined component model of inertial element 1/ (1 ) sT  .In the RTDS/Draft file, for the triangular of the included model in RTDS component library and the 3 user-defined component models, which have the input frequency 50 Hz and the amplitude 0.8 pu, we uniformly set the time constant of each component model as 2 s, set the simulation step as 50 μs, and set the relative simulation time as 4 s.We analyze the output data of each model with the simulation time in the vicinity of 4s, as Table 3 shows.
We can see from the above table, while the simulation step is set as 50 μs and the simulation time is set as 4 s, the first 4 significant digits of the simulation results from these three algorithms are the same, and the simulation results are relatively close.Comparatively speaking,

Solutions for differential equations
Explicit solution formula compared with the user-defined component of Mod-Euler and Euler method, the user-defined component using EMTDC algorithm has the simulation results which is closer to that of the transfer function module RTDS comes with.Therefore, in this paper, we solve these 3 types of transfer functions contained in the IEEE type EXST1 static excitation system by using the solutions for differential equations provided by EMTDC.The solution formulas are shown in Table 4 shows, where R and C are input and output of the equation, T is the time constant, and is the simulation step.t  Moreover, the programed methods of the amplitude limit unit and add and subtract unit are comparatively easier, and unnecessary details were given here.According to the format requirements of model.cfile, we edit code in areas such as STATIC, RAM and CODE.As the code in CODE is executed in real time in RTDS, the programming language we wrote should be as efficient as possible [11].For instance, the parameters which do not need to be re-computed can be computed in RAM area, division should be avoided in CODE area, the variable that only be used in CODE area do not need to be declared in STATIC area, etc. Components can right away be called in the RTDS library after compiling.

RTDS-CBuilder User-Defined Model Testing
Static excitation system model in RTDS has already passed the engineering validation and it meets the application requirements of engineering facts.By doing comparison testing using the user-defined model and the RTDS included model, the correctness of the user-defined modeling method presented in this paper can be verified.While there are differences between the userdefined component model and the RTDS included model in terms of the choosing of differential equation algorithm, the processing modes of each unit, etc [12].As the source code of the existing component in the component library is unknown, this paper compares in terms of the differences of external performance between the two models.Closed-loop tests were perform to user-defined component model and RTDS included model by setting up specific scenes of the power grid, to examine whether the external characteristics are identical or not.
In this paper, we use the power system with the typical connection mode of 500 kV auto transformers in the dynamic model test standard of the DL/T871-2004 power system relay protection product as the closed-loop test system.The system have 6 nodes by all, including generator MACH1, infinite source SCR1, infinite source SCR2, 500 kV terminal bus BUS1, high voltage side bus of the main transformer BUS2, medium voltage side bus of the main transformer BUS3, low voltage side bus of the main transformer BUS4, 500 kV terminal bus BUS1 and high voltage side bus of the main transformer BUS2 connected via the 200 km single line TL1.The network topological graph of the closed-loop testing system is shown in Figure 5.
The typical data of IEEE type EXST1 static excitation system of generator MACH1 is shown in Table 5.
The major functions of the excitation system are to provide the excitation source for the generator, stabilize the terminal voltage, demagnetize when the generator shed the load, rapidly and forcibly excite in the case of system disturbances, demagnetize automatically in the case of internal fault of the generator , control the reactive power output of the generator, etc [13,14].Closedloop tests were then perform to the user-defined component and the Module in this paper in 3 conditions, including voltage initialization, the step process of the terminal voltage of generator, large system disturbance, etc.The major parameters of the test consist of terminal voltage of the generator, excitation voltage f E , the reactive power output of the generator 1 MACH
In the process the generator from the end of initialization to the stable state, we need to inspect the establisment of excitation voltage, the stabilizing process of the terminal voltage, etc.The recorded experimental data diagram ( ) As Figure 6 and Figure 7 show, the variation trends of these two parameters of the user-defined component and the Module, excitation voltage and terminal voltage, are generally the same.
2) The step process of terminal voltage reference value The terminal voltage reference value was stepped to a certain multiple of the reference value after the system As Figure 8 and Figure 9 show, the variation trend of the two parameters, the excitation voltage and the reactive power output, are generally the same.
3) The large system disturbance situation When faults occur to the system, there is a shock to the system voltage, so the voltage stability problem is likely to occur.When faults occur to the AC system in the vicinity of the generator, a disturbance is applied to the bus voltage at the generator terminal.As the input of the excitation system, the disturbance signal make the excitation system adjust dynamically, and stabilize the system voltage.
This paper designs the following experimental scenarios.After the system entering the stable state, a three-phase fault with the fault duration time 0.1 s was applied to K1 point which was at the main transformer side of line TL1 and then large disturbance occurred in the system.The recorded experimental data diagram Figure 10 is the excitation voltage and Figure 11 is the   , are basically the same, when the system is in the initialization process, the step process of the terminal voltage reference value, the condition of large disturbance, etc.The error should be in an acceptable regime, in the consideration of the difference of selection of transfer function algorithms, the logical unit processing, etc.Therefore, the user-defined component of the IEEE type EXST1 static excitation system basically meets the test requirements.

Conclusions
This paper introduce the modeling method application of the user-defined modeling module CBuilder using power system real time simulation software RTDS.The model was designed by the user according to the external appearance of power system control component, the input and output and the component parameters.Meanwhile, we edit the internal transfer function and the logic unit using C-like code on the basis of the system logic block diagram.Thus we obtain the user-defined model of the component, and take the IEEE type EXST1 static excitation as an example to perform closed-loop simulation verification.The test results indicate that the component model built on the basis of this method, can well implement the controlling function of the component and satisfy the users' simulation demands for the specific model.Meanwhile, the user-defined modeling module possesses fine man-machine interaction interface, and the userdefined component module it built has the advantage of easily-extension, conciseness, efficiency, etc.

Figure 6
is excitation voltage, Figure 7 is terminal voltage, and the recording time is 20s.The gray curves and is the test results to the user-defined component, and the black curves and is the test results to the Module.

Figure 6 .
Figure 6.Contrast of excitation voltage in initialization.

Figure 7 . 1 of
Figure 7. Contrast of terminal voltage in initialization.

Figure 8 .
Figure 8. Contrast of terminal voltage in initialization.

Figure 9 .Figure 10 .
Figure 9. Contrast of reactive power in step process.

Figure 11 .As Figure 10 and
Figure 11.Contrast of terminal voltage in large disturbance.terminal voltage, with the recording time 5 s.The gray curves , in these figures are test results to the user-defined component, and the black curves , are test results to the Module.( ) f E C V C