Striped tube simulation macro script generation method based on knowledge graph and related products

By constructing a directed knowledge graph and utilizing its calling order constraints, the problem of stripe tube design relying on human experience in electromagnetic simulation software is solved. This enables the generation of macro scripts with high reliability and executability, improving the automation level of simulation tasks and the reproducibility of results.

CN122308805APending Publication Date: 2026-06-30XI AN JIAOTONG UNIV +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XI AN JIAOTONG UNIV
Filing Date
2026-06-01
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing electromagnetic simulation software relies heavily on the experience of engineers in the design and verification of stripe tubes, resulting in cumbersome simulation configuration processes, high trial and error costs, and poor executability and unreasonable physical logic of macro scripts generated by large language models, making it difficult to apply directly to engineering practice.

Method used

A directed knowledge graph is constructed. By acquiring heterogeneous data from multiple sources, knowledge triples are generated to represent the calling order constraints between nodes. Breadth-first search is used to retrieve the target constraint path, and the path is sorted according to the directed association relationship. Constraint prompts that conform to the calling order are then input into a large language model to generate a stripe tube simulation macro script.

Benefits of technology

This improves the reliability and engineering applicability of macro script generation in simulation tasks, reduces the probability of missing prerequisite steps and incorrect method call order, and ensures that the generated macro scripts can be executed correctly and meet engineering requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122308805A_ABST
    Figure CN122308805A_ABST
Patent Text Reader

Abstract

This invention discloses a knowledge graph-based method for generating macro scripts for striped tube simulation and related products, belonging to the field of electromagnetic simulation automation technology. The knowledge graph-based method for generating macro scripts for striped tube simulation provided by this invention constructs a directed knowledge graph containing directed associations representing the calling order constraints between nodes. This allows simulation knowledge to go beyond semantic associations and possess explicit topological dependency logic. After retrieving the target constraint path, the extracted nodes are sorted according to the directed associations to form constraint prompts that conform to the calling order. This minimizes the probability of missing preliminary steps and incorrect method calling order, thereby guiding a pre-set large language model to generate executable electromagnetic simulation macro scripts with correct calling order and complete configuration chains. This improves the reliability, engineering applicability, and actual execution stability of macro script generation in simulation tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electromagnetic simulation automation technology, specifically to a method for generating macro scripts for stripe tube simulation based on knowledge graphs and related products. Background Technology

[0002] Currently, when using electromagnetic simulation software for the design and verification of stripe tubes, the configuration phase of the simulation process still heavily relies on the personal experience of engineers. Specifically, stripe tube simulation typically involves several core steps, including cathode emission configuration, electrode grid bias setting, focusing electrode field distribution calculation, time-varying electromagnetic field analysis of the deflection plate, and particle tracking solution. These steps involve discrete geometric entities, simulation methods, and operating parameters with strict topological dependencies and execution order. Engineers must sequentially select the target discrete geometric entities, configure the corresponding parameters, and write simulation macro scripts within the electromagnetic simulation software. This not only results in a cumbersome simulation configuration process and high trial-and-error costs but also makes the consistency and reproducibility of simulation results susceptible to the experience of the engineers.

[0003] While large language models have code generation capabilities, they are prone to problems such as missing pre-execution steps and disordered method call order when generating simulation macro scripts with strict method call order. This results in macro scripts that generally have poor executability and unreasonable physical logic, making them difficult to apply directly to engineering practice.

[0004] Therefore, how to achieve highly reliable generation of stripe tube simulation macro scripts has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to provide a method for generating macro scripts for stripe tube simulation based on knowledge graphs and related products, so as to overcome the problems of poor executability, unreasonable physical logic, and difficulty in direct application to engineering practice of macro scripts generated by large language models.

[0006] The present invention solves the above-mentioned technical problems through the following technical solution: This invention provides a method for generating macro scripts for stripe tube simulation based on knowledge graphs, comprising the following steps: Construct a directed knowledge graph, which includes nodes and directed associations representing the calling order constraints between nodes. The nodes include at least object nodes, method nodes, parameter nodes, and attribute nodes. In response to the received simulation task description, retrieve the target constraint path associated with the simulation task description from the directed knowledge graph; Extract the nodes in the target constraint path, and sort the extracted nodes according to the directed association relationship of the call order constraints between the nodes to form constraint prompt information that conforms to the call order; Input the constraint prompts into the preset large language model to generate a stripe tube simulation macro script.

[0007] A further improvement of this invention lies in constructing a directed knowledge graph, specifically: Acquire multi-source heterogeneous data, which should include at least the help documentation of the electromagnetic simulation software, historical simulation macro scripts, and external control interface files; Extract head entities, tail entities, and relations from multi-source heterogeneous data to generate knowledge triples; A directed knowledge graph is constructed based on knowledge triples, where the head and tail entities of the knowledge triples are constructed as nodes, and the relations are constructed as directed associations from the head entity to the tail entity.

[0008] A further improvement of this invention lies in the directed association relationship representing the calling order constraint between nodes, specifically: Directed associations represent the subordinate relationships between object nodes and method nodes, the parameter constraint relationships between method nodes and parameter nodes, the attribute attribution relationships between object nodes and attribute nodes, and the method call relationships between method nodes.

[0009] A further improvement of this invention lies in retrieving the target constraint path associated with the simulation task description from the directed knowledge graph, specifically: Extract the semantic tags pre-set for the discrete geometric entities of the simulation task to be performed from the simulation task description; Seed nodes are determined in directed knowledge graphs based on semantic tags; Starting from the seed node, perform a breadth-first search along the directed relationships in the directed knowledge graph to retrieve the target constraint path within a preset number of hops; The semantic tags pre-set for the discrete geometric entities to be simulated are as follows: Obtain the three-dimensional geometric model of the striped tube to be simulated, import the three-dimensional geometric model into the electromagnetic simulation software, generate discrete geometric entities, and set semantic labels for each discrete geometric entity.

