CN117057108A - Python-based CAE software domain specific language system - Google Patents

Python-based CAE software domain specific language system Download PDF

Info

Publication number
CN117057108A
CN117057108A CN202310925942.XA CN202310925942A CN117057108A CN 117057108 A CN117057108 A CN 117057108A CN 202310925942 A CN202310925942 A CN 202310925942A CN 117057108 A CN117057108 A CN 117057108A
Authority
CN
China
Prior art keywords
python
data model
cae
model
json
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310925942.XA
Other languages
Chinese (zh)
Inventor
何其昀
胡明灿
石茂志
罗凯升
常兴华
刘化勇
陈亮中
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan University
Original Assignee
Sichuan University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan University filed Critical Sichuan University
Priority to CN202310925942.XA priority Critical patent/CN117057108A/en
Publication of CN117057108A publication Critical patent/CN117057108A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/20Design optimisation, verification or simulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2111/00Details relating to CAD techniques
    • G06F2111/04Constraint-based CAD
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2111/00Details relating to CAD techniques
    • G06F2111/10Numerical modelling
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

A CAE software domain specific language system based on Python, which models a static data model of an object implemented by CAE; modeling is carried out on dynamic parameter logic among data models; packaging the bottom kernel interface by adopting a Swig library, wherein the type of Python after packaging meets the type correspondence in C++; writing CAE business logic into a member function of a related data model Python class to establish a CAE business model; aiming at the used CAE business process, the business model and the data model thereof are arranged; and the dynamic driving execution of the business process is realized based on the CAE workflow engine, and the process state is displayed in real time. The invention uses Python to describe CAE field model and processing logic, adopts a service model built by Python standard library and SwigC++ package, etc., service modeling based on finite state machine and workflow engine, realizes Python DSL description of all service logic, and effectively improves field modeling efficiency and software architecture flexibility.

Description

