Journal of Modern Power Systems and Clean Energy

ISSN 2196-5625 CN 32-1884/TK

网刊加载中。。。

使用Chrome浏览器效果最佳,继续浏览,你可能不会看到最佳的展示效果,

确定继续浏览么?

复制成功,请在其他浏览器进行阅读

Exploration of Artificial-intelligence Oriented Power System Dynamic Simulators  PDF

  • Tannan Xiao
  • Ying Chen
  • Jianquan Wang
  • Shaowei Huang
  • Weilin Tong
  • Tirui He
the Department of Electrical Engineering, Tsinghua University, Beijing 100084, China; the College of Electrical Engineering, Zhejiang University, Hangzhou 310027, China; Wuxi Power Supply Company of State Grid, Wuxi 214125, China

Updated:2023-03-20

DOI:10.35833/MPCE.2022.000099

  • Full Text
  • Figs & Tabs
  • References
  • Authors
  • About
CITE
OUTLINE

Abstract

With the rapid development of artificial intelligence (AI), it is foreseeable that the accuracy and efficiency of dynamic analysis for future power system will be greatly improved by the integration of dynamic simulators and AI. To explore the interaction mechanism of power system dynamic simulations and AI, a general design for AI-oriented power system dynamic simulators is proposed, which consists of a high-performance simulator with neural network supportability and flexible external and internal application programming interfaces (APIs). With the support of APIs, simulation-assisted AI and AI-assisted simulation form a comprehensive interaction mechanism between power system dynamic simulations and AI. A prototype of this design is implemented and made public based on a highly efficient electromechanical simulator. Tests of this prototype are carried out in four scenarios including sample generation, AI-based stability prediction, data-driven dynamic component modeling, and AI-aided stability control, which prove the validity, flexibility, and efficiency of the design and implementation for AI-oriented power system dynamic simulators.

I. Introduction

POWER system dynamic simulation is still the most reliable and widely used approach for power system stability analysis [

1]. Electric power companies and developers from all over the world have developed many dynamic simulators including electromechanical simulators such as PSASP [2] and PSD-BPA [3] by the China Electric Power Research Institute (CEPRI), PSS/E [3] by Siemens, DSATools [4] by Powertech, DIgSILENT PowerFactory [5] by DIgSILENT GmbH, Eurostag [6] by Tractebel, PYPOWER-Dynamics [7] by Susanto, and STEPS [8] by Shandong University; electromagnetic simulators such as PSCAD/EMTDC [9] by Manitoba and CloudPSS [10] by Tsinghua University; and real-time simulators such as RTDS [11] by Manitoba, HYPERSIM [12] by OPAL-RT, and ADPSS [13] by CEPRI. The commercial simulators are well tested in the practical power systems, which means they support a lot of functions and are very reliable. However, the commercial simulators were usually designed and implemented years ago, which means their architecture might be old and the application programming interfaces (APIs) may be stiff or even be unavailable. Besides, the free and open-source simulators are commonly not as functionally mature as the commercial ones but are much more flexible. The source code can be directly modified, hence APIs can be developed as needed.

Research on artificial intelligence (AI) has achieved a growth spurt in the past few years. AI algorithms such as graph neural networks (GNNs) and reinforcement learning (RL) have been applied to a variety of power system studies such as measurement enhancement [

14], dynamic component modeling [15], parameter inference [16], optimization and control [17], and stability assessment [18]. AI models can learn and approximate any functions with enough samples [19]. AI technology will be more and more important in the research field of power systems, especially with the rapid development of renewable generation and power electronics [20]. The safe and efficient operation of power systems is facing great challenges, e.g., we may need to model new devices to analyze stability although some operation mechanisms of devices are still under research, the dimensionality reduction is needed to scale down the complexity, and the significantly increasing uncertainty of power systems requires fast and flexible stability analysis and control. AI-assisted power system analysis and control might be a solution to these challenges [21], or at least a mitigation measure.

Currently, although some commercial softwares such as DIgSILENT PowerFactory have supported AI applications to a certain extent, the relationship between power system dynamic simulation and AI is still relatively fragmented. The simulator usually works only as a data generator and provides limited prior knowledge, whereas the trained AI model usually works independently as a black-box model with poor interpretability and cannot be easily integrated into simulators. In one word, the simulator is not AI-friendly enough. In [

22], the idea of a learning simulation engine that combines AI and simulation is proposed. Simulation-assisted AI and AI-assisted simulation mutually support each other. With the support of AI, the simulator can evolve autonomously and become more accurate and efficient, which is also crucial to the realization of power system digital twins [23]. In [24], a similar and more comprehensive concept of simulation intelligence is proposed. This can be the future of power system dynamic simulators.

Based on the learning simulation engine proposed in [

22] and the simulation intelligence discussed in [24], we explore the cooperation of AI and power system dynamic simulations in this paper. The contributions are as follows.

1) A general design of an AI-oriented power system dynamic simulator is proposed, which consists of a high-performance simulator with neural network supportability and flexible external and internal APIs. External API-based simulation-assisted AI and internal API-based AI-assisted simulation form a comprehensive interaction mechanism between power system dynamic simulations and AI.

2) A prototype of the proposed design is implemented based on a self-developed power system electromechanical simulator. The efficiency of the simulator is improved by traditional approaches including sparsity techniques, parallel computing, and memory allocation optimization. External and internal APIs are developed with Python and the source code is made public on GitHub, as shown in Supplementary Material A.

3) Four typical cases of utilizing the developed simulator, i.e., sample generation, GNN-based stability prediction, data-driven dynamic component modeling, and RL-based stability control, are illustrated to prove the validity, flexibility, and efficiency of the proposed design and implementation.

The remainder of this paper is as follows. Section II introduces the design of the AI-oriented power system dynamic simulator. The implementation details of a prototype simulator based on the proposed design are illustrated in Section III. In Section IV, the typical examples of the implemented simulator are explained and tested. Conclusions are drawn in Section V.

II. Design of AI-oriented Power System Dynamic Simulator