[0010] A further improvement of this invention lies in determining seed nodes in a directed knowledge graph based on semantic tags, specifically: Obtain multiple candidate nodes that match semantic labels in a directed knowledge graph; Seed nodes are selected from multiple candidate nodes based on preset priority rules; The preset priority rules, arranged in descending order of priority, include: prioritizing nodes whose names are exactly the same as their semantic tags, prioritizing method nodes, and prioritizing nodes with fewer characters in their names.

[0011] A further improvement of this invention is that, when sorting the extracted nodes according to the directed association relationship of the calling order constraint between nodes, the seed node has the highest priority; In a directed association, the method node located at the starting point of the directed association takes precedence over the method node located at the ending point of the directed association; Nodes with smaller graph distances to the seed node are prioritized over nodes with larger graph distances. When method nodes located at the starting point or ending point of a directed association have the same graph distance, the order of discovery within the same graph distance is determined by the breadth-first search.

[0012] This invention provides a knowledge graph-based macro script generation system for stripe tube simulation, comprising: The first module is used to construct a directed knowledge graph, which includes nodes and directed associations representing the calling order constraints between nodes. The nodes include at least object nodes, method nodes, parameter nodes, and attribute nodes. The second module is used to retrieve the target constraint path associated with the simulation task description from the directed knowledge graph in response to the received simulation task description. The third module is used to extract nodes in the target constraint path and sort the extracted nodes according to the directed association relationship of the calling order constraints between nodes to form constraint prompt information that conforms to the calling order. The fourth module is used to input constraint prompts into a preset large language model and generate a stripe tube simulation macro script.

[0013] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method for generating macro scripts for stripe tube simulation based on knowledge graphs.

[0014] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described method for generating a stripe tube simulation macro script based on a knowledge graph.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described knowledge graph-based stripe tube simulation macro script generation method.

[0016] Compared with the prior art, the positive and progressive effects of the present invention are as follows: The present invention provides a knowledge graph-based method for generating macro scripts for stripe tube simulation. By constructing a directed knowledge graph containing directed associations representing constraints on the calling order between nodes, the simulation knowledge not only remains at the semantic association level but also possesses explicit topological dependency logic. After retrieving the target constraint path, instead of simply splicing text fragments, the extracted nodes are sorted according to the directed associations to form constraint prompts that conform to the calling order. In this way, the probability of missing preliminary steps and incorrect method calling order is minimized, thereby guiding the preset large language model to generate executable electromagnetic simulation macro scripts with correct calling order and complete configuration chains, improving the reliability, engineering applicability, and actual execution stability of macro script generation in simulation tasks. Attached Figure Description

[0017] The accompanying drawings are provided to further understand the invention and constitute a part of this invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0018] Figure 1 This is a flowchart illustrating the knowledge graph-based method for generating macro scripts for stripe tube simulation according to the present invention. Figure 2 Figure 1 shows a schematic diagram of the flight trajectory tracking of electrons in the vw plane in Example 1. Figure 1(a) shows the flight trajectory tracking of electrons in the vw plane under the first set of electrode voltage parameters; Figure 2(b) shows the flight trajectory tracking of electrons in the vw plane under the second set of electrode voltage parameters; and Figure 3(c) shows the flight trajectory tracking of electrons in the vw plane under the third set of electrode voltage parameters. Figure 3 Figure 1 shows a schematic diagram of the two-dimensional electron landing point distribution on the probe end face in Example 1. Figure (a) shows the two-dimensional electron landing point distribution on the probe end face under the first set of electrode voltage parameters; Figure (b) shows the two-dimensional electron landing point distribution on the probe end face under the second set of electrode voltage parameters; and Figure (c) shows the two-dimensional electron landing point distribution on the probe end face under the third set of electrode voltage parameters. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] In the description of this invention, it should be understood that the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0021] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0022] It should be understood that although terms such as first, second, third, etc., may be used in the embodiments of the present invention to describe the preset range, these preset ranges should not be limited to these terms. These terms are only used to distinguish the preset ranges from one another. For example, without departing from the scope of the embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.

[0023] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0024] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. This is an explanation of the present invention and not a limitation thereof.

[0025] See Figure 1 This invention provides a method for generating macro scripts for stripe tube simulation based on knowledge graphs, comprising the following steps: Construct a directed knowledge graph, which includes nodes and directed associations representing the calling order constraints between nodes. The nodes include at least object nodes, method nodes, parameter nodes, and attribute nodes. In response to the received simulation task description, retrieve the target constraint path associated with the simulation task description from the directed knowledge graph; Extract the nodes in the target constraint path, and sort the extracted nodes according to the directed association relationship of the call order constraints between the nodes to form constraint prompt information that conforms to the call order; Input the constraint prompts into the preset large language model to generate a stripe tube simulation macro script.

[0026] The present invention provides a knowledge graph-based method for generating macro scripts for stripe tube simulation. By constructing a directed knowledge graph containing directed associations representing constraints on the calling order between nodes, the simulation knowledge not only remains at the semantic association level but also possesses explicit topological dependency logic. After retrieving the target constraint path, instead of simply splicing text fragments, the extracted nodes are sorted according to the directed associations to form constraint prompts that conform to the calling order. In this way, the probability of missing preliminary steps and incorrect method calling order is minimized, thereby guiding the preset large language model to generate executable electromagnetic simulation macro scripts with correct calling order and complete configuration chains, improving the reliability, engineering applicability, and actual execution stability of macro script generation in simulation tasks.

