Simulation Parametric Design Method, Device and System Compatible with APDL Command Stream

By preprocessing and syntax analysis of the APDL command stream, generating and executing object code, and outputting APDL basic command streams without parameters and programming syntax, the problem that CAE simulation software is not compatible with APDL command streams is solved, and support for ANSYS APDL high-level syntax is achieved.

CN119917109BActive Publication Date: 2025-06-24CHINA SHIPBUILDING ORLANDO WUXI SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510396829.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-01
Publication Date
2025-06-24
Estimated Expiration
2045-04-01

AI Technical Summary

Technical Problem

CAE simulation software other than ANSYS is not compatible with ANSYS APDL command flow, which causes users to manually convert the APDL command flow into commands corresponding to other software, increasing the user's learning cost and workload.

Method used

By obtaining the APDL command stream string for preprocessing, and configuring syntax matching rules that support ANSYS APDL syntax, calling the syntax parsing component for syntax parsing, generating an abstract syntax tree, compiling it into object code, and executing the virtual machine module to output the APDL basic command stream without parameters and programming syntax.

Benefits of technology

It implements the execution of ANSYS APDL command stream in the CAE system and supports most of the high-level syntax of ANSYS APDL, solving the problem that CAE simulation software cannot be compatible with APDL command stream.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917109B_ABST
    Figure CN119917109B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of processing ANSYS APDL command streams, and specifically discloses a simulation parametric design method, device and system compatible with APDL command streams, including: obtaining an APDL command stream string and performing preprocessing on it; configuring a syntax matching rule that supports ANSYS APDL syntax; calling a syntax parsing component, which can perform syntax parsing on the preprocessed APDL command stream string according to the syntax matching rule, and the syntax parsing result includes a complete abstract syntax tree or an incomplete abstract syntax tree; inputting the complete abstract syntax tree into a compiler module; inputting the target code into a virtual machine module to obtain an APDL basic command stream; and executing the APDL basic command stream. The simulation parametric design method compatible with APDL command streams provided by the present invention enables CAE software other than ANSYS to be compatible with APDL command streams.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of processing ANSYS APDL command streams, and particularly relates to a simulation parametric design method compatible with APDL command streams, a simulation parametric design device compatible with APDL command streams, and a CAE system. Background Art

[0002] ANSYS APDL (ANSYS Parametric Design Language) is a powerful scripting language widely used in processes such as model creation, analysis and solution, and result processing in ANSYS software. It enables users to automate and customize various stages of finite element analysis through command streams and parameterization.

[0003] The ANSYS APDL command system can be divided into several core parts that cooperate together to complete a full finite element analysis process. Specifically, it includes the following modules: the preprocessing stage, which mainly defines and prepares the model, including geometric modeling, mesh generation, material property setting, and boundary condition definition, etc.; the solution stage, which is the core of finite element analysis, including selecting the analysis type, setting solution control parameters, and the actual solution process; the postprocessing stage, which is the process of analyzing, visualizing, and processing the solution results.

[0004] ANSYS APDL supports parameterization of commands, allowing the use of variables and parameters to dynamically adjust the execution of commands, enabling users to define changeable values, avoiding hard-coding certain constants, and thus making the analysis model more flexible. It supports the definition of arrays and retrieving values from arrays, enabling flexible management and use of a large number of parameters and facilitating the processing of multi-dimensional data. It supports various control flow statements (such as *DO, *IF) to implement loops and conditional judgments, facilitating loop processing of multiple similar tasks or performing certain operations when specific conditions are met.

[0005] In ANSYS, commands are usually executed in sequence, and the entire analysis process is driven by a series of commands. Users can manually input commands or write macro files for batch processing to achieve automated analysis. By combining means such as parameterization and automation, users can create complex and dynamic analysis processes in ANSYS APDL and efficiently complete all links from geometric modeling to result processing.

[0006] However, CAE simulation software other than ANSYS is often not compatible with the syntax of the ANSYS APDL programming language and cannot handle advanced syntax in APDL commands such as variable parameters, complex mathematical operations, and loop statements. As a result, users who are accustomed to using APDL for parametric design need to manually convert the APDL command stream into corresponding commands for other software, increasing the user's learning cost and workload.

[0007] Therefore, how to make CAE simulation software other than ANSYS compatible with APDL command stream has become a technical problem that needs to be solved urgently by technical personnel in this field. Summary of the invention

[0008] The present invention provides a simulation parameterized design method compatible with APDL command stream, a simulation parameterized design device compatible with APDL command stream and a CAE system, which solve the problem in the related art that CAE simulation software other than ANSYS is not compatible with APDL command stream.

[0009] As a first aspect of the present invention, a simulation parameterized design method compatible with APDL command stream is provided, which includes:

[0010] Acquire an APDL command stream character string, and preprocess the APDL command stream character string to obtain a preprocessed APDL command stream character string;

[0011] Configure syntax matching rules to support ANSYS APDL syntax;

[0012] Calling a syntax parsing component and receiving a syntax parsing result returned by the syntax parsing component, wherein the syntax parsing component can perform syntax parsing on the preprocessed APDL command stream character string according to the syntax matching rule and obtain a syntax analysis result, wherein the syntax parsing result includes a parsed complete abstract syntax tree or an incomplete parsed abstract syntax tree;

[0013] Inputting the parsed complete abstract syntax tree into the compiler module to obtain the target code including operands and operators;

[0014] Inputting the target code into a virtual machine module to obtain a plurality of APDL basic command flows without parameters and programming syntax;

[0015] The APDL basic command flow is executed to at least implement parameter-driven simulation modeling.