In Fig. 1, the overall architecture design of the power system dynamic simulator is demonstrated. The idea is intuitive. In order to support the interactions between the simulator and AI model, a reasonable choice is to develop AI-friendly APIs to bridge them. The simulator, APIs, AI models, and power system operator form a bionic interaction mechanism similar to the musculoskeletal system, nerves, spinal cord, and brain. Via the APIs, the simulator can provide massive data and prior knowledge for AI models, whereas AI models mine the data, discover the hidden patterns, and return well-trained models and posterior knowledge. Meanwhile, AI models can provide predictions and suggestions to power system operators based on their demands. Therefore, a closed-loop interaction mechanism is established. With the support of this interaction mechanism, the traditional physics-based simulator and the data-driven AI models can cooperate to achieve the task of data enhancement [

25], awareness enhancement [26], analysis enhancement [27], decision-making enhancement [28], etc., and may finally lead to the creation of a power system digital twin.

Fig. 1  Overall architecture of AI-oriented power system dynamic simulator.

In this section, the designs of the simulator and APIs as well as the interactions between the simulator and AI models are explained in detail.

A. Simulator

Power system dynamic simulators can be used to generate massive scenarios and simulation results, i.e., physics-based data. The general structure of a power system dynamic simulator is presented in Fig. 1, which consists of four parts, i.e., model, parameter, solution, and function. Firstly, a model is needed for each power system component, which can be a physics-based model, a data-driven model, or a physics-data-integrated model. A model conversion function for different models of different simulators is preferred. Secondly, parameters of the selected model need to be measured or estimated, i.e., model calibration [

29] is needed. Thirdly, all the models with parameters are formulated together in a group of high-dimensional equations. Power flow can be solved with the Newton method to obtain the operation state. Power system dynamics are formulated with ordinary differential equations (ODEs) in the electromagnetic simulation and differential-algebraic equations (DAEs) in the electromechanical simulation. They can both be solved with a numerical integration method and a linear solver [30]. Finally, the simulation-based functions are realized based on the solutions of power flow and power system dynamics.

Here are two required features of the simulator to support the integration of simulations and AI models, i.e., rapid simulation speed and neural network supportability.

1) Rapid Simulation Speed

Simulation speed is essentially the basis of AI-assisted power analysis and control system. The training of AI models requires massive data; and the data generation is very time-consuming. The simulation speed is a bottleneck in successfully utilizing AI algorithms and training a model with sufficient performance. Therefore, the simulator must be well optimized and highly efficient. The algorithm-level and task-level parallelisms, which are solution level and function level in Fig. 1, are required to fulfill the efficiency needs in different situations.

2) Neural Network Supportability

Another requirement of the simulator is neural network supportability, i.e., being able to load the structure and parameters of neural networks and perform at least forward propagation of neural networks. The simulator should be able to integrate AI models into any part of the simulator so that the efficiency and accuracy of the simulator can be improved by the cooperation of traditional algorithms and AI.

B. API

Flexible APIs are crucial to the cooperation of power system dynamic simulations and AI models. The APIs of an AI-oriented power system dynamic simulator are divided into external APIs and internal APIs. The external APIs are used to get data and invoke functions of the simulator, whereas the internal APIs are used to modify the data and control the simulation process. Corresponding to the four parts of the simulator shown in Fig. 1, the external and internal APIs can further be divided into four categories, i.e., model APIs, parameter APIs, solution APIs, and function APIs.

External model APIs and parameter APIs are used to output structures and parameters of different models. The model expression should be easy to understand and modify, e.g., diagrams and JSON files. External solution APIs are used to output parameters related to solution methods and intermediate results during the solution process, e.g., the node ordering method, the admittance matrix, the iteration number of the power flow solution, and the integration step. External function APIs are used to invoke functions, e.g., power flow solutions, short-circuit calculations, transient simulations, as well as output required simulation results, e.g., the maximum rotor angle difference, nodal voltages, and currents of transmission lines.

Correspondingly, the internal APIs are used to alter model types, modify parameters, change solution methods, and adjust boundary conditions of functions. Through internal APIs, AI models can be used to model dynamic components, estimate parameters, accelerate solutions, and surrogate functions.

Overall, compared with the APIs of existing commercial simulation tools, the APIs of an AI-oriented power system dynamic simulator make it easy to develop AI models for power system applications and realize the cooperation of traditional algorithms and AI algorithms. More detailed information of the power system components and simulations can be provided to AI models via the external APIs, and AI models can be deeply integrated into power system simulations via the internal APIs. Other suggested features of the APIs are as follows.

1) No Impact on Simulation Efficiency

The implementation of APIs must not affect the efficiency of the simulator. As mentioned before, the simulator focuses on efficiency. The source code is usually written with efficient programming languages such as C++, Java, FORTRAN, i.e., the implementation is highly organized and optimized. It should not be disturbed by the APIs. Therefore, a suggested way is to rewrap the needed internal functions as external functions. These external functions can be invoked by other programming languages.

2) Efficient Memory Exchange

Data are frequently exchanged between the simulator and AI models. Taking neural network based stability prediction as an example, massive samples of tens or even hundreds of gigabytes are generated. The data exchange better happens in RAM instead of on hard drives. If there is not enough RAM, the data could be cut into several pieces and transferred sequentially, or the data could be exchanged using a database.

3) Interpreted Language-written

It is recommended to develop the APIs of an AI-oriented power system dynamic simulator with interpreted languages such as Python. These programming languages are easy to learn and use, and have very mature developer communities. There are a tremendous number of Python-written open-source AI projects on GitHub. With Python APIs, the simulator can be easily modified for AI applications and can cooperate with AI models.

C. Interactions of Dynamic Simulations and AI

In contrast to the simulator, AI produces data-driven models based on the existing data, as illustrated in Fig. 1. Firstly, a training dataset is needed. The quality and representativeness of the samples will seriously affect the performance of AI models. Secondly, a hypothesis set is established, i.e., a learning framework is selected based on the task and the training data. Thirdly, optimization algorithms are utilized to train the model. At last, the final hypothesis, i.e., an AI model, is obtained.

The interactions between the simulator and AI models are further illustrated in Fig. 2. The right part demonstrates simulation-assisted AI and the left part denotes AI-assisted simulation.

Fig. 2  Interactions between simulator and AI models.

1) Simulation-assisted AI