[0027] Specifically, constructing a directed knowledge graph involves: Acquire multi-source heterogeneous data, which should include at least the help documentation of the electromagnetic simulation software, historical simulation macro scripts, and external control interface files; Extract head entities, tail entities, and relations from multi-source heterogeneous data to generate knowledge triples; A directed knowledge graph is constructed based on knowledge triples, where the head and tail entities of the knowledge triples are constructed as nodes, and the relations are constructed as directed associations from the head entity to the tail entity.

[0028] By acquiring heterogeneous data from multiple sources, such as help documents, historical simulation macro scripts, and external control interface files of electromagnetic simulation software, and extracting head entities, tail entities, and relationships, the construction sources of the directed knowledge graph cover three dimensions: official specifications of electromagnetic simulation software, engineering practice experience, and external interface definitions. This ensures the integrity and accuracy of nodes and relationships in the directed knowledge graph, avoiding knowledge omissions or interface deviations caused by a single data source.

[0029] Specifically, the directed association relationship representing the call order constraint between nodes is as follows: Directed associations represent the subordinate relationships between object nodes and method nodes, the parameter constraint relationships between method nodes and parameter nodes, the attribute attribution relationships between object nodes and attribute nodes, and the method call relationships between method nodes.

[0030] By refining the relationships into four directional types—subordination, parameter constraint, attribute attribution, and method call—the knowledge graph not only records the semantic relationships between entities but also explicitly encodes the hierarchical subordination between objects and methods, the interface constraints between methods and parameters, the configuration attribution between objects and attributes, and the sequential call dependencies between methods. This provides a structured directional constraint basis for subsequent retrieval of target constraint paths and topological linearization sorting.

[0031] Specifically, the target constraint paths associated with the simulation task description are retrieved from the directed knowledge graph, as follows: Extract the semantic tags pre-set for the discrete geometric entities of the simulation task to be performed from the simulation task description; Seed nodes are determined in directed knowledge graphs based on semantic tags; Starting from the seed node, perform a breadth-first search along the directed relationships in the directed knowledge graph to retrieve the target constraint path within a preset number of hops; The semantic tags pre-set for the discrete geometric entities to be simulated are as follows: Obtain the three-dimensional geometric model of the striped tube to be simulated, import the three-dimensional geometric model into the electromagnetic simulation software, generate discrete geometric entities, and set semantic labels for each discrete geometric entity.

[0032] By extracting pre-set semantic tags for discrete geometric entities from the simulation task description to determine seed nodes, and performing a breadth-first search to retrieve target constraint paths starting from the seed nodes, the functional roles annotated by users are directly mapped to the retrieval starting point in the knowledge graph, avoiding the ambiguity and drift that may occur with pure semantic matching. At the same time, the 3D geometric model is imported into the simulation software to generate discrete geometric entities and set semantic tags, so that the macro scripts generated subsequently can accurately reference and manipulate the corresponding geometric entities through semantic tags, ensuring the accurate correspondence between macro scripts and simulation objects.

[0033] Specifically, based on semantic tags, seed nodes are determined in the directed knowledge graph, as follows: Obtain multiple candidate nodes that match semantic labels in a directed knowledge graph; Seed nodes are selected from multiple candidate nodes based on preset priority rules; The preset priority rules, arranged in descending order of priority, include: prioritizing nodes whose names are exactly the same as their semantic tags, prioritizing method nodes, and prioritizing nodes with fewer characters in their names.

[0034] Seed nodes are selected from multiple candidate nodes by pre-defined priority rules: nodes with completely identical names are given priority, method nodes are given priority, and nodes with fewer characters in their names are given priority. When multiple candidate nodes are generated by semantic tag matching, deterministic selection can be performed according to three dimensions: name accuracy, node function type, and name distinguishability. This avoids the randomness of seed node selection and ensures that the retrieval starting point is highly consistent with the functional intent of the simulation task.

[0035] Specifically, when sorting the extracted nodes based on the directed association relationship constrained by the order of calls between nodes, the seed node has the highest priority; In a directed association, the method node located at the starting point of the directed association takes precedence over the method node located at the ending point of the directed association; Nodes with smaller graph distances to the seed node are prioritized over nodes with larger graph distances. When method nodes located at the starting point or ending point of a directed association have the same graph distance, the order of discovery within the same graph distance is determined by the breadth-first search.

[0036] By employing a four-layer sorting rule—highest priority seed node, priority given to method nodes at the start of a directed association over those at the end, priority given to nodes with smaller graph distance, and breadth-first search as a fallback—the unordered set of nodes in the target constraint path is transformed into a linear sequence that strictly follows topological dependencies and call order. This ensures that the generated constraint prompts conform to the actual execution logic of the simulation software in terms of method call sequence, completeness of prerequisite steps, and parameter configuration hierarchy, fundamentally eliminating call order errors and missing prerequisite steps caused by improper sorting.

[0037] Based on the same inventive concept, this invention also provides a knowledge graph-based stripe tube simulation macro script generation system, comprising: The first module is used to construct a directed knowledge graph, which includes nodes and directed associations representing the calling order constraints between nodes. The nodes include at least object nodes, method nodes, parameter nodes, and attribute nodes. The second module is used to retrieve the target constraint path associated with the simulation task description from the directed knowledge graph in response to the received simulation task description. The third module is used to extract nodes in the target constraint path and sort the extracted nodes according to the directed association relationship of the calling order constraints between nodes to form constraint prompt information that conforms to the calling order. The fourth module is used to input constraint prompts into a preset large language model and generate a stripe tube simulation macro script.

