A control model automatic generation method and system for PSCAD simulation
By using deep learning technology to automatically identify the structure diagram of the power system control system, an accurate electromagnetic transient simulation model is generated, which solves the problems of low modeling efficiency and insufficient accuracy in existing technologies, and realizes efficient and accurate automatic generation of simulation models and cross-platform compatibility.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHONGQING UNIV OF POSTS & TELECOMM
- Filing Date
- 2026-04-08
- Publication Date
- 2026-06-19
AI Technical Summary
Existing technologies struggle to automatically identify topological relationships from control system structure diagrams and generate accurate electromagnetic transient simulation models of power systems, resulting in low modeling efficiency and a high susceptibility to errors, especially in complex systems where model accuracy and reusability are insufficient.
Deep learning-based target detection technology is used to identify functional modules and connections in the control system structure diagram. The signal flow topology is constructed by combining directed graph theory, and Fortran calculation code and configuration files are automatically generated to ensure the compatibility of the model with the PSCAD simulation platform.
It achieves fully automated generation from control system structure diagrams to executable simulation models, improving modeling efficiency and accuracy, ensuring the accuracy and reusability of simulation models, and supporting cross-platform portability.
Smart Images

Figure CN122240126A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of electromagnetic transient simulation and intelligent modeling technology of power systems, and relates to an automatic generation method and system for control models for PSCAD simulation. Background Technology
[0002] As power systems continue to expand in scale and their control structures become increasingly complex, power system simulation technology is playing an increasingly important role in system planning, design, operation, and control analysis. In practical engineering applications, the standard component libraries built into power system electromagnetic transient simulation software (Power Systems Computer Aided Design, PSCAD) often struggle to accurately describe the internal structure and dynamic characteristics of complex control logic, special control strategies, or novel control devices.
[0003] Currently, the conventional approach to building simulation models of complex control systems based on PSCAD involves engineers manually drawing the simulation circuits based on the control system structure diagram and writing the corresponding Fortran calculation code. This method suffers from high workload and low modeling efficiency. Especially when the system structure is complex or contains multiple feedback loops, errors in model structure or inconsistent parameter settings are easily caused by human misunderstanding or operational negligence, which seriously affects the accuracy and reusability of the simulation model.
[0004] Most existing methods for automatically generating electromagnetic transient simulation models of power systems rely on data conversion from electromechanical transient simulation data or other simulation software model files, establishing model correspondences by parsing existing data formats. However, these methods heavily depend on existing, specific-format simulation data and lack a conversion mechanism that can automatically generate simulation program code directly from the results of analyzing control system structure diagrams. Furthermore, existing image recognition and automatic modeling technologies are primarily geared towards general engineering drawings or circuit schematics. For power system control structure diagrams containing numerous functional modules and complex connections, their recognition accuracy is insufficient, making it difficult to accurately identify equipment and their connections. Particularly for systems with multiple feedback control loops, existing technologies lack the ability to automatically identify signal transmission paths and closed-loop feedback structures. Simultaneously, most existing research focuses on model generation for specific simulation platforms, lacking a unified data expression and interface mechanism, which significantly limits the universality and applicability of model generation methods.
[0005] Therefore, there is an urgent need in this field for a method that can automatically identify system topology relationships from control system structure diagrams and directly generate executable simulation program code, so as to significantly improve the efficiency and automation level of power system electromagnetic transient simulation model construction. Summary of the Invention
[0006] In view of this, the purpose of the present invention is to provide a method and system for automatically generating control models for PSCAD simulation.
[0007] To achieve the above objectives, the present invention provides the following technical solution: An automatic generation method for control models for PSCAD simulation, the method comprising the following steps: S1: Obtain the structural image of the transfer function system, and use a pre-trained deep learning model to detect the structural image of the transfer function system; S2: Read the type, coordinates, and parameter information of the components in the transfer function system structure image; S3: Based on the type, coordinate, and parameter information read in S2, automatically construct a directed signal flow network relationship consisting of the forward propagation path set and the closed path set of the system corresponding to the transfer function system structure image; S4: Based on the directed signal flow network relationship constructed in S3, automatically generate Fortran code segments to describe the system's operational logic and a custom model appearance; S5: Perform semantic parsing, type mapping, and interface encapsulation on the Fortran code segment generated in S4, and compile it to generate a dynamic link library; S6: Automatically integrate the Fortran code segment generated in S4, the custom model appearance, and the path information of the dynamic link library generated in S5 into a configuration file that conforms to the specifications of the power system electromagnetic transient simulation software PSCAD. S7: Automatically generate a Web service interface, which provides the function of uploading the system structure image of the transfer function and the function of downloading the configuration file and the dynamic link library.
[0008] Furthermore, in S1, the pre-trained deep learning model is an object detection model built on a convolutional neural network.
[0009] Furthermore, in step S2, the parameter information is obtained through image text recognition technology; step S2 also includes using a spatial distance-based clustering method to deduplicatize the identified coordinates and integrating all component information into a unified data structure, the data structure including at least a unique module identifier, a module type label, and two-dimensional coordinate information of the module in the transfer function system structure image.
[0010] Furthermore, step S3 includes the following sub-steps: S31: Based on the type, coordinate, and parameter information read in S2, determine the initial connection relationship between the modules connected by arrows in the component, and generate an initial edge set, where nodes correspond to functional modules and edges correspond to signal transmission directions; S32: For module ports that have not established connections, the connection relationships are inferred based on the spatial positional relationships and directional characteristics between modules, and the initial edge set is supplemented and corrected to form a complete set of connection relationships; S33: Construct a directed graph topology based on the complete set of connections. , where the set of nodes Corresponding to the aforementioned functional modules, the edge set E This is the complete set of connection relationships; S34: For the directed graph topology G Graph traversal and path analysis are performed to determine the forward propagation path of the system, and feedback loops that form closed structures are identified through connectivity analysis.
[0011] Furthermore, in S33, the directed graph topology... G The adjacency matrix A is The matrix, matrix elements Defined as:
[0012] in, n The total number of nodes. and For the nodes in the node set V, i and j For node indexing.
[0013] Furthermore, step S4 includes the following sub-steps: S41: Based on the module's mathematical template, discretization strategy, and the forward propagation path and feedback loop node sequence obtained in S3, generate calculation statements and variable declarations in topological order; S42: Generate a state initialization area based on the parameter information read in S2, and generate a signal flow calculation area based on the forward propagation path, replacing the parameters in the mathematical template with the parameter information; S43: For modules with dynamic characteristics, generate corresponding discrete-time state update expressions based on their continuous-time mathematical models.
[0014] Furthermore, step S5 includes the following sub-steps: S51: Perform semantic parsing on the Fortran code segment generated in S4 and construct an intermediate representation, which includes at least a symbol table, control flow relationships, data dependency relationships, and module interface description information; S52: Convert the variable declarations, conditional branches, loop structures, and arithmetic operators in the Fortran code segment into corresponding C language syntax structures, and perform type mapping and encapsulation on function parameters and pointer variables; S53: Generate C language code for static state variable declarations and state update logic; S54: Compile the C language code to generate the dynamic link library.
[0015] Furthermore, in step S6, the configuration file is a file based on the Extensible Markup Language (XML) structure, and its content includes compilation and build logs, simulation view configuration, output measurement variables, and simulation parameters.
[0016] Furthermore, in S7, the Web service interface is implemented based on a client-server architecture, and the Web service interface includes at least an image data receiving module, a code generation and scheduling module, a dynamic link library file distribution module, and a simulation result acquisition module.
[0017] A control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD, the system comprising: The image acquisition and detection module is used to acquire the structure image of the transfer function system and to detect the image using a pre-trained deep learning model. The information reading module is used to read the type, coordinates, and parameter information of the components in the transfer function system structure image; The topology construction module is used to automatically construct a directed signal flow network relationship based on the information read by the information reading module, consisting of the forward propagation path set and the closed path set of the system corresponding to the transfer function system structure image. The code generation module is used to automatically generate Fortran code segments describing the system's operational logic and a custom model appearance based on the directed signal flow network relationship constructed by the topology construction module. The compilation module is used to perform semantic parsing, type mapping, and interface encapsulation on the Fortran code segment generated by the code generation module, and compile it into a dynamic link library; The configuration generation module is used to automatically integrate the Fortran code segment and the custom model appearance generated by the code generation module, as well as the path information of the dynamic link library generated by the compilation module, into a configuration file that conforms to the specifications of the power system electromagnetic transient simulation software PSCAD. The Web service module is used to automatically generate a Web service interface that provides an upload function for the system structure image of the transfer function and a download function for the configuration file and the dynamic link library; The image acquisition and detection module, the information reading module, the topology construction module, the code generation module, the compilation module, the configuration generation module, and the Web service module are connected in sequence.
[0018] The beneficial effects of this invention are as follows: (1) This invention realizes the end-to-end fully automatic generation from control system structure diagram to executable simulation model, transforming the traditional modeling mode that relies heavily on manual drawing and programming into an automated process. This significantly reduces the workload of manual participation and greatly improves the development efficiency of power system controller simulation model.
[0019] (2) By introducing deep learning-based target detection technology to automatically identify the functional modules and connection relationships in the structure graph, and combining it with directed graph theory to construct an accurate signal flow topology, it can completely and accurately restore the complex system structure including the forward channel and feedback loop, effectively avoiding structural errors and ambiguities that may be introduced by manual analysis, thereby improving the accuracy, consistency and reliability of the generated model from the root.
[0020] (3) This invention ensures seamless compatibility between the generated simulation model and the official simulation platform in terms of computational logic and interface specifications by automatically generating Fortran calculation code conforming to PSCAD specifications from the identification results, compiling it into a dynamic link library, and packaging it into a complete project configuration file. This method not only guarantees the numerical accuracy of the simulation results, but also makes the model have good reusability and cross-platform portability potential.
[0021] Other advantages, objectives, and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination, or may be learned from practice of the invention. The objectives and other advantages of the invention can be realized and obtained through the following description. Attached Figure Description
[0022] To make the objectives, technical solutions, and advantages of the present invention clearer, the preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein: Figure 1 This is a schematic diagram illustrating the overall process of automatic generation of a PSCAD simulation model from structural image input according to the present invention. Figure 2 This is the control block diagram of the excitation system; Figure 3 The F1-confidence curve of the yolov8n_train model; Figure 4 The target detection results for each functional module in the system architecture diagram; Figure 5 This is a custom model structure diagram of the excitation control system in the PSCAD platform; Figure 6 A comparison chart of the model's predicted image and a traditional custom PSCAD simulation model. Detailed Implementation
[0023] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0024] The accompanying drawings are for illustrative purposes only and are schematic diagrams, not actual pictures. They should not be construed as limiting the invention. To better illustrate the embodiments of the invention, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0025] In the accompanying drawings of the embodiments of the present invention, the same or similar reference numerals correspond to the same or similar components. In the description of the present invention, it should be understood that if terms such as "upper," "lower," "left," "right," "front," and "rear" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the terms used to describe positional relationships in the drawings are only for illustrative purposes and should not be construed as limiting the present invention. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.
[0026] like Figure 1 As shown in the diagram, the overall process of this invention from structural image input to automatic generation of PSCAD simulation model includes the following steps: (1) Before implementing this example, it is necessary to train a deep learning object detection model. The training process consists of the following sub-steps: (1.1) Construct a training dataset, which is derived from publicly available computerized block diagram (CBD) image sets or manually collected images of engineering control models. The collected images are labeled, and some of the type labels are shown in Table 1.
[0027] Table 1 Component Type Label Table
[0028] (1.2) Write the dataset configuration file and training parameter configuration; (1.3) Through multiple rounds of iterative training, and by evaluating and comparing the performance of different training versions of the model, the convergence state and target detection performance of the model can be intuitively reflected. The target detection model is based on a convolutional neural network and can locate and classify functional modules in the system structure diagram. The performance indicators of various models are shown in Table 2.
[0029] Table 2 Comparison of Key Assessment Indicators
[0030] The results show that yolov8n_train has the best performance, with mAP50 close to 0.95 and mAP50-95 reaching 0.73. It also has the highest detection accuracy and localization accuracy. Its training metrics are as follows: Figure 2 As shown in Table 1, the labels it identifies are as follows.
[0031] (2) Use the trained deep learning object detection model to detect the transfer function structure image. The specific steps are as follows: (2.1) Obtain the system structure image of the transfer function to be processed. The control block diagram of the excitation system is as follows: Figure 3 As shown, its image contains multiple functional modules and their connection relationships, used to describe the dynamic structure of the excitation system; (2.2) The acquired system structure image is automatically identified using a pre-trained deep learning object detection model. The predicted structure is as follows: Figure 4 As shown in Table 1, the corresponding labels identified by the system are shown in Table 1.
[0032] (2.3) Through target detection processing, the location information and category labels of each module in the image are obtained and converted into a unified module description form. Each module includes at least a module type identifier, spatial location information and associated parameter type information, providing basic data support for subsequent topology construction and numerical modeling.
[0033] (3) After completing the detection of each module in the system structure diagram, the detection results of step (2) are standardized to construct a system module information set. For these module information sets, it is necessary to analyze the spatial relative positions, arrow directions and connection rules between modules to automatically generate the signal flow relationship between modules, and express the system structure in the form of a directed graph to further construct the directed topology of the system.
[0034] During the topology construction process, a multi-strategy fusion approach is adopted to improve the robustness of connection relationship identification, automatically identify the signal transmission path and existing feedback loop structure of the system, thereby completely restoring the closed-loop control logic of the system.
[0035] (4) After obtaining the directed signal flow network relationship information consisting of the forward propagation path and the closed path set of the system, the automatic generation stage of the numerical calculation model is entered. In this embodiment, the trapezoidal integral method is used to discretize the continuous-time transfer function in the system. For each module, the corresponding mathematical expression is called from the template library, and the parameters are filled and the signals are bound according to the module parameters and the source of the input signal. Some of the calculation logic is shown in Table 3.
[0036] Table 3. Mapping Correspondence between Module Types and Mathematical Templates
[0037] (5) After generating the Fortran numerical code, the code is further converted into numerical computation functions in C language. During the conversion process, the variable definitions, state storage methods, and computation flow in Fortran are semantically parsed and mapped to equivalent C language data structures and computational logic. By setting the system state variables to static storage, the generated C function can maintain the continuity of the simulation state during multiple calls. Subsequently, the C function is compiled using a compilation tool to generate a dynamic link library file that conforms to the PSCAD interface specification, so that the PSCAD simulation platform can call it during the simulation process.
[0038] (6) After the dynamic link library is generated, this embodiment automatically generates the corresponding simulation configuration file according to the PSCAD project structure requirements. The configuration file is used to describe information such as module parameters, external function interfaces and dynamic library loading paths in the simulation model, so as to realize the automated construction of the PSCAD project.
[0039] (7) In the Web service interaction interface, users upload the system structure diagram through a graphical interface. The structure diagram generates code in the backend. Users can download the XML configuration file that conforms to the PSCAD project content and open the resulting custom model in PSCAD software, such as... Figure 5 As shown.
[0040] (8) In the PSCAD engineering environment, an excitation system model consistent with the equivalent closed-loop transfer function is built using traditional modeling methods, and the same parameters are selected for simulation calculation. The output results of this model are compared with the response results of the excitation system model automatically generated by the method of this invention. The comparison results are as follows: Figure 6 As shown.
[0041] The comparison results show that the excitation voltage output response curves obtained by the two methods are basically the same, which verifies the correctness and effectiveness of the model generated by the present invention in terms of dynamic characteristics and voltage regulation performance, and can meet the application requirements of electromagnetic transient simulation of power systems.
[0042] Through the above implementation methods, the present invention realizes a complete automated process from understanding the system structure diagram, topology modeling, numerical code generation to constructing an executable simulation model, which has good engineering practicality and promotion value.
[0043] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for automatically generating control models for PSCAD simulation, characterized in that: The method includes the following steps: S1: Obtain the structural image of the transfer function system, and use a pre-trained deep learning model to detect the structural image of the transfer function system; S2: Read the type, coordinates, and parameter information of the components in the transfer function system structure image; S3: Based on the type, coordinate, and parameter information read in S2, automatically construct a directed signal flow network relationship consisting of the forward propagation path set and the closed path set of the system corresponding to the transfer function system structure image; S4: Based on the directed signal flow network relationship constructed in S3, automatically generate Fortran code segments to describe the system's operational logic and a custom model appearance; S5: Perform semantic parsing, type mapping, and interface encapsulation on the Fortran code segment generated in S4, and compile it to generate a dynamic link library; S6: Automatically integrate the Fortran code segment generated in S4, the custom model appearance, and the path information of the dynamic link library generated in S5 into a configuration file that conforms to the specifications of the power system electromagnetic transient simulation software PSCAD. S7: Automatically generate a Web service interface, which provides the function of uploading the system structure image of the transfer function and the function of downloading the configuration file and the dynamic link library.
2. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 1, characterized in that: In S1, the pre-trained deep learning model is an object detection model built on a convolutional neural network.
3. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 2, characterized in that: In step S2, the parameter information is obtained through image text recognition technology; step S2 also includes using a spatial distance-based clustering method to deduplicate the identified coordinates and integrating all component information into a unified data structure, the data structure including at least a unique module identifier, a module type label, and two-dimensional coordinate information of the module in the transfer function system structure image.
4. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 1, characterized in that: S3 includes the following sub-steps: S31: Based on the type, coordinate, and parameter information read in S2, determine the initial connection relationship between the modules connected by arrows in the component, and generate an initial edge set, where nodes correspond to functional modules and edges correspond to signal transmission directions; S32: For module ports that have not established connections, the connection relationships are inferred based on the spatial positional relationships and directional characteristics between modules, and the initial edge set is supplemented and corrected to form a complete set of connection relationships; S33: Construct a directed graph topology based on the complete set of connections. , where the set of nodes Corresponding to the aforementioned functional modules, the edge set E This is the complete set of connection relationships; S34: For the directed graph topology G Graph traversal and path analysis are performed to determine the forward propagation path of the system, and feedback loops that form closed structures are identified through connectivity analysis.
5. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 4, characterized in that: In S33, the directed graph topology G The adjacency matrix A is The matrix, matrix elements Defined as: in, n The total number of nodes. and For the nodes in the node set V, i and j For node indexing.
6. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 1, characterized in that: S4 includes the following sub-steps: S41: Based on the module's mathematical template, discretization strategy, and the forward propagation path and feedback loop node sequence obtained in S3, generate calculation statements and variable declarations in topological order; S42: Generate a state initialization area based on the parameter information read in S2, and generate a signal flow calculation area based on the forward propagation path, replacing the parameters in the mathematical template with the parameter information; S43: For modules with dynamic characteristics, generate corresponding discrete-time state update expressions based on their continuous-time mathematical models.
7. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 1, characterized in that: S5 includes the following sub-steps: S51: Perform semantic parsing on the Fortran code segment generated in S4 and construct an intermediate representation, which includes at least a symbol table, control flow relationships, data dependency relationships, and module interface description information; S52: Convert the variable declarations, conditional branches, loop structures, and arithmetic operators in the Fortran code segment into corresponding C language syntax structures, and perform type mapping and encapsulation on function parameters and pointer variables; S53: Generate C language code for static state variable declarations and state update logic; S54: Compile the C language code to generate the dynamic link library.
8. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 1, characterized in that: In step S6, the configuration file is a file based on the Extensible Markup Language (XML) structure, and its content includes compilation and build logs, simulation view configuration, output measurement variables, and simulation parameters.
9. The control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD as described in claim 1, characterized in that: In step S7, the Web service interface is implemented based on a client-server architecture, and the Web service interface includes at least an image data receiving module, a code generation and scheduling module, a dynamic link library file distribution module, and a simulation result acquisition module.
10. A control system modeling method based on deep learning for the power system electromagnetic transient simulation software PSCAD, characterized in that: The system includes: The image acquisition and detection module is used to acquire the structure image of the transfer function system and to detect the image using a pre-trained deep learning model. The information reading module is used to read the type, coordinates, and parameter information of the components in the transfer function system structure image; The topology construction module is used to automatically construct a directed signal flow network relationship based on the information read by the information reading module, consisting of the forward propagation path set and the closed path set of the system corresponding to the transfer function system structure image. The code generation module is used to automatically generate Fortran code segments describing the system's operational logic and a custom model appearance based on the directed signal flow network relationship constructed by the topology construction module. The compilation module is used to perform semantic parsing, type mapping, and interface encapsulation on the Fortran code segment generated by the code generation module, and compile it into a dynamic link library; The configuration generation module is used to automatically integrate the Fortran code segment and the custom model appearance generated by the code generation module, as well as the path information of the dynamic link library generated by the compilation module, into a configuration file that conforms to the specifications of the power system electromagnetic transient simulation software PSCAD. The Web service module is used to automatically generate a Web service interface that provides an upload function for the system structure image of the transfer function and a download function for the configuration file and the dynamic link library; The image acquisition and detection module, the information reading module, the topology construction module, the code generation module, the compilation module, the configuration generation module, and the Web service module are connected in sequence.