[0016] Furthermore, the syntax matching rules supporting ANSYS APDL syntax are configured, including:

[0017] Configure grammar matching rules that match the complex semantic types according to the ANSYS APDL grammar. The grammar matching rules include a grammar structure that forms a hierarchical pattern in a preset organizational order, and a nested relationship is formed between each grammar matching rule.

[0018] Further, receive the grammar parsing result returned by the grammar parsing component, including:

[0019] Receive the boolean value returned by the grammar parsing component;

[0020] Judge the legality of the grammar parsing result according to the boolean value;

[0021] If the boolean value is true, determine that the grammar parsing result includes a parsed complete abstract syntax tree;

[0022] If the boolean value is false, determine that the grammar parsing result includes a parsed incomplete abstract syntax tree.

[0023] Further, input the parsed complete abstract syntax tree into the compiler module to obtain target code including operands and operators, including:

[0024] Input the parsed complete abstract syntax tree into the compiler module, and the compiler module can traverse according to the node structure of the parsed complete abstract syntax tree and generate target code corresponding to each node.

[0025] Further, the compiler module can traverse according to the node structure of the parsed complete abstract syntax tree and generate target code corresponding to each node, including:

[0026] When traversing to the IF conditional statement node, process the IF condition, compile it into target code, and then process the IF branch, ELSEIF branch, and ELSE branch under preset conditions respectively, and obtain the target code of the corresponding branches;

[0027] When traversing to the DO loop statement node, process the loop variable and the increment of the variable respectively, and obtain the corresponding target code;

[0028] When traversing to the basic command statement node, process the keyword of the command and the parameter list of the command respectively, and obtain the corresponding target code.

[0029] Further, input the target code into the virtual machine module to obtain multiple APDL basic command streams without parameters and programming grammar, including:

[0030] Input the target code into the virtual machine module, and the virtual machine module can check the matching degree of the target code and whether the parameter variable is a declared variable;

[0031] If there is a situation where the inspection fails, the virtual machine module terminates the execution of the target code and returns an error message;

[0032] If all inspections pass, the virtual machine module executes the target code to obtain multiple APDL basic command streams without parameters and programming syntax.

[0033] Further, executing the APDL basic command stream to at least implement parameter-driven simulation modeling includes:

[0034] Determine command keywords according to the APDL basic command stream;

[0035] Search for the corresponding API in the command registry according to the command keywords;

[0036] Call the API corresponding to the command keyword to sequentially execute the APDL basic command stream.

[0037] Further, it also includes the following steps before the step of obtaining the APDL command stream string:

[0038] Configure the API corresponding to the command keyword into a plug-in in the form of a dynamic link library, where the plug-in in the form of a dynamic link library can be automatically loaded;

[0039] Register the command keyword in the command registry, where the command registry can search for and return the corresponding API according to the command keyword.

[0040] As another aspect of the present invention, there is provided a simulation parametric design device compatible with the APDL command stream for implementing the simulation parametric design method compatible with the APDL command stream described above, which includes:

[0041] A preprocessing module for obtaining an APDL command stream string and preprocessing the APDL command stream string to obtain a preprocessed APDL command stream string;

[0042] A configuration module for configuring syntax matching rules that support ANSYS APDL syntax;

[0043] A syntax tree construction module for calling a syntax parsing component and receiving the syntax parsing result returned by the syntax parsing component, where the syntax parsing component can perform syntax parsing on the preprocessed APDL command stream string according to the syntax matching rules and obtain a syntax analysis result, and the syntax parsing result includes a parsed complete abstract syntax tree or a parsed incomplete abstract syntax tree;

[0044] A compilation module, configured to input the completely parsed abstract syntax tree into a compiler module to obtain target code including operands and operators;

[0045] A virtual machine execution module, configured to input the target code into a virtual machine module to obtain multiple APDL basic command streams without parameters and programming syntax;

[0046] A command execution module, configured to execute the APDL basic command stream to at least implement parameter-driven simulation modeling.

[0047] As another aspect of the present invention, there is provided a CAE system, which includes: the simulation parametric design device compatible with APDL command streams described above.

[0048] The simulation parametric design method compatible with APDL command streams provided by the present invention preprocesses the APDL command stream string, configures a set of syntax matching rules supporting ANSYS APDL syntax, then performs syntax analysis on the preprocessed command stream according to the syntax matching rules, and based on the compiler module, compiles the completely parsed abstract syntax tree in the syntax analysis result and converts it into target code only containing operands and operators. The target code generated by the compiler module is executed by the virtual machine module, and finally a set of APDL commands without high-level syntax is output. Through the APDL basic command call mechanism, the specific functions of multiple APDL commands can be called. This simulation parametric design method compatible with APDL command streams can implement the execution of ANSYS APDL command streams in a CAE system and support most of the high-level syntax of ANSYS APDL, solving the problem that CAE simulation software other than ANSYS in the prior art cannot be compatible with APDL command streams. Description of the Drawings

[0049] The drawings are used to provide a further understanding of the present invention, and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present invention, but do not constitute a limitation to the present invention.

[0050] Figure 1 It is a flowchart of the simulation parametric design method compatible with APDL command streams provided by the present invention.

[0051] Figure 2 It is a schematic diagram of the specific working process of the simulation parametric design method compatible with APDL command streams provided by the present invention.

[0052] Figure 3 It is the content of the main command stream provided by the present invention.

[0053] Figure 4 It is the content of the command stream included in the macro file provided by the present invention.

[0054] Figure 5 This is the pseudocode of the syntax rule for the mathematical expression in the syntax matching rule provided by the present invention.

[0055] Figure 6 This is the pseudocode of the syntax rule for the IF conditional statement in the syntax matching rule provided by the present invention.