[0038] Through the coordinated efforts of the first to fourth modules, the four stages of knowledge graph construction, target constraint path retrieval, topological linearization sorting, and large language model script generation are organized into a complete systematic process, realizing end-to-end automated generation from simulation task description to executable electromagnetic simulation macro script.

[0039] In a specific embodiment of the present invention, a method for generating a stripe tube simulation macro script based on a knowledge graph includes the following steps: S1. Semantic Tag Labeling: Import the three-dimensional geometric model of the striped tube from external CAD (Computer-Aided Design) software into the electromagnetic simulation environment, perform functional mapping on the discrete geometric entities in the three-dimensional geometric model of the striped tube, and assign semantic tags to the target discrete geometric entities. The semantic tags are used to characterize the functional role of the corresponding discrete geometric entities in the striped tube simulation, and are used for subsequent reference and operation of discrete geometric entities by the striped tube simulation macro script.

[0040] S2. Directed Knowledge Graph Construction: Based on multi-source heterogeneous data such as help documents, historical simulation macro scripts, and external control interface files of electromagnetic simulation software, text parsing is performed on the multi-source heterogeneous data, and the data is segmented into text fragments according to object descriptions, method descriptions, parameter descriptions, and example code. Subsequently, entity extraction and relation extraction are performed on the text fragments using a large language model to obtain entity sets and relation sets, which are then organized into knowledge triples of head entity—relation—tail entity. A knowledge triple consists of a head entity, a relation, and a tail entity. The head and tail entities contain node identifiers, node types, node names, descriptive text, and source information, while the relation contains relation types. When constructing a directed knowledge graph based on knowledge triples, the head and tail entities are converted into nodes, the relation is converted into a directed association between nodes, and the association direction is determined by the head entity pointing to the tail entity.

[0041] Directed knowledge graphs are organized around nodes as the basic unit. Each node stores its own node identifier, node type, node name, descriptive text, and source information. For relationships between this node and other nodes, it stores the relationship type, relationship direction, and the node identifier of the associated node. Nodes include at least object nodes, method nodes, parameter nodes, and attribute nodes. Relationships include at least the dependency relationship between object nodes and method nodes, the attribute attribution relationship between object nodes and attribute nodes, the parameter constraint relationship between method nodes and parameter nodes, and the method call relationship between method nodes. Logically, a directed knowledge graph is a directed relational structure. The reachable path from the first method node to the second method node represents the call order constraint that the first method node executes before the second method node.

[0042] S3. Seed Node Determination and Target Subgraph Retrieval Steps: Receive the simulation task description to be generated from the script, and extract the semantic tags corresponding to the target discrete geometric entities in the simulation task description; construct query information based on the semantic tags and the simulation task description, and perform semantic encoding on the query information to obtain the query vector; perform semantic encoding on the concatenated text of the node name and description text of each node in the directed knowledge graph to obtain the vector representation corresponding to each node; calculate the similarity between the query vector and the vector representation corresponding to each node, and select nodes with similarity higher than a preset threshold or ranking in the top N as candidate nodes.

[0043] If there is only one candidate node, then that candidate node is determined as the seed node. If there is more than one candidate node, then the following selection process is performed: First, prioritize candidate nodes whose node names are exactly the same as their semantic tags. Second, if there are no candidate nodes whose node names are exactly the same as their semantic tags, prioritize candidate nodes whose node names contain semantic tags. Third, if all candidate nodes have semantic tags in their node names, prioritize method nodes, then object nodes, then parameter nodes, and finally attribute nodes. Finally, if there are still multiple candidate nodes, select the candidate node with the fewer characters in its node name as the seed node.

[0044] After determining the seed node, a breadth-first search is performed starting from the seed node within a preset hop count range to obtain the target subgraph. The target subgraph includes the seed node, associated nodes connected to the seed node within the preset hop count range, and the association relationships between the nodes. In this invention, graph distance is used to represent the shortest path length between any node in the target subgraph and the seed node, and the shortest path length is counted according to the number of hops traversed by the association relationships.

[0045] S4. Topology linearization steps: Extract all nodes in the target subgraph and sort them in the following order: seed nodes first; in method call relationships, method nodes located at the starting point of a directed association are prioritized over method nodes located at the ending point of that directed association; nodes with smaller graph distances are prioritized over nodes with larger graph distances; when the graph distances and dependencies of nodes are the same, the order is determined by the discovery order within the same number of hops in the breadth-first search. Based on the sorting results, extract the node type, node name, and descriptive text from each node and organize them into node description items; at the same time, extract the relationship description between adjacent nodes from the association relationships stored in the nodes and organize them into relationship description items; then organize them into constraint prompt information in the order of node description item - relationship description item - next node description item.

[0046] S5. Electromagnetic simulation macro script generation steps: Input the constraint prompt information into the preset large language model, generate the striped tube electromagnetic simulation macro script from the large language model, and add semantic label names, physical parameters and solution settings to the striped tube electromagnetic simulation macro script. The semantic label names are used to reference the corresponding discrete geometric entities.

[0047] This method transforms scattered knowledge from electromagnetic simulation software help documents, historical simulation macro scripts, and external control interface files into nodes and their relationships in a directed knowledge graph. It then utilizes the subordinate relationships, parameter constraints, attribute attribution, and directed associations of method calls within the directed knowledge graph to complete target subgraph retrieval, topology linearization, and stripe tube simulation macro script generation. Compared to existing knowledge graph-assisted generation schemes that rely solely on semantic association to retrieve text fragments and then splice them, this method not only utilizes a directed knowledge graph for retrieval but also further leverages call order constraints to limit the scope and organization order of script generation. This improves the correctness of the call order, the consistency of parameter configuration, the executability, and the engineering applicability of the stripe tube simulation macro script.