Simulation-assisted AI is realized based on the external APIs. Firstly, simulations can be used to generate dataset. The actual training dataset also needs sample selection or augmentation, e.g., stability prediction needs the simulation results with balanced stability labels. Sampling methods are very important since the data quality determines the performance of AI models [

31]. Secondly, physics-based models can be used as a strong prior knowledge for AI model design. For example, the power network topology can be used to design GNN [18]. Thirdly, physical laws such as conservation laws can be used as constraints in optimization algorithms to limit the feasible region, improve the interpretability of AI models, and speed up the training process [32], [33]. Finally, the simulator can be used as the benchmark for the performance verification of AI models.

2) AI-assisted Simulation

AI-assisted simulation is realized based on the internal APIs. Firstly, data-driven AI models can be used for dynamic component modeling [

15], [34]. Although the model may suffer from the problem of interpretability, the measurement-based AI model can also be accurate and adaptive. Via the internal APIs, physics-based models and data-driven models can be integrated seamlessly and be simulated simultaneously [35]. Secondly, AI models can be used for power system model calibration [36]. Power system dynamic modeling and parameter estimation are facing increasing challenges because of the rapid development of renewable generation and power electronics. Data-driven power system dynamic modeling could be a potential solution. Thirdly, AI models can be used to discover and formulate the hidden patterns in the solution procedures and improve solution efficiency, e.g., convergence prediction of power network equations, variable integration step prediction, and switch state prediction of power electronic devices [37]. Finally, AI models can be used as surrogate models for power system analysis [38] and control [39]. Power system computation can be very time-consuming. Using a surrogate model as an approximation of the actual computation can significantly increase the efficiency of analysis and decision-making.

III. Implementation of AI-oriented Power System Dynamic Simulator

In Fig. 3, a prototype of the AI-oriented power system dynamic simulator explained in the former section is implemented based on a high-performance electromechanical simulator called power system optimal parameter selection (PSOPS). After developing some external functions to support Python APIs, the simulator is compiled as a dynamic link library PSOPS.dll in Windows and a shared object file PSOPS.so in Linux. The Python APIs of the prototype are developed using the ctypes library [

40]. The PSOPS.dll, PSOPS.so, and the open-source Python APIs, can be found in the repository called Py_PSOPS on GitHub. In the Python APIs, computational functions such as power flow solution and transient simulation have that names the begin with “cal”. The functions with the names that start with “get” and “set” denote the functions of external APIs and internal APIs, respectively.

Fig. 3  Implementation and tests of Py_PSOPS.

In this section, the implementation details of the PSOPS simulator and the APIs are illustrated.

A. Implementation of PSOPS Simulator

PSOPS can perform AC power flow considering PV-PQ switching and electromechanical transient stability simulations. It is developed using C++ based on previous studies [

41]-[44]. Power system dynamics are modeled with a group of high-dimensional nonlinear DAEs. The alternating approach proposed in [45] is adopted in PSOPS due to its simplicity, reliability, and robustness [30].

1) Traditional Techniques for Efficiency Improvement

In PSOPS, traditional algorithms including improved sparsity techniques, improved bordered block diagonal form (BBDF) method, and memory allocation techniques are utilized to accelerate transient simulations.

As for the sparsity techniques, the approximate minimum degree-minimum number of source predecessor (AMD-MNSP) algorithm and the multi-path sparse vector method are utilized to enhance the efficiency of the sparse vector method while maintaining the sparsity of the factorized matrix [

41].

In terms of parallel computing, a fully parallel BBDF method [

42], a fully parallel nested BBDF method [43], and an efficient computing task allocation scheme based on subnet-core mapping and mixed programming of message passing interface (MPI) and OpenMP [44] are adopted to improve the BBDF method at the algorithmic and implementational levels.

As for memory allocation, a node-ordering-based memory allocation technique is utilized, which reorders components such as transmission lines, transformers, generators, and loads based on the node ordering and saves the admittance matrix, the equation coefficient matrix, and the independent vector in a contiguous memory block to increase the cache hit rate when solving power network equations.

In Table I, the basic information and average time consumption of 10 s transient simulations after utilizing the above techniques are presented. The 2383wp system is a widely used test system in MATPOWER, and sys13490 and Sys24886 are two practical power systems. All the dynamic components are modeled in detail. The test HPC platform is Sugon I950r-G installed with 8 Intel Xeon E7-8837 2.67 GHz processors. Each processor is integrated with 8 CPU cores, i.e., the total number of CPU cores is 64. As can be observed, simulations are significantly accelerated.

TABLE I  Basic Information and Average Time Consumption of 10 s Simulations of Three Test Systems

Test

system

Number of componentsTime consumption (s)
BusBranchGeneratorLoadSerialParallel
2383wp 2383 2892 327 1822 2.655 0.365
Sys13490 13490 22544 1797 3550 9.911 0.587
Sys24886 24886 39512 1919 5646 13.525 0.639

2) C++ Libraries for Neural Network Supportability

Meanwhile, neural network supportability is realized using two open-source C++ libraries, i.e., the Eigen library [

46] and the LibTorch library [47]. The difference between the two libraries is the granularity of neural network implementation. As for the Eigen library, neural networks are built in the source code of the PSOPS simulator using the vector class and the matrix class. The structure of neural networks is loaded by reading a JSON file and the parameters are loaded by reading binary files saved by PyTorch [48]. Besides, the neural modules saved by PyTorch, i.e., both the structures and the parameters, are directly loaded for the LibTorch library. The Eigen library is computationally more efficient but structural changes of neural networks require the modification of the source code of PSOPS, whereas the LibTorch library is simpler to use but the computation speed is lower than the Eigen library. Therefore, the LibTorch library is recommended for model evaluation and the Eigen library is recommended for model deployment. By changing the version of LibTorch, Py_PSOPS can adapt to different versions of PyTorch.

As mentioned before, neural network supportability makes it possible to integrate AI with traditional simulations. Currently, the integration and simultaneous simulations of AI-based power system dynamic models and physics-based models have been realized in PSOPS. Other applications of AI-assisted simulations are still under development.

B. Implementation of APIs