[0056] Figure 7 This is the pseudocode of the syntax rule for the DO loop statement in the syntax matching rule provided by the present invention.

[0057] Figure 8 This is the content of the target code generated by the compiler module provided by the present invention.

[0058] Figure 9 This is the schematic diagram of the execution flow of the IF conditional statement in the virtual machine module provided by the present invention.

[0059] Figure 10 This is the schematic diagram of the execution flow of the DO loop statement in the virtual machine module provided by the present invention.

[0060] Figure 11 This is the scalar and array results obtained after the virtual machine module provided by the present invention executes all commands.

[0061] Figure 12 This is the schematic diagram of the working process of the APDL command extension mechanism provided by the present invention.

[0062] Figure 13 This is the structural block diagram of the simulation parametric design device compatible with the APDL command stream provided by the present invention. Detailed implementation manners

[0063] It should be noted that, without conflict, the embodiments in the present invention and the features in the embodiments may be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0064] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0065] It should be noted that the terms "first", "second", etc. in the specification, claims and above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances, so as to implement the embodiments of the present invention described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily limit to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0066] In this embodiment, a simulation parametric design method compatible with APDL command stream is provided. Figure 1 It is a flowchart of the simulation parametric design method compatible with APDL command stream provided according to the embodiment of the present invention, as Figure 1 shown, including:

[0067] S100. Obtain the APDL command stream string, and preprocess the APDL command stream string to obtain a preprocessed APDL command stream string;

[0068] In the embodiment of the present invention, for the APDL command stream string input by the user, it is preprocessed to make it meet the string rules for running on the current CAE system. Specifically, the preprocessing content includes but is not limited to the preprocessing of the continuation character and punctuation marks in the APDL command stream string.

[0069] S200. Configure the syntax matching rules that support ANSYS APDL syntax;

[0070] In the embodiment of the present invention, a set of syntax matching rules that support ANSYS APDL syntax are configured, which can specifically support scalar parameter definition, array parameter definition, table parameter definition, parameter name matching, complex mathematical operations, IF conditions, FOR / WHILE loop nesting, and APDL basic commands, etc.

[0071] S300. Call the syntax parsing component and receive the syntax parsing result returned by the syntax parsing component, where the syntax parsing component can perform syntax parsing on the preprocessed APDL command stream string according to the syntax matching rules and obtain a syntax analysis result, and the syntax parsing result includes a complete abstract syntax tree or an incomplete abstract syntax tree;

[0072] In an embodiment of the present invention, according to the syntax matching rules configured above, and by invoking a syntax parsing component, syntax parsing is performed on the preprocessed APDL command stream string. The specific syntax parsing result may specifically be a complete abstract syntax tree or an incomplete abstract syntax tree.

[0073] S400. Input the complete abstract syntax tree into a compiler module to obtain object code including operands and operators.

[0074] In an embodiment of the present invention, the complete abstract syntax tree obtained above is input into a compiler module, and based on this compiler module, object code that can include operands and operators is obtained. It should be understood that this compiler module can convert the complete abstract syntax tree into object code executable by a virtual machine module, realizing the mapping from high-level abstraction to low-level operations. This object code only contains operands and operators.

[0075] S500. Input the object code into a virtual machine module to obtain multiple APDL basic command streams without parameters and programming syntax.

[0076] In an embodiment of the present invention, the object code obtained by the above compiler module is input into a virtual machine module, and based on the execution of this virtual machine module, multiple APDL basic command streams without parameters are obtained. Specifically, the virtual machine module can execute the object code generated by the compiler module, which involves stack operations and memory operations, and finally outputs a set of APDL commands without high-level syntax such as variables, mathematical operations, and loop statements.

[0077] S600. Execute the APDL basic command stream to at least implement parameter-driven simulation modeling.

[0078] In an embodiment of the present invention, based on the API and based on the call mechanism, the above APDL basic command stream is called to implement the specific functions corresponding to the commands.

[0079] In summary, the simulation parametric design method compatible with APDL command flow provided by the embodiments of the present invention preprocesses the APDL command flow string, configures a set of syntax matching rules that support ANSYS APDL syntax, then performs syntax analysis on the preprocessed command flow according to the syntax matching rules, and based on the compiler module, compiles the parsed complete abstract syntax tree in the syntax analysis result and converts it into target code that only contains operands and operators. The target code generated by the compiler module is executed through the virtual machine module, and finally a set of APDL commands without high-level syntax are output. Through the APDL basic command call mechanism, the specific functions of multiple APDL commands can be called. This simulation parametric design method compatible with APDL command flow can implement the execution of ANSYS APDL command flow in the CAE system and support most of the high-level syntax of ANSYS APDL, solving the problem that CAE simulation software other than ANSYS in the prior art cannot be compatible with APDL command flow.

[0080] In the embodiments of the present invention, for a string composed of an APDL command flow input by a user, simple preprocessing is performed on it. This preprocessing can handle the continuation character in the command flow and at the same time replace the Chinese exclamation mark in the string with an English exclamation mark (the comment flag in the APDL command language) to avoid subsequent parsing failures caused by incorrect user input. The embodiments of the present invention do not limit the specific processing content of this preprocessing.

[0081] In the embodiments of the present invention, configure syntax matching rules that support ANSYS APDL syntax, including:

[0082] Configure syntax matching rules that match the complex semantic types of the ANSYS APDL syntax. The syntax matching rules include a syntax structure that forms a hierarchical pattern in a preset organizational order, and a nested relationship is formed between each syntax matching rule.