[0048] Example 1 The simulation macro script for the striped tube is generated based on the electron trajectory and the distribution of the landing points on the detector end face after electrons are emitted from the cathode surface and under the influence of the electric field inside the striped tube. This macro script is used to complete the configuration of the emission source, the setting of the electrode voltage, and the control of the particle tracking solution process in the electromagnetic simulation software. It also calls the particle tracking solver to complete the numerical solution of the electron motion in the striped tube. The specific steps include: The three-dimensional geometric model of the stripe tube is imported into the electromagnetic simulation software. This three-dimensional geometric model includes at least discrete geometric entities such as the curved cathode, electrode mesh, focusing electrode, anode cone, and probe end face. Then, the target discrete geometric entity is selected in the three-dimensional interface and its semantic tags are assigned. In this embodiment, the emitting surface corresponding to the curved cathode is selected and assigned the semantic tag "cathode emitting surface" to characterize the electron emission function of this discrete geometric entity in the stripe tube simulation. This allows the subsequently generated stripe tube simulation macro script to reference and manipulate this discrete geometric entity through the semantic tags.

[0049] After semantic tagging is completed, a pre-constructed directed knowledge graph is invoked, with a preset retrieval depth of 2 hops. Within the 1-hop retrieval range, object nodes, method nodes, parameter nodes, and attribute nodes directly associated with the seed node are obtained. Within the 2-hop retrieval range, method nodes located at the starting point and the ending point of the directed association relationship associated with these nodes are further obtained, thus forming a target subgraph related to the current stripe tube simulation task. For the task corresponding to the semantic tag "cathode emission surface" in this embodiment, the target subgraph can not only retrieve information that can be obtained from a general knowledge graph, such as the semantic tag name, emission parameters, and attribute information corresponding to the cathode emission surface, but also further retrieve the pre-actions and call chain structures related to emission source creation, electrode configuration, and particle tracking solution process control, providing a complete task context for the subsequent generation of stripe tube simulation macro scripts.

[0050] Extract all nodes in the target subgraph and sort them in the following order: seed nodes first; method nodes at the start of a directed association are prioritized over method nodes at the end of that directed association; nodes with smaller graph distances are prioritized over nodes with larger graph distances; when nodes have the same graph distance and dependency, the order is determined by the discovery order within the same number of hops in the breadth-first search.

[0051] After sorting, the node type, node name, and descriptive text are extracted from each node, and these are organized into node description items. Simultaneously, the relationship descriptions between adjacent nodes are extracted from the node's stored associations, and these relationship descriptions are organized into relationship description items. Subsequently, constraint prompts are organized in the order of "node description item—relationship description item—next node description item," and these constraint prompts must at least reflect the following order: first, locate the discrete geometric entity to be configured, and complete the simulation module selection and solution environment loading; then, create a launch source on the launch surface corresponding to the discrete geometric entity; finally, write the launch parameters, electrode parameters, and solution parameters.

[0052] After obtaining the constraint prompts, the constraint prompts are input into the large language model, which generates a stripe tube simulation macro script. The semantic label names, physical parameters and solution settings required for the stripe tube simulation are written into the stripe tube simulation macro script. The generated stripe tube simulation macro script includes at least the target discrete geometric entity positioning statement, the emission source configuration statement, the electrode voltage setting statement, and the particle tracking solution flow control statement.

[0053] The script includes several key components: a target discrete geometric entity location statement to determine the discrete geometric entity to be configured within the stripe tube; an emission source configuration statement to create an electron emission source on the emission surface corresponding to the discrete geometric entity and define the initial physical conditions for the electrons; an electrode voltage setting statement to establish the electric field distribution affecting electron motion within the stripe tube; and a particle tracking solution flow control statement to call the particle tracking solver in the electromagnetic simulation software to numerically solve the electron flight process in the electric field. This transforms the hierarchical relationships, attribute relationships, parameter constraint relationships, and method call relationships in the directed knowledge graph into a macro script usable for stripe tube simulation. In this embodiment, the written parameters include at least the semantic tag name corresponding to the "cathode emission surface," emission source-related parameters, voltage parameters of the stripe tube's core electrode, and particle tracking solution control parameters. Specifically, this embodiment sets the initial emission kinetic energy to 1 eV and writes three different sets of electrode voltage parameters according to different test requirements, enabling subsequent comparative analysis of the electron motion behavior of the stripe tube under different operating modes.

[0054] Table 1. Voltage parameters of the three working electrodes of the striped tube

[0055] In this embodiment, the specific constraint prompts are as follows: the simulation scenario is electron tracking, the particle solver method is set to Tetrahedral, the simulation time is set to 5, the maximum time step is set to 100000, a tracking source is added, an electrostatic field E-static is added, and the weight is 1.0. The representative script fragments related to the solution objective in the macro script for generating stripe tube simulation are as follows: AddToHistory "Particle Tracking Solver", _ "With TrackingSolver"&vbCrLf&_ ".Reset"&vbCrLf&_ ".Method ""Tetrahedral"""&vbCrLf&_ ".SetSimulationTime ""5"""&vbCrLf&_ ".MaxTimeSteps ""100000"""&vbCrLf&_ ".AddTrackingSource ""all sources"", """""&vbCrLf&_ ".AddStaticsField ""E-static"", ""1.0"", ""False"""&vbCrLf&_ "End With" End Sub In the representative script snippet above, `AddToHistory "Particle Tracking Solver"` writes the configuration commands for the particle tracking solver to the history of the electromagnetic simulation software; `With TrackingSolver` enters the configuration environment of the particle tracking solver object; `.Reset` clears or resets existing solver parameters; `.Method "Tetrahedral"` sets the solution method to the tetrahedral method; `.SetSimulationTime "5"` sets the total computation time for the particle tracking simulation; `.MaxTimeSteps "100000"` sets the maximum number of time steps for the particle tracking solution; `.AddTrackingSource "all sources", ""` loads all defined electron emission sources; and `.AddStaticsField "E-static", "1.0", "False"` adds the electrostatic field named `E-static` to the particle tracking solution process and sets its weight to 1.0. With this configuration, the particle tracking solver can numerically solve for the flight trajectory of electrons inside the stripe tube and the distribution of their landing points at the detector end under specified electrostatic field and emission source conditions.