As shown in Fig. 3, the PSOPS simulator is compiled as a dynamic link library file PSOPS.dll in Windows and a shared object file PSOPS.so in Linux. Only the external functions, which are realized by rewrapping the models and functions of PSOPS, can be accessed. The external functions of PSOPS and the Python APIs are connected using the ctypes library.

The Python APIs load the external functions from PSOPS.dll and PSOPS.so and reorganize the data into a NumPy [

49] style. The source code is organized in a component-based manner, which means the functions of the same kind of component are put together. The Python APIs can be extended easily to fulfill the needs in different situations. A more well-rounded API will be a future working direction. The details of external and internal model APIs, parameter APIs, solution APIs, and function APIs are as follows.

1) Model API

As mentioned before, when using the Eigen library, the structure of neural networks can be established in the simulator by modifying the basic computation data file and reading a JSON file containing the names and structure of layers of the neural network. When using the LibTorch library, the whole neural model can be established by directly loading the modules saved by PyTorch.

2) Parameter API

The parameters of components such as the name, the total number, the constraints, the default settings, the dynamic model parameters, and the connectivity, can be got or set. However, currently, the parameters of neural networks are directly loaded by the simulator via modifying the basic computation data file and reading a binary file.

3) Solution API

The intermediate results during simulation processes can be obtained. The simulated power system can be set to states at any integration step. Basic data of the solutions such as the iteration number, the simulation time, the integration step, faults, and disturbances can be accessed. More importantly, the network topology accessibility is realized. Network topology data such as the admittance matrix, the impedance matrix, the number of fill-ins, and the factorized lower and upper triangular matrices can be obtained. The connectivity of each component, i.e., whether the component is connected to the power network, can be changed and the network connectivity check is supported, i.e., asynchronous subsystems can be identified. Other settings such as power flow solution methods, integration methods, node ordering algorithms, and sparse vector methods can be modified by changing the basic computation data file.

4) Function API

The function API supports calling power flow solutions and transient stability simulations and gets simulation results including rotor angles, rotation speed, inner electric potential, active and reactive power, outputs of regulators, nodal voltages, etc. Meanwhile, the task-level parallelism is realized using the ray library [

50] of Python.

IV. Case Studies

In this section, four typical cases of utilizing the prototype, i.e., sample generation, spatiotemporal graph convolutional networks (STGCN) based stability prediction, NODE-based [

51] power system dynamic component modeling, and RL-based stability-constrained optimal power flow (SOPF), are demonstrated to show the interactions between simulator and AI models based on Py_PSOPS, as shown in Fig. 3. Sample generation is one of the most basic applications of Py_PSOPS. The STGCN-based stability prediction, the NODE-based dynamic modeling, and the RL-based SOPF are typical examples of simulation-assisted AI, AI-assisted simulation, and mutual assistance between simulation and AI, respectively. More applications can be developed using Py_PSOPS. All four cases are supported by at least one paper or open-source code we developed on GitHub. The success of these tasks proves the validity, flexibility, and efficiency of the design and implementation.

The test system is the IEEE 39-bus system. The high-performance server used for testing consists of an NVIDIA P100 GPU, 250 gigabytes of RAM, and two Intel Xeon Gold 5118 processors, which contain 24 CPU cores in total and the hyperthreading is enabled, i.e., there are up to 48 threads available.

A. Sample Generation

1) Stepwise Power Flow Sampling Scheme

Sample generation can be used for any AI application. It is supported by the rapid simulation speed of PSOPS. As for power flow sampling, simple random sampling, grid sampling, and a stepwise power flow sampling scheme are implemented. The pseudo-code of the stepwise power flow sampling scheme is shown as follows.

Pseudo-code 1: stepwise power flow sampling scheme

Input the total number of required samples N

Set n=1

Get the limits of PD, QD, PG, and VG using external parameter APIs

While n<N

Set the connectivity states of all the transmission lines to be true using internal solution APIs

Set the connectivity state of one or two randomly chosen transmission lines to be false using internal solution APIs

Set PD and QD randomly within limits using internal parameter APIs

Calculate sum(PD)

Do

Set PG randomly within limits using internal parameter APIs

Until sum(PG)+sum(P̲Slack)<sum(PD)<sum(PG)+sum(P¯Slack)

Set VG randomly within limits using internal parameter APIs

Calculate power flow using external function APIs

Get power flow convergence using external solution APIs

If power flow calculation converges

Save (PD, PG,VG)

Set nn+1

End if

End while

In pseudo-code 1, PD and QD are the active power vector and reactive power vector of loads, respectively; sum() denotes the sum of elements in the vector; PG is the active power vector of generators; P¯Slack and P̲Slack are the upper limit vector and the lower limit vector of slack generators, respectively; and VG is the nodal voltage vector of generators other than slack generators.

After power flow sampling, contingencies are sampled by randomly choosing a component, a fault type, a fault location, and a fault clearing time. Transient simulations of these contingencies are carried out to generate simulation samples.

2) Test Results

The source code of the proposed sampling scheme can be found on GitHub in the Py_PSOPS repository. On the test server, over 1.29 million power flow samples and over 50 million simulation samples of the IEEE 39-bus system are generated using 40 threads within 9 hours. This sample dataset is used to support the research on STGCN and NODE.

B. STGCN-based Stability Prediction

This is a typical example of simulation-assisted AI. The simulator provides training data as well as prior knowledge to support AI model design.

1) STGCN

An STGCN-based stability prediction model is proposed in [

52]. The idea is to predict transient stability based on the power network changes and state variable changes within a short time after faults occur. The STGCN can extract features from these changes and learn the correlation of these changes with power system stability. Only a short-time simulation is required, and the efficiency of stability analysis can be improved.

The implementation is supported by the network topology accessibility of Py_PSOPS. The STGCN-based stability prediction model is shown in Fig. 4. Each STGCN layer is composed of a one-dimensional convolutional neural network (1D-CNN) layer, a graph convolutional network (GCN) layer, and another 1D-CNN layer. The input of the (l+1)th layer of STGCN is the feature vector fl and the admittance matrix Y, and the output is fl+1. The input features include Y0, Y1, and Y2, i.e., the admittance matrices before the fault, during the fault, and after clearing the fault, respectively, which can be obtained via external solution APIs, and f0,f1,...,fn, i.e., temporal data of selected state variables obtained by a short-time simulation from t=0 to t=T, which can be obtained using external function APIs. The fault is cleared at the time instant t=tc. The total number of sampling instants is n. The output of the model is the predicted stability label of the input cases.