[0083] It should be understood that in order to support more complex APDL syntax, the syntax rules follow a hierarchical organizational pattern. This hierarchical pattern splits the complex syntax definitions into smaller, more understandable and manageable parts. Specifically, the rules can be organized in the order from simple to complex to form a tree structure. Each rule can depend on other rules, thus forming a nested relationship between the rules.

[0084] The top-level structure of the syntax rules is statement_list, which can be regarded as a set of statements composed of multiple basic statements or statement segments, corresponding to the complete command flow to be processed passed in.

[0085] Taking the DO loop statement as an example, the structure of this statement includes the *DO keyword, loop variable, start value, end value, step size, loop body, and the *ENDDO keyword. Among them, the *DO keyword and *ENDDO keyword can be directly matched as character constants, the loop variable is matched as a variable name string, the start value, end value, and step size are matched as expressions, and since the loop body can contain multiple basic statements or statement segments, its structure is also statement_list, and this kind of loop nesting is also supported.

[0086] In addition, when configuring the syntax matching rules, scalar and array parameters can be defined through commands such as *SET and *DIM. These parameters will be used as global variables and will remain valid until the simulation parametric modeling analysis execution engine is shut down, unless the variables are deleted or redefined.

[0087] In an embodiment of the present invention, a syntax parsing component is called, and specifically, this syntax parsing component can be the Qi component of the Boost.Spirit library. It should be understood that the Boost.Spirit library is a C++ library for parsing and generating text. It provides a template-based declarative programming method, enabling users to directly write syntax rules and parsers in C++ code. Among them, the Boost.Spirit.Qi component is mainly used for text parsing. It provides a declarative way to define syntax rules and convert the input text into structured data.

[0088] In an embodiment of the present invention, the syntax parsing result returned by the syntax parsing component is received, including:

[0089] 1) Receive the boolean value returned by the syntax parsing component;

[0090] 2) Judge the legality of the syntax parsing result according to the boolean value;

[0091] 3) If the boolean value is true, determine that the syntax parsing result includes a parsed complete abstract syntax tree;

[0092] 4) If the boolean value is false, determine that the syntax parsing result includes a parsed incomplete abstract syntax tree.

[0093] Specifically, the syntax parsing component parses the preprocessed APDL command stream string according to the above syntax matching rules and returns the syntax parsing result, which is specifically a boolean value. After the return, it is specifically determined whether the syntax parsing of the preprocessed APDL command stream string by the syntax parsing component is complete according to the boolean value. In the embodiments of the present invention, if the boolean value is true, it is determined that the syntax parsing is complete, and the abstract syntax tree included in the syntax parsing result is determined to be a completely parsed abstract syntax tree; on the contrary, if the boolean value is false, the abstract syntax tree included in the syntax parsing result is determined to be an incompletely parsed abstract syntax tree.

[0094] It should be understood that only when the boolean value is true can the completely parsed abstract syntax tree be transmitted as input to the compiler module, that is, enter a step; if the boolean value is false, that is, when the obtained abstract syntax tree is incompletely parsed, since the syntax analysis failure may be caused by various reasons, if it is due to reading an incomplete conditional statement or loop statement without an end flag, the subsequent steps will be aborted, and the currently input command stream will be temporarily stored in the memory, prompting the user to input subsequently; if it is due to the command stream input by the user not meeting the syntax requirements of the APDL command language, this execution will be terminated, waiting for the user to re-enter the command stream, and prompting the user for the location of the syntax error.

[0095] Therefore, in the embodiments of the present invention, when the syntax parsing component parses the preprocessed APDL command stream string, if an incomplete conditional statement or loop statement without an end flag is detected, the subsequent steps are aborted, and the currently input command stream is temporarily stored in the memory; the newly input command stream is spliced after the temporarily stored command stream, and the above step of detecting whether there is a missing end flag is repeated until a complete conditional statement or loop statement is input, and then the command stream is compiled and executed.

[0096] In the embodiments of the present invention, inputting the completely parsed abstract syntax tree into the compiler module to obtain target code including operands and operators includes:

[0097] Input the completely parsed abstract syntax tree into the compiler module, and the compiler module can traverse according to the node structure of the completely parsed abstract syntax tree and generate target code corresponding to each node.

[0098] It should be understood that the completely parsed abstract syntax tree is passed as input to the compiler module, and the compiler module generates target code containing only operands and operators according to the abstract syntax tree.

[0099] In the embodiments of the present invention, the compiler module starts from the root node of the abstract syntax tree, traverses the entire abstract syntax tree in a depth-first manner, recursively visits each child node, and generates corresponding target code for each node

[0100] More specifically, the compiler module can traverse according to the node structure of the parsed complete abstract syntax tree and generate target code corresponding to each node, including:

[0101] (1) When traversing to an IF conditional statement node, process the IF condition, compile it into target code, and then process the IF branch, ELSEIF branch, and ELSE branch under preset conditions respectively, and obtain the target code of the corresponding branches;

[0102] Specifically, whenever the compiler module accesses an IF conditional statement node, the processing of the compiler module is mainly divided into the following steps: Step 1, process the IF condition and compile it into target code; Step 2, generate a conditional jump instruction to skip the code of the IF branch when the IF condition is false, and temporarily set the jump target to 0, and fill it later; Step 3, process the IF branch and compile it into target code; Step 4, after the end of the IF branch, generate an unconditional jump instruction to skip the subsequent ELSEIF and ELSE branches; Step 5, loop to process each ELSEIF branch. For each ELSEIF branch, repeat the processing process similar to IF (that is, Step 1 to Step 4). Similarly, temporarily set all jump targets to 0 and fill them later; Step 6, if the ELSE branch exists, process the code block of the ELSE branch and compile it into target code; Step 7, traverse all the previously generated jump instructions, fill in the correct jump target address to ensure that the program can correctly jump to the corresponding code position during runtime.