[0056] After obtaining the stripe tube simulation macro script, the stripe tube simulation macro script is executed in the electromagnetic simulation software to sequentially complete the configuration of the stripe tube emitter, the writing of electrode voltages, the loading of the field environment required for solving, and the setting of particle tracking solution control parameters. Subsequently, the particle tracking solver is called to perform electron trajectory solving. The particle tracking solver is used to calculate the flight trajectory of electrons in the electric field inside the stripe tube and the distribution of their landing points on the detection end face according to the aforementioned configuration scenario, so as to verify the executability and physical rationality of the stripe tube simulation macro script.

[0057] Driven by a macroscript for stripe tube simulation, the electron beam, emitted from the curved cathode, participates in... Figure 2 This demonstrates how, under three different electrode voltage parameters, electrons travel along v inside the stripe tube after emitting from the emission region. The graph shows the electron's trajectory in the w-plane, where v represents the electron's position coordinates in the lateral deflection direction of the stripe tube, primarily reflecting the electron's lateral displacement under the influence of the electric field. w represents the electron's position coordinates in the axial propagation direction of the stripe tube, primarily reflecting the longitudinal transmission process of the electron from the cathode to the detector end face. The horizontal axis represents the position in the v-direction, and the vertical axis represents the position in the w-direction, both in millimeters. Each curve in the graph represents the trajectory of an electron, with circles indicating the starting point and asterisks indicating the ending point. The trajectory represents the kinetic energy of the electron during flight, in eV. The graph shows that after starting from the emitter, the electron propagates along the w-direction under the influence of the electric field inside the stripe tube, undergoing significant focusing and deflection during transmission. Under the three sets of electrode voltage parameters, the electron trajectory exhibits a relatively smooth, continuous curve without obvious trajectory interruptions, abrupt changes, or crossing anomalies, indicating that the generated simulation macro script can correctly complete the emission source configuration, electrode voltage writing, electrostatic field environment configuration loading, and particle tracking solution. The particle tracking solver is used to calculate the flight trajectory of electrons in the electric field inside the stripe tube and the distribution of their landing points at the detector end face to verify the executability and physical rationality of the macroscript. The main differences under the three sets of electrode voltage parameters lie in the electron focusing position, deflection amplitude, and endpoint distribution range. Under the first set of electrode voltage parameters, the electron trajectory forms a relatively obvious convergence in the central region and then spreads towards the detector end face; under the second set of electrode voltage parameters, the overall deflection trend of the electron beam is more concentrated, and the trajectory maintains good continuity during propagation; under the third set of electrode voltage parameters, the trajectory distribution range is relatively wider, indicating that the third set of electrode voltage parameters has a different impact on the spatial deflection and focusing state of the electron beam. All three modes can complete the electron tracking calculation, indicating that the proposed method has stable comparability under different electrode voltage parameters. Also see Figure 3 This demonstrates the two-dimensional distribution of electron landing points after reaching the detector end face under three sets of electrode voltage parameters, i.e., the electron endpoint at... In the diagram, u represents the spatial coordinate direction perpendicular to the probe surface. This represents the coordinates of the endpoint position of the electron in the u direction when it reaches the detector end face. This represents the coordinates of the endpoint position of the electron in the v direction when it reaches the detector end face. This represents the coordinates of the endpoint position of the electron in the w direction when it reaches the detector end face. Indicates the time magnification of the stripe tube; This indicates the time resolution; ps stands for picosecond, which is a unit of time. The figure only shows the statistics that satisfy the condition. The electron landing points under the given conditions reflect the distribution of electrons effectively reaching or approaching the detector end face. Under all three sets of electrode voltage parameters, the electron landing points exhibit obvious stripe-like and layered distribution characteristics, indicating that after the electron beam is focused, deflected, and transmitted under the influence of the electric field inside the stripe tube, it forms a regular spatial distribution on the detector end face. Under the first set of electrode voltage parameters, the electron landing points are relatively sparse, and the distribution range is longitudinally extended; under the second and third sets of electrode voltage parameters, more electrons reach the statistical region, and the landing point distribution is more continuous and dense. Overall, the electron landing points under all three sets of electrode voltage parameters do not show obvious abnormal scattering, indicating that the electron tracking solution process is relatively stable, and the electron distribution on the detector end face conforms to the expectations of the imaging stripes in the stripe tube design.

[0058] In summary, this invention does not merely use directed knowledge graphs as general semantic association retrieval tools, but rather leverages the directed association relationships within the directed knowledge graph that represent the call order constraints between nodes to complete target subgraph retrieval, topological linearization, and stripe tube simulation macro script generation. This approach reduces issues such as missing preliminary steps, incorrect method call order, and inconsistent parameter configurations, thereby improving the automatic generation quality, actual execution stability, and result reproducibility of the stripe tube simulation macro script.

