Simulation model packaging method and system
By encapsulating the internal variables of the simulation model into output variables and writing EL language code in the simulation environment, the problem of non-convergence and error reporting of encapsulated simulation model during data interaction in third-party software is solved, and time synchronization and errors are achieved Diagnosis improves the operation efficiency and portability of the simulation model.
Patent Information
- Application Number
- CN202411369251.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-09-29
AI Technical Summary
After encapsulating the simulation model into an fmu file, internal variables such as simulation time and error information cannot be directly set to output variables, resulting in non-convergence, interruption of operation or errors during data interaction in third-party software, and the operator cannot Master the error information.
By encapsulating internal variables such as simulation time and error information into output variables, and writing EL language code in the simulation environment, controlling the running status of the simulation model, generating a deck platform, and encapsulating the simulation model into a fmu file.
The simulation model deployed in third-party laboratory management software can provide more functions, such as time synchronization and error diagnosis, improve the operation efficiency and accuracy of the simulation model, and enhance its portability and reusability.
Smart Images

Figure CN119397739A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of system simulation, and in particular to a simulation model packaging method and system. Background Art
[0002] With the advancement of science and technology and the actual needs of engineering, the demand for multidisciplinary collaborative joint simulation is very urgent. In the process of building a large-scale multi-domain simulation system, it is usually necessary to connect the simulation models built on multiple software platforms.
[0003] In recent years, breaking the constraints of incompatibility between mainstream simulation tools in different professional fields and realizing multidisciplinary, cross-platform, high-precision full-digital simulation is a very important development direction in the current simulation field. Under this trend, the FMI (Functional Mock-up Interface) standard was born in 2008 and has been widely and deeply applied. Now this standard has become the most accepted and widely used interface standard for interactive reuse of functional and performance models in the world. So far, more than 100 world-leading software-in-the-loop, hardware-in-the-loop, software development and other software and hardware tools support the FMI standard. Different modeling and simulation software can export their models into FMU (Functional Mock-up Unit) models through this standard, and then integrate them into other simulation software or platforms to achieve joint simulation, which solves the problem that has always been bothering us - how to use models developed by different modeling tools for joint simulation.
[0004] After the simulation model is encapsulated as an fmu file, the fmu file is deployed in the third-party laboratory management software, and the start, stop, and pause functions of the simulation model are all controlled by the system variables of the third-party laboratory management software. For example, when the simulation model is deployed in a third-party laboratory management software such as veristand, the ModelCommand variable is used to control the start, pause, and stop functions of the simulation model. In this process, the internal variables of the simulation model itself do not participate in controlling the state of the simulation model in the third-party laboratory management software.
[0005] The simulation model is ensured to run successfully in the simulation software, and then it is packaged into an fmu file and deployed in the third-party laboratory management software. In this process, whether it is deployed in the third-party laboratory management software or interacting with the new third-party software, some variables must be set as input variables, that is, some variables are controlled by the third-party software to input commands into the simulation model. Unless the original simulation model has sufficient adaptive capabilities, the simulation model will not converge, interrupt the operation, or report an error during the data interaction process. Because the simulation model has been packaged into an fmu file, the fmu file encounters various information that cannot be successfully run during the data interaction with the third-party software, including the error information of the simulation model itself, which cannot be grasped by the operator. In the original simulation model, the error information variable #error is an internal variable. In the process of packaging into an fmu file, the internal variable cannot be directly set as an output variable for output.
[0006] Another important internal variable of the simulation model is simulation time. In the original simulation model, simulation time is an internal variable. When encapsulating it into an fmu file, the internal variable cannot be directly set as an output variable for output.
[0007] In order to overcome these defects, the present application proposes a simulation model packaging method and system. Summary of the invention
[0008] The purpose of this application is to provide a simulation model packaging method and system to solve the above-mentioned problems.
[0009] To achieve the above objectives, this application provides the following technical solutions:
[0010] The present application provides a simulation model packaging method, comprising:
[0011] Introducing internal variables into a pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables;
[0012] Compiling the simulation model, generating components, and verifying the components;
[0013] Establish a simulation environment based on the components, write EL language code in the simulation environment, and control the running state of the simulation model;
[0014] A deck platform is generated by using the simulation environment and the EL language code, and the simulation model is packaged into an fmu file based on the deck platform.
[0015] Further, in the step of introducing internal variables into the pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables, the following steps are specifically included:
[0016] The simulation time is encapsulated into a simulation time component, the output of the simulation time component is a simulation time value, and the output is set to a real value of the analog type; the error information is encapsulated into an error information component, the output of the error information component is an error information value, and the output is set to a real value of the analog type.
[0017] Furthermore, the steps of compiling the simulation model, generating components, and verifying the components specifically include the following steps:
[0018] Placing the packaged simulation time component and error information component and the main loop model of the simulation model in the same screen, and compiling them;
[0019] After the simulation model is compiled, components are generated and the components are verified.
[0020] Furthermore, in the step of establishing a simulation environment based on the component, writing EL language code in the simulation environment, and controlling the running state of the simulation model, the following steps are specifically included:
[0021] After component verification, a simulation environment is established, and EL language code is written in the simulation environment;
[0022] Introducing the special internal variable in the EL language code, and defining the running state of the simulation model under different assignment conditions of the special internal variable;
[0023] Controlling the simulation model includes, but is not limited to: controlling the simulation model to initialize global variables, and controlling the simulation model to run and stop.
[0024] Furthermore, in the step of generating a deck platform through the simulation environment and the EL language code, and encapsulating the simulation model into an fmu file based on the deck platform, the following steps are specifically included:
[0025] Generate a deck platform through the simulation environment and the EL language code, that is, based on the EL experiment code;
[0026] Setting input variables and output variables on the deck platform;
[0027] The simulation model is encapsulated as an fmu file using the deck platform, and the fmu file type for interacting with third-party software is selected.
[0028] Furthermore, the step of setting input variables and output variables on the deck platform specifically includes the following steps:
[0029] Define the variables controlled by the third-party software as input variables;
[0030] The simulation time value output by the simulation time component and the error information value output by the error information component are defined as output variables;
[0031] The special internal variables are defined as input variables and output variables;
[0032] The output variables include process values calculated for the simulation model, but are not limited to: temperature, pressure, flow, and liquid level.
[0033] Furthermore, the fmu file is deployed by third-party software;
[0034] After deployment, the special internal variables set by the deck platform and the control variables of the third-party software are used to jointly control the operation status of the simulation model;
[0035] The running status of the simulation model in the third-party software is tested to determine whether to output the simulation time value and the error information value, and to perform data interaction with the third-party software.
[0036] The present application provides a simulation model packaging system, comprising:
[0037] Model building module: introduces internal variables into a pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables;
[0038] Compilation module: compiles the simulation model, generates components, and verifies the components;
[0039] Control module: establish a simulation environment based on the components, write EL language code in the simulation environment, and control the running state of the simulation model;
[0040] Packaging module: Generates a deck platform through the simulation environment and the EL language code, and packages the simulation model into an fmu file based on the deck platform.
[0041] The present application provides a device, which includes a processor and a memory coupled to the processor, wherein the memory stores program instructions for implementing a simulation model packaging method; the processor is used to execute the program instructions stored in the memory to implement a simulation model packaging.
[0042] The present application provides a storage medium storing program instructions executable by a processor, wherein the program instructions are used to execute a simulation model packaging method.
[0043] The present application provides a simulation model packaging method and system, which has the following beneficial effects:
[0044] (1) By encapsulating important internal variables such as simulation time and error information as output variables, the simulation model deployed in the third-party laboratory management software can provide more functions; for example, simulation time can be used to write sequential control logic or trigger important events to achieve time synchronization between the simulation model and the third-party software, thereby realizing time synchronization of multi-platform joint simulation; and error information can be used for error diagnosis;
[0045] (2) The introduction of special internal variables (simulinkSFunctionMode) and the use of EL language codes make the control of the simulation model more flexible and convenient; by changing the value of simulinkSFunctionMode, the initialization, running, and stopping states of the simulation model can be controlled;
[0046] (3) The output accuracy problem of the simulation time component was solved by taking logarithmic operations, avoiding the accuracy loss caused by insufficient resolution of the analog acquisition module and improving the operating efficiency and accuracy of the simulation model;
[0047] (4) After the simulation model is encapsulated as an fmu file, it is more convenient to deploy and co-simulate in third-party software that supports the FMI standard, which enhances the portability and reusability of the simulation model and promotes multidisciplinary and cross-platform simulation cooperation. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of a simulation model packaging method according to Embodiment 1 of the present application;
[0049] Figure 2 A schematic diagram of the structure of a simulation model packaging system according to Embodiment 2 of the present application;
[0050] Figure 3 This is a schematic diagram of the device structure of Example 3 of the present application;
[0051] Figure 4 This is a schematic diagram of the storage medium structure of Example 4 of the present application. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0054] Example 1
[0055] See also Figure 1 , is a flow chart of a simulation model packaging method according to Embodiment 1 of the present application; the steps include:
[0056] S1: Introducing internal variables into a pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables.
[0057] In this embodiment, a simulation model is established based on the dynamic simulation software EcosimPro. The simulation time time is encapsulated as a simulation time component, the simulation time component outputs a simulation time value, and the output is set as a real value of the analog type; the error information error is encapsulated as an error information component, the error information component outputs an error information value, and the output is set as a real value of the analog type.
[0058] Specifically, for the simulation models of hydrogen-helium refrigerators and hydrogen-helium liquefiers, the simulation time under complex working conditions is a very large constant, which can easily be hundreds of thousands of seconds. It is very necessary to transmit the simulation time to the outside when encapsulating it into an fmu file. When interacting with third-party software, the simulation time of the simulation model can be used to write the logic of sequential control, or the simulation time of the simulation model can be used to trigger certain important events, so as to achieve time synchronization between the simulation model and the third-party software.
[0059] The simulation time is encapsulated into a simulation time component and output as a real value of analog type. When performing HIL hardware in-loop simulation, due to the resolution problem of the analog acquisition module, if the simulation time is directly sent to the third-party software, the accuracy is too low. In this case, the real value of the analog type output by the simulation time component can be taken as the logarithm of 10, and the result of the logarithm can be sent to the third-party software as a real value of analog type. In the third-party software, the result after taking the logarithm is then antilogarithmized to obtain the complete real value of the analog type, that is, the original simulation time.
[0060] S2: Compile the simulation model, generate components, and verify the components.
[0061] In this embodiment, the simulation time component and the error information component do not need to be connected to the main loop of the simulation model. It is only necessary to place the packaged simulation time component and the error information component and the main loop model of the simulation model in the same screen and run smoothly after compilation.
[0062] After the simulation model is compiled, a component (partition) is generated, and the component (partition) is verified (validated).
[0063] S3: Establishing a simulation environment based on the components, writing EL language codes in the simulation environment, and controlling the running state of the simulation model.
[0064] In this embodiment, a simulation environment (experiment) is established after component verification, and EL language code is written in the simulation environment (experiment).
[0065] The special internal variable (simulinkSFunctionMode) is introduced into the EL language code to define the running state of the simulation model under different assignment conditions of the special internal variable (simulinkSFunctionMode). For example: when simulinkSFunctionMode==1, the simulation model initializes global variables; when simulinkSFunctionMode==3, the simulation model starts running; when simulinkSFunctionMode==5, the simulation model stops running.
[0066] S4: Generate a deck platform through the simulation environment and the EL language code, and encapsulate the simulation model into an fmu file based on the deck platform.
[0067] In this embodiment, the deck platform is generated through the simulation environment (experiment) and the EL language code, that is, based on the ELexperiment code.
[0068] Input variables and output variables are set on the deck platform: variables controlled by third-party software are defined as input variables; simulation time values output by the simulation time component and error information values output by the error information component are defined as output variables; special internal variables are defined as input variables and output variables; variables calculated and output by the simulation model, such as temperature, pressure, flow, liquid level, etc., are defined as output variables.
[0069] The simulation model is encapsulated as an fmu file using the deck platform, and the fmu file type for interacting with third-party software is selected. The fmu file is deployed by the third-party software; after deployment, the operation state of the simulation model is jointly controlled by the special internal variables set by the deck platform and the control variables of the third-party software. The operation state of the simulation model in the third-party software is tested, and it is determined whether to output the simulation time value and the error information value, and to interact with the third-party software for data.
[0070] Specifically, when the generated fmu file is deployed by third-party software, such as Veristand, the different values of the special internal variable simulinkSFunctionMode can be used on the workspace interface to control the running state of the entire simulation model. This method combines the control variables provided by the third-party laboratory management software, such as simulinkSFunctionMode and Model Command, and is more convenient to operate when the simulation model is deployed and run.
[0071] It can be understood that the simulation time value output by the simulation time component can be output to third-party software for use, and if necessary, logarithmic operation can be performed before output to avoid the problem of low acquisition accuracy in the analog acquisition module. The simulation time can be used to write sequential control logic, or the simulation time of the simulation model can be used to trigger certain important events, so as to achieve time synchronization between the simulation model and the third-party software, thereby realizing time synchronization of multi-platform joint simulation.
[0072] The error information value output by the error information component can be used for error diagnosis. Before developing a simulation model with sufficient adaptive capabilities, many errors will be encountered during the debugging process of interacting with third-party software. By observing the value of the error information variable, it can be determined whether the error is caused by the simulation model itself or by external operations, that is, fault diagnosis in the multi-platform joint simulation debugging process.
[0073] In summary, in Example 1 of the present application, components and a simulation environment are generated by introducing internal variables into a simulation model; a deck platform is generated based on the simulation environment and EL language code; and the simulation model is encapsulated into an fmu file using the deck platform. When the fmu file generated in the present application is deployed in a third-party laboratory management software such as Veristand, the encapsulated simulation model can be provided with more functions and more convenient to operate with the help of the introduced special internal variables.
[0074] Example 2
[0075] See also Figure 2, is a structural diagram of a simulation model packaging system in Example 2 of the present application; the specific contents include:
[0076] Model building module: introduces internal variables into a pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables;
[0077] Compilation module: compiles the simulation model, generates components, and verifies the components;
[0078] Control module: establish a simulation environment based on the components, write EL language code in the simulation environment, and control the running state of the simulation model;
[0079] Packaging module: Generates a deck platform through the simulation environment and the EL language code, and packages the simulation model into an fmu file based on the deck platform.
[0080] Example 3
[0081] See also Figure 3 , is a schematic diagram of the device structure of Embodiment 3 of the present application. The device 50 includes a processor 51 and a memory 52 coupled to the processor 51 .
[0082] The memory 52 stores program instructions for implementing the above-mentioned simulation model packaging method.
[0083] The processor 51 is used to execute program instructions stored in the memory 52 to implement a simulation model package.
[0084] The processor 51 may also be referred to as a CPU (Central Processing Unit).
[0085] The processor 51 may be an integrated circuit chip with signal processing capabilities. The processor 51 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0086] Example 4
[0087] See also Figure 4, which is a schematic diagram of the structure of the storage medium of Example 4 of the present application. The storage medium of the embodiment of the present application stores a program file 61 that can implement all the above methods, wherein the program file 61 can be stored in the above storage medium in the form of a software product, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or a computer, a server, a mobile phone, a tablet, and other devices.
[0088] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.
[0089] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
[0090] Although the embodiments of the present application have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the appended claims and their equivalents.
[0091] Of course, the present invention may have many other implementations. Based on this implementation, other implementations obtained by ordinary technicians in this field without any creative work are all within the scope of protection of the present invention.
Claims
1. A simulation model packaging method, characterized in that: include: Introducing internal variables into a pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables; Compiling the simulation model, generating components, and verifying the components; Establish a simulation environment based on the components, write EL language code in the simulation environment, and control the running state of the simulation model; A deck platform is generated by using the simulation environment and the EL language code, and the simulation model is packaged into an fmu file based on the deck platform.
2. A simulation model packaging method according to claim 1, characterized in that: In the step of introducing internal variables into a pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables, the following steps are specifically included: The simulation time is encapsulated into a simulation time component, the output of the simulation time component is a simulation time value, and the output is set to a real value of the analog type; the error information is encapsulated into an error information component, the output of the error information component is an error information value, and the output is set to a real value of the analog type.
3. A simulation model packaging method according to claim 1, characterized in that: The steps of compiling the simulation model, generating components, and verifying the components specifically include the following steps: Placing the packaged simulation time component and error information component and the main loop model of the simulation model in the same screen, and compiling them; After the simulation model is compiled, components are generated and the components are verified.
4. A simulation model packaging method according to claim 1, characterized in that: The steps of establishing a simulation environment based on the components, writing EL language code in the simulation environment, and controlling the running state of the simulation model specifically include the following steps: After component verification, a simulation environment is established, and EL language code is written in the simulation environment; Introducing the special internal variable in the EL language code, defining the running state of the simulation model under different assignment conditions of the special internal variable, and controlling the simulation model to stop; Controlling the simulation model includes, but is not limited to: controlling the simulation model to initialize global variables, and controlling the simulation model to run and stop.
5. A simulation model packaging method according to claim 1, characterized in that: In the step of generating a deck platform through the simulation environment and the EL language code, and encapsulating the simulation model into an fmu file based on the deck platform, the following steps are specifically included: Generate a deck platform through the simulation environment and the EL language code, that is, based on the EL experiment code; Setting input variables and output variables on the deck platform; The simulation model is encapsulated as an fmu file using the deck platform, and the fmu file type for interacting with third-party software is selected.
6. A simulation model packaging method according to claim 5, characterized in that: The steps of setting input variables and output variables on the deck platform specifically include the following steps: Define the variables controlled by the third-party software as input variables; The simulation time value output by the simulation time component and the error information value output by the error information component are defined as output variables; The special internal variables are defined as input variables and output variables; The output variables include process values calculated for the simulation model, but are not limited to: temperature, pressure, flow, and liquid level.
7. A simulation model packaging method according to claim 1, characterized in that: The fmu file is deployed by third-party software; After deployment, the special internal variables set by the deck platform and the control variables of the third-party software are used to jointly control the operation status of the simulation model; The running status of the simulation model in the third-party software is tested to determine whether to output the simulation time value and the error information value, and to perform data interaction with the third-party software.
8. A system for a simulation model packaging method according to claim 1, characterized in that: include: Model building module: introduces internal variables into a pre-established simulation model, wherein the internal variables include simulation time, error information, and special internal variables; Compilation module: compiles the simulation model, generates components, and verifies the components; Control module: establish a simulation environment based on the components, write EL language code in the simulation environment, and control the running state of the simulation model; Packaging module: Generates a deck platform through the simulation environment and the EL language code, and packages the simulation model into an fmu file based on the deck platform.
9. A device, characterized in that: The device includes a processor and a memory coupled to the processor, wherein the memory stores program instructions for implementing a simulation model packaging method as described in any one of claims 1-7; and the processor is used to execute the program instructions stored in the memory to implement a simulation model packaging.
10. A storage medium, characterized in that: Program instructions executable by a processor are stored, and the program instructions are used to execute a simulation model packaging method as described in any one of claims 1-7.
Citation Information
Patent Citations
Static analysis method and platform for product packaging and transportation, storage medium and application
CN112270116A
Real-time dynamic simulation platform for large hydrogen liquefier or refrigerator
CN114035493A
Modeling simulation method and device for aero-engine and storage medium
CN114625026A
Code packaging method and device
CN114721666A
Joint simulation method for converting FMU model into Modelica model
CN114860388A