[0103] (2) When traversing to a DO loop statement node, process the loop variable and the increment of the variable respectively, and obtain the corresponding target code;

[0104] Whenever the compiler module accesses a DO loop statement node, the processing of the compiler module is mainly divided into the following steps: Step 1, process the loop variable and the increment of the variable, and compile them into target code; Step 2, mark the position of the start point of the loop in the target code; Step 3, process the loop variable and the termination condition expression of the loop, compile them into target code, and generate corresponding comparison instructions according to the positive or negative of the increment; Step 4, generate a conditional jump instruction to jump out of the loop when the loop condition is not met, and temporarily set the jump target to 0 and supplement it later; Step 5, process the loop body and compile it into target code; Step 6, process the update of the loop variable, and add the increment value to the loop variable; Step 7, generate an unconditional jump instruction to jump back to the start position of the loop to realize the repeated execution of the loop; Step 8, fill in the target address of the previously generated conditional jump instruction to make it point to the position after the end of the loop.

[0105] (3) When traversing to the basic command statement node, process the keyword of the command and the parameter list of the command respectively, and obtain the corresponding target code.

[0106] Whenever the compiler module accesses a basic command statement, the processing of the compiler module mainly includes the following steps: Step 1, process the keyword of the command and add it to the target code as the name of the command; Step 2, loop through the parameter list of the command. For each parameter, if the parameter is not empty, recursively call the compiler module to process the parameter and compile it into the target code. If the parameter is empty, generate an empty parameter instruction; Step 3, after processing all the parameters, generate a command end instruction to indicate the completion of the compilation of the current command.

[0107] It should be understood that the embodiments of the present invention only exemplarily list the compilation and execution processes of IF statements, DO statements, and basic command statements, and are not intended to limit the embodiments of the present invention. Those skilled in the art can also compile and execute other types of statements as needed.

[0108] In the embodiments of the present invention, after the compiler module completes the above compilation function, the target code is obtained. Specifically, input the target code into the virtual machine module to obtain multiple APDL basic command streams without parameters and programming syntax, including:

[0109] (1) Input the target code into the virtual machine module, and the virtual machine module can check the matching degree of the target code and whether the parameter variables are declared variables.

[0110] (2) If there is a situation where the check fails, the virtual machine module terminates the execution of the target code and returns an error message.

[0111] (3) If all the checks pass, the virtual machine module executes the target code to obtain multiple APDL basic command streams without parameters and programming syntax.

[0112] It should be understood that during the execution of the target code, the virtual machine module will check whether the types match and whether the parameter variables used are declared variables. If there is a situation where the check fails, the execution of the target code will be terminated and an error message will be returned.

[0113] In the embodiments of the present invention, executing the APDL basic command stream at least realizes parameter-driven simulation modeling, including:

[0114] (1) Determine the command keyword according to the APDL basic command stream.

[0115] (2) Look up the corresponding API in the command registry according to the command keyword.

[0116] (3) Invoke the API corresponding to the command keyword to sequentially execute the APDL basic command stream.

[0117] It should be understood that the APDL basic command stream generated by the virtual machine module is an APDL basic command without parameters and advanced syntax. Taking it as input, find the corresponding API according to the command keyword and execute it sequentially.

[0118] In the embodiment of the present invention, the current CAE system already supports the functions of more than 300 APDL basic commands, including:

[0119] Database commands: / CLEAR, ALLSEL, ASLL, VSEL, NSLK, NSLL, NSLA, NSLV, KSLN, KSLL, ASLV, ESLL, ESLA, ESLV, ESLN, NSLE, NSEL, ESEL, KSEL, LSLK, LSEL, LSLA, ASEL, VSLA, CSLIST, CSYS, WPSTYL, WPAVE, WPLANE, WPCSYS, WPOFFS, WPROTA, KWPAVE, CM, CMGRP, CMDELE, CMSEL, CSDELE, CSKP, CSWPLA, LOCAL, CLOCAL, CMPLOT, SAVE, / INPUT, CDWRITE, etc.

[0120] Geometric modeling commands: K, L, A, V, KL, AL, VA, KDELE, LDELE, ADELE, VDELE, KPLOT, LPLOT, APLOT, VPLOT, KDIST, ACLEAR, LCLEAR, VCLEAR, KNODE, KPLOT, LPLOT, APLOT, VPLOT, GPLOT, KLIST, LLIST, ALIST, VLIST, LSBL, LSBA, LSBV, LSBW, ASBL, ASBA, ASBW, VSBA, VSBV, VSBW, L2TAN, LDIV, AINV, LINV, LINA, ASBV, ASKIN, CONE, SPHERE, LTAN, CON4, SPH4, RECTNG, PCIRC, BLC5, BLOCK, BLC4, TORUS, CYLIND, CYL4, ARSCALE, VLSCALE, LSSCALE, KGEN, LGEN, AGEN, VGEN, CIRCLE, LARC, VADD, LINL, VINV, AINA, AADD, BSPLIN, SPLINE, LSYMM, ARSYM, VSYMM, LOVLAP, VOVLAP, AOVLAP, LFILLT, AFILLT, LCOMB, LPTN, APTN, VPTN, LGLUE, AGLUE, VGLUE, VEXT, VOFFST, ADRAG, VDRAG, NUMOFF, NUMMRG, NUMCMP, NUMSTR, NWPAVE, LEXTND, AROTAT, VROTAT, ASUM, etc.