Fig. 4  Architecture of STGCN-based stability prediction model.

After training, the STGCN model and the transient simulation function of the Py_PSOPS can be integrated using APIs and perform efficient transient stability analysis. The pseudo-code of training an STGCN model and integrating the STGCN model with transient simulations is as follows.

2) Test Results

The STGCN-based stability prediction model is trained. Samples in the training dataset are randomly selected in the sample dataset. The training dataset contains 10240 samples, whereas the testing dataset contains 33600 samples. The comparison results of the STGCN model, the convolutional neural network (CNN) model, the long short-term memory (LSTM) model, and the multi-layer perceptron (MLP) model are displayed in Fig. 5, where accuracy, precision, recall, and f1-score are the commonly used indices for evaluating the performance of neural networks [

52]. Each time of STGCN-based stability prediction averagely costs 5 ms, whereas the complete simulation averagely costs 25 ms.

Fig. 5  Results of STGCN, CNN, LSTM, and MLP models.

Pseudo-code 2: STGCN-based stability prediction

Training procedures

Input the total number of training epochs NE, the training dataset, the test dataset, and the mini-batch size m

Initiate the parameters of the STGCN model

Set epoch=1

While epoch<NE

Do

Get m samples from the training dataset

STGCN.forward(m samples)

Calculate the cross-entropy loss

Loss.backward()

Update parameters of STGCN

Until all the samples in the training dataset have been selected

Evaluate the STGCN model in the test dataset

Set epochepoch+1

End while

Integrate the STGCN model and transient simulations

Input the STGCN model, the contingency, the integration step Δt, and the

short simulation time T

Calculate power flow using external function APIs

Set contingency using internal function APIs

Set the integration step to Δt and the simulation time T using internal solution APIs

Perform transient simulations using external function APIs

Get Y0, Y1, Y2, and f0, f1,..., fn using external solution APIs and external function APIs

Stability label = STGCN.forward (Y0, Y1, Y2, f0, f1,..., fn)

C. NODE-based Dynamic Modeling

This is an example of AI-assisted simulation. The trained AI model is integrated into the simulator and is simulated simultaneously with physics-based dynamic models.

1) NODE-based Power System Dynamic Modeling

An NODE-based power system dynamic modeling method is proposed in [

35]. The idea is to build data-driven dynamic models based on NODE and accessible measurement data when there is a lack of prior knowledge of the component, e.g., equivalent modeling of load areas [53] and renewable plants [54]. While learning a global approximation of the derivative functions with easily trainable neural networks, NODE also keeps the classical framework of numerical integration, which is a very important prior knowledge and makes NODE highly adaptive to scientific computations and industrial applications, as shown in (1).

Ψ(x,V;θ)x˙=f(x,V) (1)

where x is the vector of state variables, whose time derivatives are equal to f(x,V); V is the vector of nodal voltages; Ψ is the vector of parametric derivative functions; and θ is the vector of parameters of the parametric derivative functions. After inputting the initial value x=x(0), the variation of x can be calculated with a numerical integration method. The parameters of NODE can be trained using a set of sampled curves of x and V, which can be obtained through external APIs. The loss function is the mean squared error between the predicted curves and the ground-truth curves of x.

After training, the NODE-based dynamic models are directly integrated with physics-based models and transient simulations are carried out to verify the efficacy of the neural model. The pseudo-code of training an NODE-based power system dynamic modeling is as follows.

Pseudo-code 3: NODE-based power system dynamic modeling

Training procedures

Input the total number of training epochs NE as well as the training and test datasets that contain {x̂(ti),V̂(ti)},i{0,1,...,n}, i.e., the ground- truth values of x and V at time instant t=ti

Initiate the parameters of the NODE model

Set epoch=1

While epoch<NE

Do

Get a sample {x̂(ti),V̂(ti)},i{0,1,...,n} from the training dataset

Set x=x̂(t0) and V=V̂(t0)

for i{1,2,...,n}

x(ti)=x(ti-1)+(ti-ti-1)NODE.forward(x(ti-1),V̂(ti-1))

End for

Calculate the mean squared loss between x and x̂

Loss.backward()

Update the parameters of the NODE model

Until all the samples in the training dataset have been selected

Evaluate the NODE model in the test dataset

Set epochepoch+1

End while

NODE model-integrated transient simulation

Input the NODE model, the contingency, the integration step Δt, and the simulation time T

Set the component model to be the NODE model using internal model APIs

Calculate power flow using external function APIs

Set contingency using internal function APIs

Set the integration step to be Δt and the simulation time to be T using internal solution APIs

Transient simulate using external function APIs

2) Test Results

The source code of common NODE modules for power system dynamic modeling is developed and published on GitHub, as shown in Supplementary Material A. A test case of modeling a generator with the published NODE module is conducted. The generator at bus 31 is modeled with the classical generator model. There are 3200 samples in the training dataset and 800 samples in the test dataset. Samples are randomly selected in the sample dataset including stable contingencies and unstable contingencies. The neural model is trained using only the state variables before the maximum rotor angle difference exceeds 360°.

After training, the NODE-based dynamic model is integrated into the simulator using the LibTorch Library. The comparative results of classical generator model-based simulations and NODE model-integrated simulations under stable and unstable contingencies are shown in Fig. 6, where Δδ is the rotor angle difference between generators at buses 31 and 39; Cal Diff. denotes the difference between the results obtained by the original model and the NODE-based model; and abs(Diff.) denotes the absolution value of the difference. As can be observed, the modeling errors are within an acceptable range.

Fig. 6  Comparative results of classical generator model-based simulations and NODE model-integrated simulations under stable and unstable contingencies. (a) Stable contingency. (b) Unstable contingency.

D. RL-based SOPF

This is an example of the simulator and AI mutually assisting each other.

1) Framework Design