[0059] Comparative Example 1 Using the same striped tube simulation task as in Example 1 as the target, a striped tube simulation macro script is required to be generated for the same 3D model of the striped tube and the same set of simulation requirements. The striped tube simulation macro script should include at least the emitter configuration statement, the voltage setting statement for the core electrode of the striped tube, and the particle tracking solver flow control statement. The particle tracking solver flow control statement may include settings such as tetrahedral solution mode, simulation time, maximum time step, tracking source loading, and electrostatic field loading. The following selects script fragments related to particle tracking solver configuration from the generated striped tube simulation macro script as representative comparison content.

[0060] In this comparative example, only the task description information is directly input into the large language model. This embodiment uses the ChatGPT-5.4-Thinking model to generate the stripe tube simulation macro script, and the generated result is imported into the electromagnetic simulation software for execution.

[0061] The task description is as follows: Please generate a CSTStudioSuiteVBA macro script that only outputs the particle tracking solver configuration code and does not output other parts. The requirements are as follows: Use the AddToHistory method to organize the relevant code. The configuration objects are limited to TrackingSolver and its directly related mesh setting statements. The simulation scenario is electron tracking. The solver method is set to Tetrahedral. The simulation time is set to 5. The maximum time step is set to 100000. Add a tracking source and an electrostatic field E-static with a weight of 1.0. The output style should be as close as possible to the CSTVBA macro.

[0062] The representative script fragments related to the solution objective in the ChatGPT-5.4-Thinking model generation stripe tube simulation macro script are as follows: AddToHistory "Particle Tracking Solver",_ "With Mesh"&vbCrLf&_ ".MeshType ""Tetrahedral"""&vbCrLf&_ "End With"&vbCrLf&_ "With TrackingSolver"&vbCrLf&_ ".Reset"&vbCrLf&_ ".Method ""Tetrahedral"""&vbCrLf&_ ".SimulationType ""ParticleTracking"""&vbCrLf&_ ".TrackingType ""Electron"""&vbCrLf&_ ".SetSimulationTime ""5"""&vbCrLf&_ ".SetMaxNumberOfTimesteps ""100000"""&vbCrLf&_ ".AddTrackingSource"&vbCrLf&_ ".AddField ""E-Static"", ""1.0"""&vbCrLf&_ "End With" End Sub Ignoring the correctness of script calls, from a purely semantic perspective, AddToHistory "ParticleTracking Solver" means writing the particle tracking solver configuration to the simulation software's historical operation record; With Mesh means entering the mesh object's configuration environment; .MeshType "Tetrahedral" means attempting to set the mesh type to a tetrahedral mesh; the first End With means ending the mesh object configuration. Subsequently, `WithTrackingSolver` indicates entering the particle tracking solver object; `.Reset` indicates resetting existing parameters of the particle tracking solver; `.Method "Tetrahedral"` indicates setting the particle tracking solution method to the tetrahedral method; `.SimulationType "ParticleTracking"` indicates attempting to set the simulation type to particle tracking; `.TrackingType "Electron"` indicates attempting to set the tracking object to electron; `.SetSimulationTime "5"` indicates setting the total computation time of the particle tracking simulation to 5; `.SetMaxNumberOfTimesteps "100000"` indicates attempting to set the maximum number of time steps to 100000; `.AddTrackingSource` indicates attempting to add a particle tracking source; `.AddField "E-Static", "1.0"` indicates attempting to load the electrostatic field and set its weight to 1.0; the last `End With` indicates ending the particle tracking solver object configuration, and `End Sub` indicates ending the current macro process; `&vbCrLf&` is used for string concatenation and line breaks.

[0063] The execution result imported into the electromagnetic simulation software is as follows: The simulation software is reporting an error: "No such property or method. (.SimulationType "ParticleTracking")". This file may have been saved by a later version of CST PARTICLE STUDIO.

[0064] It is evident that the large language model can generate script fragments related to the particle tracking solver configuration. These script fragments include statements related to tetrahedral solving (e.g., ".MeshType ""Tetrahedral"""&vbCrLf&), tracking source loading (e.g., ".AddTrackingSource"&vbCrLf&), and electrostatic field loading (e.g., ".AddField ""E-Static"", ""1.0"""&vbCrLf&), which can express the basic intent of the particle tracking solution flow control part in the stripe tube simulation macro script. It can be seen that the large language model can identify the basic semantic goals of the particle tracking solution flow control part and generate script fragments related to the particle tracking solver configuration, indicating that it has certain capabilities in local syntactic organization and functional splicing.

[0065] However, compared with Example 1, this script fragment still has the following problems: First, the method call format is not consistent with the corresponding script fragment actually used for stripe tube simulation in Example 1, which is prone to problems such as generalization of method names and inaccurate parameter interfaces, such as calling the non-existent parameter interface ".SimulationType ""ParticleTracking"""&vbCrLf&; Second, although the relevant statements can express the basic intention of particle tracking solution process control, they fail to form a complete call chain constrained by topological dependencies with the emission source configuration and electrode parameter settings, such as the incorrect call order of the three commands "With Mesh"&vbCrLf&, ".MeshType ""Tetrahedral"""&vbCrLf&, and "End With"&vbCrLf&. Therefore, the stripe tube simulation macro script generated in Comparative Example 1 cannot guarantee its call position, order, and parameter consistency in the complete simulation process; Third, errors occur when executed in electromagnetic simulation software, indicating that there are still problems of invalid calls, interface mismatch, or missing preliminary steps at the actual execution level. It is evident that the macro script for stripe tube simulation directly generated from the large language model in Comparative Example 1 still mainly remains at the level of splicing local functions in the particle tracking solution process control, which is insufficient to meet the requirements of complex stripe tube simulation tasks for configuration accuracy and execution stability.