[0121] Mesh generation commands: N, E, ESIZE, LESIZE, AESIZE, MSHKEY, MSHAPE, LMESH, KMESH, VMESH, ADMESH, AMESH, VSWEEP, KATT, LATT, AATT, VATT, NROTAT, MAT, REAL, TSHAP, TYPE, NGEN, NLIST, NPLOT, EMODIF, ELIST, EPLOT, ENSYM, etc.

[0122] Physical property commands: ET, KEYOPT, ETDELE, ETLIST, MP, MPTEMP, MPDATA, MPCOPY, MPDELE, MPLIST, R, RMORE, RDELE, RLIST, RMODIF, SECNUM, SECOFFSET, SECTYPE, SECDATA, SECPLOT, SLIST, SDELETE, etc.

[0123] Constraint commands: CE, CERIG, CELIST, CP, CPINTF, CPLIST, etc.

[0124] Solution setup commands: D, DK, DDELE, F, FDELE, FK, FKDELE, SF, SFA, SFADELE, SFE, SFEDELE, SFBEAM, SFGRAD, SFDELE, BFE, BFDELE, IC, ICDELE, ACEL, TREF, ANTYPE, ANTYPE, LUMPM, MODOPT, MODCONT, MXPAND, SPOPT, FREQ, SV, SRSS, CQC, GRP, SED, SVTYP, SPUNIT, SPFREQ, SPVAL, PSDUNIT, PSDFRQ, PSDVAL, PFACT, MMASS, RIGRESP, SOLVE, DMPRAT, LSREAD, LSWRITE, LSCLEAR, LSSOLVE, etc.

[0125] Post-processing commands: SET, / RGB, NSORT, PLNSOL, PLESOL, ESORT, ETABLE, SADD, SMAX, SMIN, PLETAB, LCASE, LCDEF, LCFACT, LCFILE, LCWRITE, LCOPER, LCABS, etc.

[0126] Graphical display commands: DSYS, / SHOW, / REPLOT, / AUTO, / CONTOUR, etc.

[0127] Session commands: / CWD, / FILNAME, / CWD, / EXIT, etc.

[0128] Auxiliary and parameter control commands: IGESIN, / INQUIRE, *VREAD, *VWRITE, *GET, *DIM, *DEL, *AFUN, / MKDIR, *CFOPEN, *CFCLOS, etc.

[0129] In the embodiment of the present invention, it further includes the following steps performed before the step of obtaining the APDL command stream string:

[0130] Configuring the API corresponding to the command keyword into a plug-in in the form of a dynamic link library, wherein the plug-in in the form of a dynamic link library can be automatically loaded;

[0131] Registering the command keyword to a command registry, wherein the command registry can search for and return the corresponding API according to the command keyword.

[0132] It should be noted that specifically, the APIs of the APDL original commands (the APDL command stream string includes APDL original commands and custom extension commands) and custom extension commands can be grouped according to functions and uses, obtaining multiple groups of APIs for implementing various different functions such as geometric modeling, mesh generation, solution, and result processing. The APIs with different functions are respectively added to different dynamic link library files, which are placed at a specified location in the installation directory and can be automatically loaded as plug-ins; the keywords of the APDL original commands and custom extension commands are registered to the command registry, and the command registry can search for and return the API corresponding to the command according to the command keyword. It should also be noted that replacing or adding dynamic link library files and registering the keywords of the commands can expand the support for new commands.

[0133] In addition, in the embodiment of the present invention, when executing the APDL basic command stream, the APDL basic command stream can be specifically grouped according to different implemented functions, and based on the simulation parametric design requirements, determine the APDL basic command stream that needs to be called currently and matches the function. In this way, the APDL basic command stream corresponding to the function can be directly called, rather than all being called, which can effectively solve the update efficiency when the function is updated, that is, when the function is updated, only the APDL basic command stream corresponding to the function needs to be updated directly.

[0134] Therefore, in the embodiment of the present invention, users can independently implement the functions of custom commands at the code level. When using, only replace the dynamic link library file, and the command registration mechanism inside the simulation parametric modeling analysis execution engine can automatically load the dynamic link library file and register all the custom commands implemented inside. The user-defined commands can be used in the command stream or macro file, and the calling method of the commands is exactly the same as that of the ANSYS APDL basic commands.

[0135] It should be noted that macro files are ordinary text files containing a set of predefined APDL commands, usually with the file extension MAC, and can be called through the / INPUT command. When the macro file call statement is executed, the execution of the current command stream will be paused, and the command stream of the macro file will be transferred to start processing such as syntax parsing, compilation, and execution. In the embodiments of the present invention, nested calls of macro files are supported to decompose complex tasks, make the overall script more modular, and reduce the difficulty of maintenance and debugging. The use of local variables in macro files is supported: 99 local variables such as built-in ARG1~ARG9 and AR10~AR99 are provided, and their scope of action is limited to the interior of the macro file where the local variables are defined and are initialized to 0 after leaving the macro file where they are assigned values.

[0136] The following combines Figures 2 to 11 to describe in detail the specific implementation process of the simulation parametric design method for compatible APDL command streams in the embodiments of the present invention.

[0137] As Figure 2 shown, the simulation parametric design method for compatible APDL command streams can specifically include:

[0138] Step 1, input a string composed of an APDL command stream, the content of which is as Figure 3 shown, including the definition and assignment of scalar parameters and array parameters, complex mathematical operations including built-in functions, conditional judgment statements, loop statements, macro file calls, APDL basic commands, etc., which are the syntax of the ANSYS APDL command language. Among them, the content of the command stream contained in the macro file is as Figure 4 shown.