Python-based CAE software domain specific language system
Technical Field
The invention belongs to the technical field of CAE software, and particularly relates to a specific language system in the CAE software field based on Python.
Background
Most foreign business and open source CAE software have their own domain specific language (Domain Specific Language, DSL), and in recent years there has been a trend that these CAE software have begun to use Python to encapsulate native domain code or directly use Python as DSL to describe the domain.
Representative of commercial software is Abaqus and Fluent, the former directly uses Python as an external DSL, and is divided into Session, mdb and Odb, and the three objects respectively correspond to a view, a model database and a calculation result database; the latter pushes out PyFluent in 2022R2, and uses the remote procedure call interface to start or connect the running Fluent process as a server, and then transmits a Python instruction to interact with the Fluent process, such as activating a turbulence model, setting object parameters, solving control, and the like. In open source software, SU2 solvers are packaged using Python, facilitating the field personnel to directly use Python to modify and extend physical models and computational methods, while PyFR directly uses Python and three-way packages to develop solvers, while adapting to the high performance computational development of various hardware platforms by using external DSL derived from the Python's Mako template engine.
Domestic open source software realizes domain script functions through an external library of Python, so that domain description based on Python is realized to a certain extent, but in general, the advantages of Python in object-oriented and language ecology are not fully utilized to process services, and a certain improvement space is provided for architecture and technical realization.
Disclosure of Invention
Aiming at the defects in the prior art, the invention designs a specific language system mechanism in the CAE software field based on Python and develops a corresponding software system, and the system is used for improving the flexibility of a CAE software development platform so as to rapidly customize CAE software oriented to the specific field.
In order to solve the technical problems, the invention is realized by the following steps:
a CAE software domain specific language system based on Python comprises the following specific steps:
s1, modeling a static data model of an object implemented by CAE;
s2, modeling is conducted on dynamic parameter logic among the data models in the step S1, wherein the modeling comprises parameters such as parameter constraint, association and control logic;
s3, packaging the bottom kernel interface into a Python interface by adopting a Swig library, wherein the packaged Python type meets the type correspondence in C++;
s4, writing CAE service logic into a member function of a related data model Python class, and establishing a CAE service model;
s5, aiming at the used CAE business process, arranging a business model and a data model to which the business model belongs;
s6, dynamic driving execution of the CAE business process is realized based on the CAE workflow engine, and the process state is returned to the front end for display in real time.
Further, the specific steps of the step S1 are as follows:
s11, a data model adopts a nested directed tree structure, a root node of the data model is an engineering or database node, the data model comprises geometry, grid, physics, numerical value, solution and result, the data model is separately managed, and the data is operated by combining with a current session model of a user;
s12, analyzing and injecting the data model into the member attribute of the Python class in the running process by adopting a Json format, and simultaneously supporting the direct encoding of the data model into the member attribute of the Python class;
s13, marking the data model with repeatable attribute or library attribute in the data model by using a user-defined semantic keyword, realizing delayed creation of the data model by using a lazy loading technology in operation, dynamically defining the data model according to a specific library element selected by a user, and creating a corresponding data object according to the data model.
Further, the specific steps of the data model in S12 are as follows:
s121, firstly, reading a Json object, traversing the Json non-basic type object, if the Json object contains repeatable attributes or library attributes, directly storing class attributes to a Python data model to be created in a delayed manner, and continuing traversing the next Json object; otherwise, analyzing each piece of sub-Json data of the Json object, and entering step S122;
s122, traversing all Json sub-objects, if the data type is a basic type, setting the Json object as a member attribute of the current Python data model, and continuing traversing the next Json object; otherwise, creating a Python sub-data model, traversing each Json sub-object in the sub-data set model, and feeding back the traversed Json non-basic type object in the step S121;
s123: and after all Json objects and sub-objects thereof are traversed, the Python data model is initially ended.
Further, the specific steps of the step S2 are as follows:
s21: aiming at a parameter logic part in the static data model in the step S1, modifying and generating an attribute modification method by using an attribute modifier built in Python, and writing a processing code in the method;
s22, searching and acquiring other parameters related to the parameters through a tree structure of a data model, wherein the tree structure is orderly stored by adopting red and black trees, and the searching time complexity is O (log N);
s23, when the software runs, of the data model recognizes that the parameter value or the modified parameter value is converted into a data object in C++ in real time and returned to the front end, and consistency of the operating data in Python and C++ is ensured.
Further, the specific steps of the step S5 are as follows:
s51, dividing CAE service into a plurality of independent services with dependency relationship, and combining the independent services into a state diagram so as to form a logic whole;
s52, arranging the workflow according to the state diagram, configuring the workflow by adopting a Json format, analyzing the workflow during operation, and transmitting the workflow to the front end for generating an interface;
s53, the flow nodes in the Json format configuration file are linked to the nodes of the data model tree, and the flow nodes and the data model are mutually bound;
s54, determining a Python function required to be called by the process operation through a method name registered in advance in a sub-object of the process node, and binding the process node and the service model with each other.
Further, the specific steps of the step S6 are as follows:
s61, recording whether each flow node is executed or not when the workflow engine runs;
s62, switching states according to the execution result of each flow node, and determining the flow node which is to be opened and can be used for executing the next step according to the states;
s63, selecting a next flow node to enter according to the next operation of the user, and returning to the step S61.
Compared with the prior art, the invention has the beneficial effects that:
the invention uses Python to describe CAE field model and processing logic, the system comprises a data model description module, a business model description module and a business process arranging and executing module; the system comprises a CAE data model for separately describing geometry, grid, physics, numerical value, solution and result, a service model established by adopting a Python standard library, swigC++ package and the like, and a service modeling and workflow engine based on a Finite State Machine (FSM); pythonDSL description of all business logics is realized, and the modeling efficiency and the flexibility of a software architecture can be effectively improved based on the DSL mechanism.
Drawings
FIG. 1 is a schematic flow chart of the present invention;
FIG. 2 is a schematic diagram of a data model tree structure according to the present invention;
FIG. 3 is a schematic diagram of a data model initialization process according to the present invention;
FIG. 4 is a timing diagram of the overall CAE software of the present invention running;
FIG. 5 is a schematic diagram of the CAE workflow engine status according to the present invention.
Detailed Description
The following describes the embodiments of the present invention in further detail with reference to the drawings and specific examples.
As shown in fig. 1, a CAE software domain specific language system based on Python comprises the following specific steps:
s1, modeling a static data model of an object implemented by CAE according to a data instance generated by software based on the data model at running time
S11, a data model adopts a nested directed tree structure, a root node of the data model is an engineering (Project) or database node, the data model comprises geometry, grid, physics, numerical value, solution and result, the data model is separately managed and is operated by combining with a current session model of a user, and the data model also comprises user information, software configuration and a session model pointing to the current data state as shown in FIG. 2;
s12, analyzing and injecting the data model into the member attribute of the Python class in the running process by adopting a Json format, and simultaneously supporting the direct encoding of the data model into the member attribute of the Python class;
s13, a data model (such as a material library, a boundary type library and a preset model parameter library) with repeatable attributes or library attributes is identified by using custom semantic keywords "$repeat" and "$library", a lazy loading technology is used in operation to realize delayed creation of the data model, the data model is dynamically defined according to a specific library element selected by a user, and then a corresponding data object is created according to the data model.
As shown in fig. 3, the data model in S12 has the following steps:
s121, firstly, reading a Json object, traversing a Json non-basic type (string, number) object, if the Json object contains repeatable attributes or library attributes, directly storing class attributes from the Json root object to a Python data model to be created in a delayed manner, and continuing traversing the next Json object; otherwise, analyzing each piece of sub-Json data of the Json object, and entering step S122;
s122, traversing all Json sub-objects, if the data type is a basic type, setting the Json object as a member attribute of the current Python data model, and continuing traversing the next Json object; otherwise, if the data type is dictionary or list type, creating a Python sub-data model, traversing each Json sub-object in the dictionary or list in the sub-data set model, and feeding back the traversed Json non-basic type object in the step S121;
s123: and after all Json objects and sub-objects thereof are traversed, the Python data model is initially ended.
S2, modeling the dynamic parameter logic among the data models in the step S1, wherein the modeling comprises parameter constraint, association, control logic and other parameters
S21: aiming at a parameter logic part in the static data model in the step S1, modifying and generating an attribute modification method such as set/get/delete and the like by using an attribute modifier "@ property" built in Python, and writing a processing code in the method;
s22, searching and acquiring other parameters related to the parameters through a tree structure of a data model, wherein the tree structure is orderly stored by adopting red and black trees, and the searching time complexity is O (log N);
s23, when the software runs, of the data model recognizes that the parameter value or the modified parameter value is converted into a data object in C++ in real time and returned to the front end, and consistency of the operating data in Python and C++ is ensured.
S3, packaging an interface of a bottom kernel (such as grid generation, data format conversion and iteration solution) into a Python interface by adopting a Swig library, wherein the packaged Python type and method meet the type and method in the corresponding C++;
and S4, writing CAE service logic into member functions of related data models Python based on the design, and establishing a CAE service model, wherein the CAE service model comprises services such as physical model selection, material setting, initial value condition setting, algorithm parameter setting, bottom kernel calling and the like.
The above is modeling of a data model and a service model, and is used for accepting CAE service operation of a user when software runs, as shown in fig. 4, taking a CAE resolving service operation during a typical running as an example, a specific method corresponding to the software is as follows:
after the GUI receives the user request, the front-end business service layer generates a corresponding Python script according to the input of the user; forwarding the Python script to a Python interpreter at the back end through RPC communication; the Python interpreter calls the corresponding service function to execute the service; updating a database by using the Python service function, forwarding downwards, and calling a kernel algorithm to execute resolving; the kernel returns the calculation result and stores the calculation result to the database; the database service sends a result update notification upwards; the GUI receives the result update notification and refreshes the interface display.
S5, aiming at CAE business processes used by users, arranging business models and data models to which the business models belong in an object-oriented mode, namely, each business model needs to be bound with the data model object to which the business model belongs.
S51, dividing CAE service into a plurality of independent services with dependency relationship, and combining the independent services into a state diagram so as to form a logic whole;
s52, arranging the workflow according to the state diagram, configuring the workflow by adopting a Json format, analyzing the workflow during operation, and transmitting the workflow to the front end for generating an interface;
s53, the flow nodes in the Json format configuration file are linked to the nodes of the data model tree, so that the flow nodes and the data model are mutually bound;
s54, determining a Python function required to be called by the process operation through a method name registered in advance in a sub-object of the process node, and binding the process node and the service model with each other.
S6, a CAE workflow engine based on a Finite State Machine (FSM) realizes dynamic driving execution of a CAE business process, and returns the process state to the front end for display in real time.
S61, recording whether each flow node is executed or not when the workflow engine runs;
s62, switching states according to the execution result of each flow node, and opening the flow node available for execution in the next step;
s63, selecting a next flow node to enter according to the next operation of the user, and returning to the step S61.
As shown in fig. 5, in the CAE workflow engine state diagram, the contents and steps of the model and numerical parameters set up later in the CFD software are also changed according to the opened physical model.
The foregoing is merely illustrative of the embodiments of this invention and it will be appreciated by those skilled in the art that variations may be made without departing from the principles of the invention, and such modifications are intended to be within the scope of the invention as defined in the claims.