SOPF is one of the traditional control problems of power systems. In SOPF formulation, a target function needs to be optimized under the equality constraints of the power flow equations and the DAEs of power system dynamics as well as the inequality constraints of static security constraints and dynamic security constraints [

55], [56]. RL can solve this problem in a simulation-based optimization manner, as shown in Fig. 7. Based on OpenAI Gym [57] and Py_PSOPS, an environment of SOPF solutions is established, which parses actions and outputs state and reward after performing power flow calculation, transient simulation, and constraints check. An AI-based agent determines actions according to the state. The simulator-based environment and the AI-based agent form an interactive mechanism by exchanging states, rewards, and actions.

Fig. 7  Framework of RL-based SOPF.

After training, the AI-based agent can adjust power flow states rapidly and is suitable for online applications. An RL-based optimal power flow solution method has been proposed in [

58] using PSOPS and the twin-delayed deep deterministic policy gradient (TD3) algorithm [59]. In this paper, a TD3-based SOPF solution program is realized using Py_PSOPS. The reward design is shown in (2).

Reward=-999       Power flow does not convergemax{-999,-500,-50(TE-TS)}                 Any dynamic constraint is violatedmax{-500,-10L(V-PG)}                     Any static constraint is violatedβ-αC     Operating state is secure (2)

where TE is the total simulation time; TS is the time instant when the system loses the stability and is set to be TE if the system remains stable; L(V, PG) is the sum of the out-of-limit parts of V and PG; C is the generation cost; and α and β are the scaling factors. The minimization problem of generation cost is converted to the maximization problem of the reward. The pseudo-code of RL-based SOPF is as follows.

Pseudo-code 4: RL-based SOPF

Input the total number of training epochs NE and anticipated contingencies

Initiate the parameters of the agent

Set epoch=1

While epoch<NE

Reset the operation state using stepwise power flow sampling scheme

Get the original state using external function APIs

Action = Agent.actor.forward(state)

Adopt the action and set the operation state to be the new state using internal parameter APIs

Calculate power flow using external function APIs

Get power flow convergence using external solution APIs

If power flow calculation converges:

Get the new state using external function APIs

Perform transient simulations for the anticipated contingencies using external function APIs

Get the time instants TS using external solution APIs when the system loses the stability

Check constraints using external function APIs

End if

Calculate reward

Update the parameters of the agent based on the original state, the actions, the new state, and the reward

Set epochepoch+1

End while

2) Test Results

The training process of the agent with the TD3 algorithm is demonstrated in Fig. 8. After the agent is trained, further tests are carried out to check the control effectiveness. Fifty thousand power flow samples with dynamic constraint violations are sampled. The agent gets the operation state and outputs the control strategy. The agent costs 122.525 ms, which includes the time consumption of generating a strategy and performing the transient simulation once to check the strategy. After the control, 49602 samples return to safe operation points, whereas 398 samples violate static stability constraints. The success rate is 99.204% and the new operation points are absolutely sure to maintain dynamic security.

Fig. 8  Training process of agent with TD3 algorithm.

V. Conclusion

To conclude, based on the illustration of the interaction mechanism between power system dynamic simulations and AI, an AI-oriented power system transient stability simulator called Py_PSOPS is designed, implemented, tested, and made public. Although it is currently an exploration of AI-oriented power system dynamic simulations, the four test cases demonstrate promising capabilities of Py_PSOPS to support the development of AI-assisted simulations and simulation-assisted AI applications in power system stability analysis and control. It should be noted the development of Py_PSOPS will continue in the future.

References

1

N. Hatziargyriou, J. Milanovic, C. Rahmann et al., “Definition and classification of power system stability,” IEEE Transactions on Power Systems, vol. 36, no. 4, pp. 3271-3281, Jul. 2021. [Baidu Scholar] 

2

Z. Wu and X. Zhou, “Power system analysis software package (PSASP)-an integrated power system analysis tool,” in Proceedings of 1998 International Conference on Power System Technology, Beijing, China, Aug. 1998, pp. 7-11. [Baidu Scholar] 

3

H. Song, R. Na, S. Ting et al., “Study on conversion between the common models of PSD-BPA and PSS/E,” in Proceedings of 2013 IEEE 11th International Conference on Electronic Measurement Instruments, Harbin, China, Aug. 2013, pp. 64-69. [Baidu Scholar] 

4

K. Morison, L. Wang, and P. Kundur, “Power system security assessment,” IEEE Power and Energy Magazine, vol. 2, no. 5, pp. 30-39, Sept. 2004. [Baidu Scholar] 

5

G. Lammert, L. D. P. Ospina, P. Pourbeik et al., “Implementation and validation of WECC generic photovoltaic system models in DIgSILENT PowerFactory,” in Proceedings of 2016 IEEE PES General Meeting (PESGM), Boston, USA, Jul. 2016, pp. 1-5. [Baidu Scholar] 

6

S. Cole and B. Haut, “Robust modeling against model-solver interactions for high-fidelity simulation of VSC HVDC systems in EUROSTAG,” IEEE Transactions on Power Systems, vol. 28, no. 3, pp. 2632-2638, Aug. 2013. [Baidu Scholar] 

7

J. Susanto. (2021, Jan.). PYPOWER-Dynamics. [Online]. Available: https://github.com/susantoj/PYPOWER-Dynamics [Baidu Scholar] 

8

C. Li, Y. Wu, H. Zhang et al., “STEPS: a portable dynamic simulation toolkit for electrical power system studies,” IEEE Transactions on Power Systems, vol. 36, no. 4, pp. 3216-3226, Jul. 2021. [Baidu Scholar] 

9

J. Xu, C. Zhao, W. Liu et al., “Accelerated model of modular multilevel converters in PSCAD/EMTDC,” IEEE Transactions on Power Delivery, vol. 28, no. 1, pp. 129-136, Jan. 2013. [Baidu Scholar] 

10

Y. Liu, Y. Song, Z. Yu et al., “Modeling and simulation of hybrid AC-DC system on a cloud computing based simulation platform–cloudPSS,” in Proceedings of 2018 2nd IEEE Conference on Energy Internet and Energy System Integration (EI2), Beijing, China, Oct. 2018, pp. 1-6. [Baidu Scholar] 

11