[0066] Based on the same inventive concept, this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of a knowledge graph-based stripe tube simulation macro script generation method. The memory may include main memory, such as high-speed random access memory, or it may also include non-volatile memory, such as at least one disk storage device. The processor, network interface, and memory are interconnected via an internal bus, which may be an industry-standard architecture bus, a peripheral component interconnection standard bus, an extended industry-standard architecture bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory is used to store the program; specifically, the program may include program code, which includes computer operation instructions. The memory may include main memory and non-volatile memory, and provides instructions and data to the processor.

[0067] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the steps of the knowledge graph-based stripe tube simulation macro script generation method. Specifically, the computer-readable storage medium includes, but is not limited to, volatile memory and / or non-volatile memory. The volatile memory may include RAM (Random Access Memory) and / or cache memory, etc. The non-volatile memory may include ROM (Read-Only Memory), hard disk, flash memory, optical disk, magnetic disk, etc.

[0068] Based on the same inventive concept, this application provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions, which, when executed by a computer device, cause the computer device to perform the steps of the above-described knowledge graph-based stripe tube simulation macro script generation method.

[0069] Those skilled in the art will understand that embodiments of the present invention can be provided as methods or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM (Compact Disc Read-Only Memory), optical storage, etc.) containing computer-usable program code.

[0070] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer apparatus or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0071] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer device or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0072] These computer program instructions may also be loaded onto a computer device or other programmable data processing equipment to cause a series of operational steps to be performed on the computer device or other programmable equipment to produce a process implemented by the computer device, thereby providing instructions that execute on the computer device or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0073] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0074] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A method for generating macro scripts for stripe tube simulation based on knowledge graphs, characterized in that, Includes the following steps: Construct a directed knowledge graph, which includes nodes and directed associations representing the calling order constraints between nodes. The nodes include at least object nodes, method nodes, parameter nodes, and attribute nodes. In response to the received simulation task description, retrieve the target constraint path associated with the simulation task description from the directed knowledge graph; Extract the nodes in the target constraint path, and sort the extracted nodes according to the directed association relationship of the call order constraints between the nodes to form constraint prompt information that conforms to the call order; Input the constraint prompts into the preset large language model to generate a stripe tube simulation macro script.

2. The method for generating a stripe tube simulation macro script based on a knowledge graph according to claim 1, characterized in that, Constructing a directed knowledge graph, specifically: Acquire multi-source heterogeneous data, which should include at least the help documentation of the electromagnetic simulation software, historical simulation macro scripts, and external control interface files; Extract head entities, tail entities, and relations from multi-source heterogeneous data to generate knowledge triples; A directed knowledge graph is constructed based on knowledge triples, where the head and tail entities of the knowledge triples are constructed as nodes, and the relations are constructed as directed associations from the head entity to the tail entity.

3. The method for generating a stripe tube simulation macro script based on a knowledge graph according to claim 2, characterized in that, The directed association relationship representing the call order constraint between nodes is as follows: Directed associations represent the subordinate relationships between object nodes and method nodes, the parameter constraint relationships between method nodes and parameter nodes, the attribute attribution relationships between object nodes and attribute nodes, and the method call relationships between method nodes.

4. The method for generating a stripe tube simulation macro script based on a knowledge graph according to claim 1, characterized in that, Retrieve the target constraint paths associated with the simulation task description from the directed knowledge graph, specifically: Extract the semantic tags pre-set for the discrete geometric entities of the simulation task to be performed from the simulation task description; Seed nodes are determined in directed knowledge graphs based on semantic tags; Starting from the seed node, perform a breadth-first search along the directed relationships in the directed knowledge graph to retrieve the target constraint path within a preset number of hops; The semantic tags pre-set for the discrete geometric entities to be simulated are as follows: Obtain the three-dimensional geometric model of the striped tube to be simulated, import the three-dimensional geometric model into the electromagnetic simulation software, generate discrete geometric entities, and set semantic labels for each discrete geometric entity.

5. The method for generating a stripe tube simulation macro script based on a knowledge graph according to claim 4, characterized in that, Based on semantic tags, seed nodes are determined in the directed knowledge graph, specifically as follows: Obtain multiple candidate nodes that match semantic labels in a directed knowledge graph; Seed nodes are selected from multiple candidate nodes based on preset priority rules; The preset priority rules, arranged in descending order of priority, include: prioritizing nodes whose names are exactly the same as their semantic tags, prioritizing method nodes, and prioritizing nodes with fewer characters in their names.

6. The method for generating a stripe tube simulation macro script based on a knowledge graph according to claim 4, characterized in that, When sorting the extracted nodes based on the directed association relationship constrained by the order of calls between nodes, the seed node has the highest priority; In a directed association, the method node located at the starting point of the directed association takes precedence over the method node located at the ending point of the directed association; Nodes with smaller graph distances to the seed node are prioritized over nodes with larger graph distances. When method nodes located at the starting point or ending point of a directed association have the same graph distance, the order of discovery within the same graph distance is determined by the breadth-first search.

7. A knowledge graph-based stripe tube simulation macro script generation system, characterized in that, include: The first module is used to construct a directed knowledge graph, which includes nodes and directed associations representing the calling order constraints between nodes. The nodes include at least object nodes, method nodes, parameter nodes, and attribute nodes. The second module is used to retrieve the target constraint path associated with the simulation task description from the directed knowledge graph in response to the received simulation task description. The third module is used to extract nodes in the target constraint path and sort the extracted nodes according to the directed association relationship of the calling order constraints between nodes to form constraint prompt information that conforms to the calling order. The fourth module is used to input constraint prompts into a preset large language model and generate a stripe tube simulation macro script.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the knowledge graph-based stripe tube simulation macro script generation method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the knowledge graph-based stripe tube simulation macro script generation method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the knowledge graph-based stripe tube simulation macro script generation method as described in any one of claims 1 to 6.