[0139] Step 2, perform syntax matching according to the defined syntax matching rules, and generate an abstract syntax tree at the same time.

[0140] Mathematical expressions are widely used in the input command stream, and the pseudo-code of its syntax rules is as Figure 5 ; the pseudo-code of the syntax rules of the IF conditional judgment statement used in the command stream is as Figure 6 ; the pseudo-code of the syntax rules of the DO loop statement used in the command stream is as Figure 7 .

[0141] Step 3, transfer the abstract syntax tree to the compiler module for compilation.

[0142] Part of the target code content generated by compilation is as Figure 8As shown in the figure. Among them, "start:" and "end:" respectively represent the start and end of the target code; "34:" and "140:" are the markers of the jump target positions; on the left, those starting with "op_" are operators, and on the right are operands. The operators include: "op_load" is to read a variable from memory, "op_store" is to save a variable to memory, "op_double" is to take a floating-point constant from the top of the data stack, "op_keyword" is to read a keyword of an APDL basic command from the top of the data stack, etc.

[0143] Step 4: Pass the target code generated by the compiler module to the virtual machine module and execute it.

[0144] Taking the IF conditional statement and the DO loop statement as examples, the schematic diagrams of their execution processes are shown in Figure 9 and Figure 10 .

[0145] After all are executed, the values of all defined scalar and array parameters are as Figure 11 shown, and all values meet the expectations.

[0146] Step 5: Take a set of APDL commands or user-defined commands without high-level syntax output by the virtual machine module as input. According to the command keywords, find the corresponding APIs in the internally implemented commands that have been registered, and execute them in sequence. The schematic diagram of the complete process is shown in Figure 12 the figure.

[0147] In the embodiment of the present invention, taking the "K" command used to create geometric key points in the main command stream as an example, during the startup phase of the self-developed CAE software, a dynamic link library file containing the "K" command will be loaded, and all APDL and custom commands including the "K" command implemented internally will be registered; during the running phase, the API of the "K" command will be found among all the registered commands according to the command keywords, and the function will be called.

[0148] In summary, the simulation parametric design method compatible with APDL command flow provided by the present invention defines a set of syntax matching rules that support ANSYS APDL syntax; preprocesses an input command flow string or macro file; performs syntax analysis on the preprocessed command flow according to the syntax matching rules and constructs an abstract syntax tree; implements a compiler module to convert the constructed abstract syntax tree into object code containing only operands and operators; implements a virtual machine module to execute the object code generated by the compiler module, and finally outputs a set of APDL commands without high-level syntax; implements a mechanism for calling basic APDL commands, which can call the specific functions of more than 300 APDL commands; and establishes a mechanism for extending APDL commands to support user-defined extended commands. Therefore, the simulation parametric design method compatible with APDL command flow of the present invention realizes the support for most of the high-level syntax of ANSYS APDL and provides a mechanism for command extension by adding user-defined extended commands.

[0149] As another embodiment of the present invention, there is provided a simulation parametric design device 100 compatible with APDL command flow for implementing the simulation parametric design method compatible with APDL command flow described above. As shown in Figure 13 the following, it includes:

[0150] A preprocessing module 110 for obtaining an APDL command flow string and preprocessing the APDL command flow string to obtain a preprocessed APDL command flow string;

[0151] A configuration module 120 for configuring syntax matching rules that support ANSYS APDL syntax;

[0152] An abstract syntax tree construction module 130 for calling a syntax parsing component and receiving a syntax parsing result returned by the syntax parsing component, where the syntax parsing component can perform syntax parsing on the preprocessed APDL command flow string according to the syntax matching rules and obtain a syntax analysis result, and the syntax analysis result includes a completely parsed abstract syntax tree or an incompletely parsed abstract syntax tree;

[0153] A compilation module 140 for inputting the completely parsed abstract syntax tree into a compiler module to obtain object code including operands and operators;

[0154] A virtual machine execution module 150 for inputting the object code into a virtual machine module to obtain a plurality of APDL basic command flows without parameters and programming syntax;

[0155] A command execution module 160 for executing the APDL basic command flow to at least implement parameter-driven simulation modeling.

[0156] The simulation parametric design device compatible with APDL command flow provided by the present invention preprocesses the APDL command flow string, configures a set of syntax matching rules that support ANSYS APDL syntax, then performs syntax analysis on the preprocessed command flow according to the syntax matching rules, and based on the compiler module, compiles the parsed complete abstract syntax tree in the syntax analysis result and converts it into target code that only contains operands and operators. The virtual machine module executes the target code generated by the compiler module, and finally outputs a set of APDL commands without high-level syntax. Through the APDL basic command call mechanism, the specific functions of multiple APDL commands can be called. This simulation parametric design device compatible with APDL command flow can implement the execution of ANSYS APDL command flow in the CAE system and support most of the high-level syntax of ANSYS APDL, solving the problem that CAE simulation software other than ANSYS in the prior art cannot be compatible with APDL command flow.

[0157] Regarding the specific working process of the simulation parametric design device compatible with APDL command flow of the present invention, reference can be made to the description of the simulation parametric design method compatible with APDL command flow in the previous text, and details will not be repeated here.

[0158] As another embodiment of the present invention, a CAE system is provided, which includes: the simulation parametric design device compatible with APDL command flow described above.

[0159] The CAE system provided by the present invention adopts the simulation parametric design device compatible with APDL command flow described above, which can meet the compatibility requirements of self-developed CAE software for the high-level syntax of APDL command flow and the support for user-defined extended commands, solving the problem that CAE simulation software other than ANSYS in the prior art cannot be compatible with APDL command flow.

[0160] It can be understood that the above embodiments are merely exemplary embodiments adopted to illustrate the principle of the present invention, and the present invention is not limited thereto. For those of ordinary skill in the art, various modifications and improvements can be made without departing from the spirit and essence of the present invention, and these modifications and improvements are also regarded as the protection scope of the present invention.

Claims

1. A simulation parameterized design method compatible with APDL command stream, characterized in that: include: Acquire an APDL command stream character string, and preprocess the APDL command stream character string to obtain a preprocessed APDL command stream character string; Configure syntax matching rules to support ANSYS APDL syntax; Calling a syntax parsing component and receiving a syntax parsing result returned by the syntax parsing component, wherein the syntax parsing component can perform syntax parsing on the preprocessed APDL command stream character string according to the syntax matching rule and obtain a syntax analysis result, wherein the syntax parsing result includes a parsed complete abstract syntax tree or an incomplete parsed abstract syntax tree; Inputting the parsed complete abstract syntax tree into the compiler module to obtain the target code including operands and operators; Inputting the target code into a virtual machine module to obtain a plurality of APDL basic command flows without parameters and programming syntax; Executing the APDL basic command flow to at least implement parameter-driven simulation modeling; Among them, the configuration supports the syntax matching rules of ANSYS APDL syntax, including: According to the complex semantic type of the ANSYS APDL syntax, a syntax matching rule matching therewith is configured. The syntax matching rule includes a syntax structure that forms a hierarchical pattern according to a preset organization order, and a nested relationship is formed between each syntax matching rule.

2. The simulation parameterized design method compatible with APDL command stream according to claim 1, characterized in that: Receiving the grammar parsing result returned by the grammar parsing component includes: Receive a Boolean value returned by the syntax parsing component; Judging the legitimacy of the grammatical parsing result according to the Boolean value; If the Boolean value is true, determining the syntax parsing result includes parsing a complete abstract syntax tree; If the Boolean value is false, determining the syntax parsing result includes parsing an incomplete abstract syntax tree.

3. The simulation parameterized design method compatible with APDL command stream according to claim 1, characterized in that: The parsed complete abstract syntax tree is input to the compiler module to obtain the target code including operands and operators, including: The fully parsed abstract syntax tree is input to a compiler module, and the compiler module can traverse the node structure of the fully parsed abstract syntax tree and generate a target code corresponding to each node.

4. The simulation parameterized design method compatible with APDL command stream according to claim 3, characterized in that: The compiler module can traverse the node structure of the parsed complete abstract syntax tree and generate target code corresponding to each node, including: When traversing to the IF conditional statement node, the IF condition is processed and compiled into a target code, and then the IF branch, ELSEIF branch and ELSE branch are processed respectively under the preset conditions, and the target code of the corresponding branch is obtained; When traversing to the DO loop statement node, the loop variable and the variable increment are processed respectively, and the corresponding target code is obtained; When traversing to the basic command statement node, the command keywords and the command parameter list are processed respectively, and the corresponding target code is obtained.

5. The simulation parameterized design method compatible with APDL command stream according to claim 1, characterized in that: The target code is input into a virtual machine module to obtain a plurality of APDL basic command flows without parameters and programming syntax, including: Inputting the target code into a virtual machine module, the virtual machine module can check the matching degree of the target code and whether the parameter variables are declared variables; If there is a situation that fails the check, the virtual machine module terminates the execution of the target code and returns an error message; If all the checks pass, the virtual machine module executes the target code to obtain multiple APDL basic command flows without parameters and programming syntax.

6. The simulation parameterized design method compatible with APDL command stream according to claim 1, characterized in that: Executing the APDL basic command flow to at least implement parameter-driven simulation modeling includes: Determine a command keyword according to the APDL basic command flow; Searching for a corresponding API in a command registry according to the command keyword; The API corresponding to the command keyword is called to execute the APDL basic command flow in sequence.

7. The simulation parameterized design method compatible with APDL command stream according to claim 1, characterized in that: The step also includes the following steps before the step of obtaining the APDL command stream string: The API corresponding to the command keyword is configured into a plug-in in the form of a dynamic link library, wherein the plug-in in the form of a dynamic link library can be automatically loaded; The command keyword is registered in a command registration table, wherein the command registration table can search for and return a corresponding API according to the command keyword.

8. A simulation parameterized design device compatible with APDL command stream, used to implement the simulation parameterized design method compatible with APDL command stream according to any one of claims 1 to 7, characterized in that: include: A preprocessing module, used for obtaining an APDL command stream character string, and preprocessing the APDL command stream character string to obtain a preprocessed APDL command stream character string; Configuration module, used to configure syntax matching rules to support ANSYS APDL syntax; A syntax tree construction module, used for calling a syntax parsing component and receiving a syntax parsing result returned by the syntax parsing component, wherein the syntax parsing component can perform syntax parsing on the pre-processed APDL command stream string according to the syntax matching rule and obtain a syntax analysis result, wherein the syntax parsing result includes a parsed complete abstract syntax tree or an incomplete parsed abstract syntax tree; A compiling module, used for inputting the parsed complete abstract syntax tree into a compiler module to obtain a target code including operands and operators; A virtual machine execution module, used for inputting the target code into the virtual machine module to obtain a plurality of APDL basic command streams without parameters and programming syntax; A command execution module is used to execute the APDL basic command flow to at least realize parameter-driven simulation modeling.

9. A CAE system, characterized in that: include: The simulation parameterized design device compatible with APDL command stream as described in claim 8.

Citation Information

Patent Citations

  • Text programming language compiling method based on decoupling architecture

    CN116501330A

  • DSL (Digital Subscriber Line) technology-based software construction method, device and equipment

    CN117908957A