R. Kuffel, J. Giesbrecht, T. Maguire et al., “RTDS–a fully digital power system simulator operating in real time,” in Proceedings of 1995 International Conference on Energy Management and Power Delivery EMPD’95, Singapore, Nov. 1995, pp. 498-503. [Baidu Scholar] 

12

A. Kumar, A. Bahjaoui, S. K. Musunuri et al., “Design and tuning of multi-band based power system stabilizer and implementation in HYPERSIM,” in Proceedings of 2019 20th International Conference on Intelligent System Application to Power Systems (ISAP), New Delhi, India, Dec. 2019, pp. 1-6. [Baidu Scholar] 

13

Y. Wang, S. Xu, Y. Xu et al., “The research and implementation of power CPS simulation platform based on ADPSS,” in Proceedings of The 16th IET International Conference on AC and DC Power Transmission (ACDC 2020), virtual meeting, Jul. 2020, pp. 706-711. [Baidu Scholar] 

14

Z. Wang, Y. Chen, S. Huang et al., “Temporal graph super resolution on power distribution network measurements,” IEEE Access, vol. 9, pp. 70628-70638, May 2021. [Baidu Scholar] 

15

Y. Zhou and P. Zhang, “Neuro-reachability of networked microgrids,” IEEE Transactions on Power Systems, vol. 37, no. 1, pp. 142-152, Jan. 2022. [Baidu Scholar] 

16

R. Nagi, X. Huan, and C. Chen, “Bayesian inference of parameters in power system dynamic models using trajectory sensitivities,” IEEE Transactions on Power Systems, vol. 37, no. 2, pp. 1253-1263, Mar. 2021. [Baidu Scholar] 

17

H. Nie, Y. Chen, Y. Song et al., “A general real-time OPF algorithm using DDPG with multiple simulation platforms,” in Proceedings of 2019 IEEE Innovative Smart Grid TechnologiesAsia (ISGT Asia), Chengdu, China, May 2019, pp. 3713-3718. [Baidu Scholar] 

18

J. Huang, L. Guan, Y. Su et al., “System-scale-free transient contingency screening scheme based on steady-state information: a pooling-ensemble multi-graph learning approach,” IEEE Transactions on Power Systems, vol. 37, no. 1, pp. 294-305, Jan. 2022. [Baidu Scholar] 

19

K. Hornik, M. Stinchcombe, and H. White, “Multilayer feedforward networks are universal approximators,” Neural Networks, vol. 2, no. 5, pp. 359-366, Jan. 1989. [Baidu Scholar] 

20

K. Sun, H. Xiao, J. Pan et al., “Cross-seam hybrid MTDC system for integration and delivery of large-scale renewable energy,” Journal of Modern Power Systems and Clean Energy, vol. 9, no. 6, pp. 1352-1362, Nov. 2021. [Baidu Scholar] 

21

A. U. Rehman, T. T. Lie, B. Valles et al., “Comparative evaluation of machine learning models and input feature space for non-intrusive load monitoring,” Journal of Modern Power Systems and Clean Energy, vol. 9, no. 5, pp. 1161-1171, Sept. 2021. [Baidu Scholar] 

22

L. von Rueden, S. Mayer, R. Sifa et al., “Combining machine learning and simulation to a hybrid modelling approach: current and future directions,” in Proceedings of 2020 18th International Symposium on Intelligent Data Analysis (IDA 2020), Konstanz, Germany, Apr. 2020, pp. 548-560. [Baidu Scholar] 

23

H. Pan, Z. Dou, Y. Cai et al., “Digital twin and its application in power system,” in Proceedings of 2020 5th International Conference on Power and Renewable Energy (ICPRE), Shanghai, China, Sept. 2020, pp. 21-26. [Baidu Scholar] 

24

A. Lavin, H. Zenil, B. Paige et al. (2021, Dec.). Simulation intelligence: towards a new generation of scientific methods. [Online]. Available: https://arxiv.org/abs/2112.03235v1 [Baidu Scholar] 

25

L. Zhu, D. Hill, and C. Lu, “Semi-supervised ensemble learning framework for accelerating power system transient stability knowledge base generation,” IEEE Transactions on Power Systems, vol. 37, no. 3, pp. 2441-2454, May 2022. [Baidu Scholar] 

26

Y. Chen, H. Chen, Y. Jiao et al., “Data-driven robust state estimation through off-line learning and on-line matching,” Journal of Modern Power Systems and Clean Energy, vol. 9, no. 4, pp. 897-909, Jul. 2021. [Baidu Scholar] 

27

C. Ren, Y. Xu, and R. Zhang, “An interpretable deep learning method for power system dynamic security assessment via tree regularization,” IEEE Transactions on Power Systems.doi: 10.1109/TPWRS.2021.3133611 [Baidu Scholar] 

28

J. Liu, Z. Yang, J. Zhao et al., “Explicit data-driven small-signal stability constrained optimal power flow,” IEEE Transactions on Power Systems. doi: 10.1109/TPWRS.2021.3135657 [Baidu Scholar] 

29

F. Ding, J. Pan, A. Alsaedi et al., “Gradient-based iterative parameter estimation algorithms for dynamical systems from observation data,” Mathematics, vol. 7, no. 5, p. 428, May 2019. [Baidu Scholar] 

30

P. Kundur, N. J. Balu, and M. G. Lauby. Power System Stability and Control. New York: McGraw-hill, 1994, pp. 836-872. [Baidu Scholar] 

31

Y. Zhang, H. Cui, J. Liu et al., “Encoding frequency constraints in preventive unit commitment using deep learning with region-of-interest active sampling,” IEEE Transactions on Power Systems, vol. 37, no. 3, pp. 1942-1955, May 2022. [Baidu Scholar] 

32

B. Lusch, J. N. Kutz, and S. L. Brunton, “Deep learning for universal linear embeddings of nonlinear dynamics,” Nature Communications, vol. 9, no. 1, p. 4950, Nov. 2018. [Baidu Scholar] 

33

X. Hu, H. Hu, S. Verma et al., “Physics-guided deep neural networks for power flow analysis,” IEEE Transactions on Power Systems, vol. 36, no. 3, pp. 2082-2092, May 2021. [Baidu Scholar] 

34