Claims (6)

1. A CAE software domain specific language system based on Python, characterized in that: the method comprises the following specific steps:
s1, modeling a static data model of an object implemented by CAE;
s2, modeling is conducted on dynamic parameter logic among the data models in the step S1, wherein the modeling comprises parameters such as parameter constraint, association and control logic;
s3, packaging the bottom kernel interface into a Python interface by adopting a Swig library, wherein the packaged Python type meets the type correspondence in C++;
s4, writing CAE service logic into a member function of a related data model Python class, and establishing a CAE service model;
s5, aiming at the used CAE business process, arranging a business model and a data model to which the business model belongs;
s6, dynamic driving execution of the CAE business process is realized based on the CAE workflow engine, and the process state is returned to the front end for display in real time.
2. The Python-based CAE software domain specific language system of claim 1, wherein:
the specific steps of the step S1 are as follows:
s11, a data model adopts a nested directed tree structure, a root node of the data model is an engineering or database node, the data model comprises geometry, grid, physics, numerical value, solution and result, the data model is separately managed, and the data is operated by combining with a current session model of a user;
s12, analyzing and injecting the data model into the member attribute of the Python class in the running process by adopting a Json format, and simultaneously supporting the direct encoding of the data model into the member attribute of the Python class;
s13, the data model with repeatable attribute or library attribute is identified by using a user-defined keyword, a lazy loading technology is used in operation to realize delayed creation of the data model, the data model is dynamically defined according to a specific library element selected by a user, and a corresponding data object is created according to the data model.
3. The Python-based CAE software domain specific language system of claim 2, wherein:
the step of the data model in S12 includes the following steps:
s121, firstly, reading a Json object, traversing the Json non-basic type object, if the Json object contains repeatable attributes or library attributes, directly storing class attributes to a Python data model to be created in a delayed manner, and continuing traversing the next Json object; otherwise, analyzing each piece of sub-Json data of the Json object, and entering step S122;
s122, traversing all Json sub-objects, if the data type is a basic type, setting the Json object as a member attribute of the current Python data model, and continuing traversing the next Json object; otherwise, creating a Python sub-data model, traversing each Json sub-object in the sub-data set model, and feeding back the traversed Json non-basic type object in the step S121;
s123: and after all Json objects and sub-objects thereof are traversed, the Python data model is initially ended.
4. The Python-based CAE software domain specific language system of claim 1, wherein:
the specific steps of the step S2 are as follows:
s21: aiming at a parameter logic part in the static data model in the step S1, modifying and generating an attribute modification method by using an attribute modifier built in Python, and writing a processing code in the method;
s22, searching and acquiring other parameters related to the parameters through a tree structure of a data model, wherein the tree structure is orderly stored by adopting red and black trees, and the searching time complexity is O (log N);
s23, when the software runs, of the data model recognizes that the parameter value or the modified parameter value is converted into a data object in C++ in real time and returned to the front end, and consistency of the operating data in Python and C++ is ensured.
5. The Python-based CAE software domain specific language system of claim 1, wherein:
the specific steps of the step S5 are as follows:
s51, dividing CAE service into a plurality of independent services with dependency relationship, and combining the independent services into a state diagram so as to form a logic whole;
s52, arranging the workflow according to the state diagram, configuring the workflow by adopting a Json format, analyzing the workflow during operation, and transmitting the workflow to the front end for generating an interface;
s53, the flow nodes in the Json format configuration file are linked to the nodes of the data model tree, and the flow nodes and the data model are mutually bound;
s54, determining a Python function required to be called by the process operation through a method name registered in advance in a sub-object of the process node, and binding the process node and the service model with each other.
6. The Python-based CAE software domain specific language system of claim 1, wherein:
the specific steps of the step S6 are as follows:
s61, recording whether each flow node is executed or not when the workflow engine runs;
s62, switching states according to the execution result of each flow node, and determining the flow node which is to be opened and can be used for executing the next step according to the states;
s63, selecting a next flow node to enter according to the next operation of the user, and returning to the step S61.
CN202310925942.XA 2023-07-26 2023-07-26 Python-based CAE software domain specific language system Pending CN117057108A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310925942.XA CN117057108A (en) 2023-07-26 2023-07-26 Python-based CAE software domain specific language system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310925942.XA CN117057108A (en) 2023-07-26 2023-07-26 Python-based CAE software domain specific language system