L. D. P. Ospina, V. U. Salazar, and D. P. Ospina, “Dynamic equivalents of nonlinear active distribution networks based on Hammerstein-Wiener models: an application for long-term power system phenomena,” IEEE Transactions on Power Systems. doi: 10.1109/TPWRS.2022.3153117 [Baidu Scholar] 

35

T. Xiao, Y. Chen, S. Huang et al. (2022, Apr.). Feasibility study of neural ODE and DAE modules for power system dynamic component modeling. [Online]. Available: http://arxiv.org/abs/2110.12981 [Baidu Scholar] 

36

Z. Bi, F. Wang, and C. Liu, “Getting parameters in power systems based on adaptive linear neural network,” in Proceedings of The 2006 IEEE International Joint Conference on Neural Network Proceedings, Vancouver, Canada, Jul. 2006, pp. 1458-1462. [Baidu Scholar] 

37

K. Wang, W. Wei, S. Gao et al., “Parametric average-value modeling of diode rectifier systems based on neural network,” in Proceedings of 2022 4th Asia Energy and Electrical Engineering Symposium (AEEES), Chengdu, China, Mar. 2022, pp. 609-613. [Baidu Scholar] 

38

L. Zhu, D. J. Hill, and C. Lu, “Hierarchical deep learning machine for power system online transient stability prediction,” IEEE Transactions on Power Systems, vol. 35, no. 3, pp. 2399-2411, May 2020. [Baidu Scholar] 

39

I. I. Avramidis, F. Capitanescu, S. Karagiannopoulos et al., “A novel approximation of security-constrained optimal power flow with incorporation of generator frequency and voltage control response,” IEEE Transactions on Power Systems, vol. 36, no. 3, pp. 2438-2447, May 2021. [Baidu Scholar] 

40

Python. (2022 Jul.). Ctypes. [Online]. Available: https://docs.python.org/3/library/ctypes.html [Baidu Scholar] 

41

T. Xiao, J. Wang, Y. Gao et al., “Improved sparsity techniques for solving network equations in transient stability simulations,” IEEE Transactions on Power Systems, vol. 33, no. 5, pp. 4878-4888, Sept. 2018. [Baidu Scholar] 

42

T. Xiao, W. Tong, and J. Wang, “A new fully parallel BBDF method in transient stability simulations,” IEEE Transactions on Power Systems, vol. 35, no. 1, pp. 304-314, Jan. 2020. [Baidu Scholar] 

43

T. Xiao, W. Tong, J. Wang et al., “A fully parallel nested BBDF method for power system transient stability simulations,” in Proceedings of 2021 IEEE PES General Meeting (PESGM), Washington DC, USA, Jul. 2021, pp. 1-5. [Baidu Scholar] 

44

T. Xiao, W. Tong, and J. Wang, “Study on reducing the parallel overhead of the BBDF method for power system transient stability simulations,” IEEE Transactions on Power Systems, vol. 35, no. 1, pp. 539-550, Jan. 2020. [Baidu Scholar] 

45

H. W. Dommel and N. Sato, “Fast transient stability solutions,” IEEE Transactions on Power Apparatus and Systems, vol. 91, no. 4, pp. 1643-1650, Jul. 1972. [Baidu Scholar] 

46

Eigen. (2022, Jan.). [Online]. Available: https://eigen.tuxfamily.org/dox/ [Baidu Scholar] 

47

PyTorch. (2022, Jan.). PyTorch C++ API. [Online]. Available: https://pytorch.org/cppdocs/ [Baidu Scholar] 

48

Pytorch. (2022, Jul.). Pytorch/pytorch. [Online]. Available: https://github.com/pytorch/pytorch [Baidu Scholar] 

49

Numpy. (2022, Jul.). Numpy/numpy. [Online]. Available: https://github.com/numpy/numpy [Baidu Scholar] 

50

Ray. (2022, Jul.). [Online]. Ray-project/ray. Available: https://github.com/ray-project/ray [Baidu Scholar] 

51

R. T. Q. Chen, Y. Rubanova, J. Bettencourt et al., “Neural ordinary differential equations,” Advances in Neural Information Processing Systems, vol. 31, pp. 6571-6583, Nov. 2018. [Baidu Scholar] 

52

Y. Zhuang, T. Xiao, L. Cheng et al., “Transient stability assessment of power system based on spatio-temporal graph convolutional networks,” Automation of Electric Power Systems, vol. 46, no. 11, pp. 11-18, Jun. 2022. [Baidu Scholar] 

53

A. Arif, Z. Wang, J. Wang et al., “Load modeling—a review,” IEEE Transactions on Smart Grid, vol. 9, no. 6, pp. 5986-5999, Nov. 2018. [Baidu Scholar] 

54

J. Liu, W. Yao, J. Fang et al., “Stability analysis and energy storage-based solution of wind farm during low voltage ride through,” International Journal of Electrical Power & Energy Systems, vol. 101, pp. 75-84, Oct. 2018. [Baidu Scholar] 

55

S. Abhyankar, G. Geng, M. Anitescu et al., “Solution techniques for transient stability-constrained optimal power flow – part I,” Transmission Distribution IET Generation, vol. 11, no. 12, pp. 3177-3185, Dec. 2017. [Baidu Scholar] 

56

G. Geng, S. Abhyankar, X. Wang et al., “Solution techniques for transient stability-constrained optimal power flow – part II,” Transmission Distribution IET Generation, vol. 11, no. 12, pp. 3186-3193, Dec. 2017. [Baidu Scholar] 

57

G. Brockman, V, Cheung, L. Pettersson et al. (2016, Jun.). OpenAI Gym. [Online]. Available: http://arxiv.org/abs/1606.01540 [Baidu Scholar] 

58

H. Zhen, H. Zhai, W. Ma et al., “Design and tests of reinforcement-learning-based optimal power flow solution generator,” Energy Reports, vol. 8, pp. 43-50, Apr. 2022. [Baidu Scholar] 

59

S. Fujimoto, H. Hoof, and D. Meger, “Addressing function approximation error in actor-critic methods,” in Proceedings of 35th International Conference on Machine Learning, Stockholm, Sweden, Jul. 2018, pp. 1587-1596. [Baidu Scholar]