Publications (1)

Publication Number Publication Date
CN117057108A true CN117057108A (en) 2023-11-14

Family

ID=88665400

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310925942.XA Pending CN117057108A (en) 2023-07-26 2023-07-26 Python-based CAE software domain specific language system

Country Status (1)

Country Link
CN (1) CN117057108A (en)

Similar Documents

Publication Publication Date Title
CN110825362B (en) Low-code application software development system and method
CN108765158B (en) Intelligent contract engine system based on block chain and contract execution method thereof
US5459868A (en) Interpretive object-oriented facility which can access pre-compiled classes
US7836428B2 (en) Declarative computer programming language method and system
US5307499A (en) Interpretive object-oriented facility which can access pre-compiled classes
JP5189986B2 (en) Extensible mechanism for object composition
US20120005650A1 (en) Hardware specific code generation
CN111666526A (en) Page generation method, device, equipment and storage medium
US9378458B2 (en) Method and apparatus for operating a finite state machine
CN106648662B (en) Report generation device and method based on project cost calculation description language BCL
JP2009289273A (en) Method for achieving software object
US20090288068A1 (en) Domain model concept for developing computer applications
CN106201480A (en) A kind of cockpit display Control System Software architecture management platform
CN111125440B (en) Monad-based persistent layer composite condition query method and storage medium
CN109976723B (en) Algorithm development platform, algorithm development method and computer readable storage medium
US7711740B2 (en) Data access layer design and code generation
US8935657B2 (en) Model-to-model transformation by kind
Guerra et al. A Framework for the Verification of UML Models. Examples Using Petri Nets.
Alessandria et al. Flutter Cookbook: Over 100 proven techniques and solutions for app development with Flutter 2.2 and Dart
Van Tendeloo Foundations of a multi-paradigm modelling tool
Lazăr et al. Tool support for fUML models
CN117057108A (en) Python-based CAE software domain specific language system
Lazar et al. Using a fUML Action Language to construct UML models
Märtin et al. Patterns and models for automated user interface construction–in search of the missing links
Cetina et al. Tool support for model driven development of pervasive systems

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination