Simulation method, device, computer equipment and storage medium
By encapsulating the simulation model into a combined structure of the simulink model and the FMU model, we use our respective advantages to avoid disadvantages, and achieve efficient simulation debugging, solving the problem of time-consuming adjustment of large models, and improving simulation efficiency and real-time performance.
Patent Information
- Application Number
- CN202411514085.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-10-29
AI Technical Summary
During the existing simulation debugging process, the larger the model, the longer the adjustment time is, resulting in low simulation debugging efficiency and waste of manpower and financial resources. The existing methods fail to effectively improve simulation debugging efficiency.
The target simulation model is encapsulated into a simulink model + n FMU models. Run through data interaction parameters. Only when the FMU model is adjusted, the simulink model will not be affected, and the code generation and compilation process will be reduced. Multi-threaded parallel loading of the FMU model is used to take advantage of the advantages of simulink and FMU models to avoid their respective disadvantages.
It improves simulation debugging efficiency, reduces local adjustment time, realizes real-time simulation and synchronous transmission, and improves simulation computing efficiency and accuracy.
Smart Images

Figure CN119047208B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of simulation control technology, and in particular to a simulation method, device, computer equipment and storage medium. Background Art
[0002] With the development of simulation technology, more and more scenarios have simulation needs. For example, simulation technology is needed in the development process of complex systems such as aerospace, automobiles, and robots. In actual simulation applications, the simulation model is usually more complex and may be integrated by simulation modules in multiple fields. Different users develop different models in different scenarios. In the end, all sub-models must be integrated into a large model, such as Figure 1 shown.
[0003] As we all know, semi-physical is divided into several key steps, including modeling integration, subsystem division, code generation, model compilation, interface definition and hardware integration, and real-time operation. During the real-time operation and debugging process, if there is a problem with the simulation model, the model needs to be adjusted, and the steps of identifying subsystems, generating code, and compiling models need to be repeated. The larger the model, the longer the process takes, which ultimately leads to low efficiency of simulation debugging and wastes a lot of manpower and financial resources.
[0004] The Chinese application with application number CN202311864964.6 discloses a spacecraft motion simulation system and related products. It mentions that some models integrated in the spacecraft motion simulation system will be exported as FMU models, and the models will be integrated into different simulation environments by utilizing their independent and portable characteristics, and the parameters will be adjusted and modified by modifying different FMU parameters.
[0005] This method can improve the efficiency of simulation debugging to a certain extent, but it does not specify which models should be exported as FMU models. How to improve them to further improve the efficiency and feasibility of simulation debugging is a technical problem that needs to be solved urgently in this field. Summary of the invention
[0006] Based on this, it is necessary to provide a simulation method, apparatus, computer device and computer-readable storage medium that can improve simulation efficiency in response to the above technical problems.
[0007] In a first aspect, the present application provides a simulation method. The method comprises:
[0008] Construct multiple submodules of the target simulation model;
[0009] Determine a target submodule among the plurality of submodules, encapsulate the target submodule into a simulink model, and encapsulate the submodules except the target submodule among the plurality of submodules into an FMU model;
[0010] Obtaining data interaction parameters between the simulink model and multiple FMU models;
[0011] The target simulation model is run according to the data interaction parameters.
[0012] In one of the embodiments, determining a target submodule among the plurality of submodules includes: determining a submodule with the fastest processing rate among the plurality of submodules as the target submodule.
[0013] In one of the embodiments, the data interaction parameters include a data mapping relationship between the simulink model and a plurality of FMU models;
[0014] The running the target simulation model according to the data interaction parameters includes:
[0015] Load and run the FMU model;
[0016] According to the data mapping relationship, the simulink model reads the calculation result of the corresponding FMU model as input data, performs simulation calculation according to the input data, obtains the simulation calculation result of the simulink model, and writes the simulation calculation result into the data cache unit;
[0017] The FMU model reads the required input signal data, performs simulation calculation according to the input signal data, obtains the simulation calculation result of the FMU model, and writes the simulation calculation result of the FMU model into the data cache unit.
[0018] In another embodiment, the data interaction parameters further include a rate ratio; and running the target simulation model according to the data interaction parameters further includes:
[0019] Each of the FMU models detects the number of simulation steps of the simulink model. If the number of simulation steps meets its own rate ratio, the current FMU model executes the steps of reading the required input signal data and performing simulation calculations according to the input signal data.
[0020] In another embodiment, the method further comprises:
[0021] Determining the number of the FMU models to be loaded;
[0022] A corresponding number of multithreads are enabled, and the multithreads load the corresponding FMU model in parallel.
[0023] In another embodiment, the data interaction parameters also include data storage parameters of the models of each submodule; and writing the simulation calculation results of the FMU model into the data cache unit includes:
[0024] The thread corresponding to the FMU model calculates the starting address of the cache unit of the FMU model data and the offset of each signal based on the starting address according to the data storage parameters, and writes the simulation calculation result into the data cache unit according to the starting address and the offset.
[0025] In another embodiment, the data cache unit includes any one or more of a local shared memory, a reflective memory card, and a network communication application.
[0026] In a second aspect, the present application also provides a simulation device. The device comprises:
[0027] A construction module, used for constructing multiple sub-modules of a target simulation model;
[0028] Determine a target submodule among the plurality of submodules, encapsulate the target submodule into a simulink model, and encapsulate the submodules except the target submodule among the plurality of submodules into an FMU model;
[0029] A configuration parameter acquisition module is used to obtain data interaction parameters between the simulink model and multiple FMU models;
[0030] A simulation module is used to run the target simulation model according to the data interaction parameters.
[0031] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the simulation method in each of the above embodiments are implemented.
[0032] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the simulation method of each of the above embodiments are implemented.
[0033] The above-mentioned simulation method, device, computer equipment and storage medium, by encapsulating the target simulation model into a simulink model + n FMU models, when the FMU model in the target simulation model needs to be adjusted, only the corresponding FMU model needs to be adjusted, and the simulink model does not need to be moved, so there is no need to go through the process of generating code and compiling on the simulink model, thereby reducing the time consumption of local adjustment of the target simulation model. If the simulink model needs to be adjusted, only the process of generating code and compiling needs to be followed on the small simulink model. The small model is relatively small, and the time consumption of generating code + compiling after adjustment is relatively short. Since the time consumption of local adjustment of the target simulation model is reduced, it is convenient to make local adjustments to the target simulation model, thereby improving the simulation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a simulink large model structure diagram in one embodiment;
[0035] Figure 2 A schematic diagram of a simulation method in one embodiment;
[0036] Figure 3 A diagram of a simulink joint multi-FMU model joint simulation structure in one embodiment;
[0037] Figure 4 A schematic diagram of a process flow of running a target simulation model according to data interaction parameters in an embodiment;
[0038] Figure 5 A schematic diagram of the data mapping relationship between a simulink model and multiple FMU models in one embodiment;
[0039] Figure 6 A data interaction structure diagram in one embodiment;
[0040] Figure 7 A schematic diagram of the structure of a simulation device in an embodiment;
[0041] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. 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.
[0043] The present application provides a simulation method, which is applied to a simulation terminal, wherein the simulation terminal may be a terminal device with computing and processing functions, such as a computer and a tablet computer.
[0044] In one embodiment, Figure 2 As shown, a simulation method is provided, taking the method applied to a simulation terminal as an example, comprising the following steps:
[0045] Step S202, constructing multiple sub-modules of the target simulation model.
[0046] Specifically, a simulation model built by a user according to an actual application scenario is obtained. The simulation model can be divided into multiple sub-modules according to factors such as protocol, function, and scenario.
[0047] Step S204, determining a target submodule among the plurality of submodules, encapsulating the target submodule into a Simulink model, and encapsulating the submodules except the target submodule among the plurality of submodules into an FMU model.
[0048] In this embodiment, among the multiple sub-modules in the target simulation model, only the target sub-module is encapsulated as a simulink model, and the other modules are encapsulated as FMU models, that is, the target simulation model is encapsulated as one simulink model + n FMU models.
[0049] If the target simulation model is encapsulated as a large Simulink model, when the model needs to be adjusted, the steps of identifying subsystems, generating code, and compiling the model need to be repeated. The larger the model, the longer the code generation + compilation process takes.
[0050] In this embodiment, the target simulation model is encapsulated as a simulink model + n FMU models. The FMU (Functional Mock-up Unit) file is a file exported according to the FMI standard, and its extension is ".FMU". Its essence is a compressed package. The compressed package of the FMU contains ".xml" files used to describe model interface information and data, files used to implement model dynamic behavior (such as C code or binary files), and other files and data that users want to include in the FMU. Therefore, when the target simulation model needs to adjust the FMU model, only the corresponding FMU model needs to be adjusted, and the simulink model does not need to be moved, so there is no need to generate code and compile the process on the simulink model. If the simulink model is adjusted, it is only necessary to generate code and compile the process on the small simulink model. The small model is small, and the time consumption of generating code + compiling after adjustment is relatively short.
[0051] Step S206, obtaining data interaction parameters between the simulink model and multiple FMU models.
[0052] Specifically, the data interaction parameters between the simulink model and the multiple FMU models are used to indicate the interaction between the simulink model and the multiple FMU models.
[0053] Step S208: running the target simulation model according to the data interaction parameters.
[0054] Based on the data interaction parameters, the interactive operation between the Simulink model and multiple FMU models is realized to jointly realize the simulation operation of the target simulation model.
[0055] The simulation method of the present application first constructs the target simulation model into multiple sub-modules, and selects one of them as the target sub-module, encapsulates the target sub-module into a simulink model, and encapsulates other sub-modules into FMU modules. The overall encapsulation is a simulink model + n FMU models, which can combine the characteristics of the simulink model and the FMU model to give full play to their respective advantages and avoid their respective disadvantages.
[0056] Specifically: The advantage of the simulink model is that it includes clock control, and real-time simulation can be achieved through step size. The disadvantage is that each adjustment requires redivision of the subsystem, and the process of generating code and compiling. The advantage of the FMU model is that each adjustment only requires adjustment of the corresponding model, and the process of generating code and compiling is followed for the modified parts. The disadvantage is that it does not include a clock module, and real-time simulation cannot be achieved step by step. When simulating between models, either all FMU models are configured with a unified clock module, or each FMU model is configured with a clock module, and then the synchronization of the clock modules is guaranteed, and it must be very accurate, otherwise accurate synchronous simulation cannot be achieved. Therefore, the present application: 1. First, construct multiple sub-modules of the target simulation model, select a module as the target sub-module, and encapsulate it as a simulink module. When the simulink model needs to be adjusted in the target simulation model, there is no need to redivide the subsystem each time the adjustment is made. It is only necessary to generate code and compile the small simulink model. In addition, when constructing multiple sub-modules of the target simulation model, the sub-module encapsulated as the simullink module can be reduced as much as possible, and the model structure of the sub-module can be reduced. The smaller the model, the shorter the time it takes to generate code + recompile after adjustment. Compared with the Chinese application with application number CN202311864964.6, the adjustment time of the simulink model can be further reduced, that is, the time it takes to adjust the local part of the target simulation model. Therefore, it is convenient to adjust the local part of the target simulation model, thereby improving the simulation efficiency; 2. Encapsulate all sub-modules except the target sub-module into FMU models. Compared with the Chinese application with application number CN202311864964.6, the adjustment time of the simulink model can be further reduced, that is, the time it takes to adjust the local part of the target simulation model. Therefore, it is convenient to adjust the local part of the target simulation model, thereby improving the simulation efficiency. .6 Chinese application can give full play to the advantages of FMU model. When the FMU model needs to be adjusted in the target simulation model, only the corresponding FMU model needs to be adjusted, and the simulink model does not need to be moved, so there is no need to generate code and compile on the simulink model. This also reduces the time-consuming local adjustment of the target simulation model; 3. Running the target simulation model through the data interaction parameters between the simulink model and multiple FMU models can avoid the disadvantages of the FMU model, and there is no need to configure a separate clock module to achieve real-time simulation and synchronous transmission.
[0057] Therefore, the present application encapsulates the whole into a simulink model + n FMU models. Compared with the structure of using all simulink models, or all FMU models, or non-selectively using several simulink models + several FMU models, it can give full play to the advantages of simulink models and FMU models to the greatest extent possible, avoid the disadvantages of the two, and maximize the efficiency of simulation debugging while ensuring the real-time and synchronization of simulation, ensuring its feasibility and accuracy. It is worth noting that the key core idea of the present invention is: a structure of a simulink model + n FMU models, which submodule is selected as the target submodule, how to obtain data interaction parameters between the two, and how to run the overall target simulation model. Several preferred embodiments are given later, but are not limited to this.
[0058] In another embodiment, the determining a target submodule among the plurality of submodules comprises: determining a submodule with the fastest processing rate among the plurality of submodules as the target submodule.
[0059] When the simulink model is adjusted, it is necessary to generate code and compile the simulink model. By determining the submodule with the fastest processing rate among multiple submodules as the target submodule, if the simulink model is adjusted, the module with the fastest processing rate can also generate code and compile the process at a fast processing rate, thereby improving processing efficiency.
[0060] In another embodiment, the data interaction parameters include data mapping relationships between the simulink model and multiple FMU models.
[0061] Specifically, the data mapping relationship between the simulink model and multiple FMU models is used to indicate the mapping relationship between the input data and output data between the Simulink model and multiple FMU models. Regardless of whether it is a simulink model or an FMU model, each model interacts with data through input / output pins. Each input / output pin has its unique identification ID. Then the input / output pins of these models need to be matched one by one for data communication. For example, the data of the FMU model is output to the input pin of the simulink model through the output pin. If the FMU model and the simulink model have multiple output pins and input pins respectively, the mapping relationship between the ID of the output pin of the FMU model and the ID of the input pin of the simulink model can be specified respectively. Specifying the connection ID object of the input / output pin is the mapping process.
[0062] like Figure 3As shown, the operation of the target simulation model according to the data interaction parameters includes: loading and running the FMU model; according to the data mapping relationship, the simulink model reads the calculation result of the corresponding FMU model as input data via the IO Interface, performs simulation calculation according to the input data, obtains the simulation calculation result of the simulink model, and writes the simulation calculation result into the data cache unit; the FMU model reads the required input signal data, performs simulation calculation according to the input signal data, obtains the simulation calculation result of the FMU model, and writes the simulation calculation result of the FMU model into the data cache unit via the IO Interface. In addition, in addition to connecting to the FMU model, the IO Interface can also be optionally connected to other simulation applications or hardware simulation devices for application in a semi-physical simulation system.
[0063] Specifically, the data interaction between the simulink model and the FMU model is decoupled. In order not to affect the simulation process of the main model, the data between the simulink model and the FMU model is exchanged through a data storage device. In one embodiment, the data cache unit includes any one or more of a local shared memory, a reflective memory card, and a network communication application.
[0064] The data mapping relationship describes the mapping relationship between the signals of the simulink model and each FMU model. Based on the data mapping relationship, when running the simulation, after reading the data of the simulink input signal from the data cache unit, the simulink model simulation operation is completed, and the simulation result data is written into the data cache unit. The FMU model obtains the corresponding input signal data, completes the simulation operation of the target FMU model, obtains the simulation result of the FMU model, and writes the simulation result of the FMU model into the data cache unit.
[0065] In another embodiment, the data interaction parameters also include data interaction parameters, such as Figure 4 As shown, running the target simulation model according to the data interaction parameters includes:
[0066] Step S402, loading and running the FMU model.
[0067] Step S404, according to the data mapping relationship, the simulink model reads the calculation result of the corresponding FMU model as input data, performs simulation calculation according to the input data, obtains the simulation calculation result of the simulink model, and writes the simulation calculation result into the data cache unit.
[0068] Step S406: Each FMU model detects whether the number of simulation steps of the simulink model meets its own rate ratio. If yes, execute:
[0069] Step S408, the current FMU model reads the required input signal data, performs simulation calculation according to the input signal data, obtains the simulation calculation result of the FMU model, and writes the simulation calculation result of the FMU model into the data cache unit.
[0070] Specifically, if Figure 5 As shown in the figure, the configuration file of data interaction parameters describes the mapping relationship between the simulink model and each FMU model signal. The configuration file also describes the simulation step of each FMU. When parsing the configuration, the step of the FMU and the simulation step of the simulink model are converted into a rate ratio. Assuming the rate ratio is R, the simulink simulation step is , the step size of FMU is , then the relationship between these three should be Since the Simulink model is the main control part, the step size is the smallest, so R must be greater than or equal to 1.
[0071] Specifically, all loaded FMU model threads continuously detect the number of simulink model simulation steps. If it meets their own rate ratio, the input signal data involved in the current FMU is read out from the data cache unit and the FMU simulation calculation is completed.
[0072] In another embodiment, the simulation method further includes: determining the number of the FMU models to be loaded; enabling a corresponding number of multithreads, the multithreads loading the corresponding FMU models in parallel.
[0073] In this embodiment, a multi-threaded method is adopted, and each FMU model adopts independent thread scheduling to ensure the isolation of the data of the FMU model and the real-time performance of the simulation calculation. Taking the Chinese application with application number CN202311864964.6 as an example, after establishing the corresponding system model part in Matlab / Simulink, the S-Function module is called to read the external S function generated by AMESim, and then the function module that can read the FMU file is called to encapsulate the FMU file from SimulationX, and create their signal input and output interfaces, and connect with the interface of the simulation model already existing in Matlab / Simulink. Calling the S-Function module to read the external S function generated by AMESim is actually to put the reading of the fmu file in the model. The execution of the entire model is executed in sequence (serial). The larger the model, the more subsystems, and the longer the simulation calculation takes. However, this application is external parallel computing, with fast computing efficiency and high simulation calculation efficiency, and can support large-scale simulation model systems with smaller step sizes.
[0074] In another embodiment, the data interaction parameters also include data storage parameters of the model of each sub-module; writing the simulation calculation results of the FMU model into the data cache unit includes: the thread corresponding to the FMU model calculates the cache unit starting address of the FMU model data and the offset of each signal based on the starting address according to the data storage parameters, and writes the simulation calculation results into the data cache unit according to the starting address and the offset.
[0075] Specifically, in the data cache unit, the blocks of interactive data between different FMU models and Simulink models are also isolated, such as Figure 6 As shown. By configuring the data storage parameters, the starting address of the cache unit for each FMU model data and the offset of each signal in different FMUs based on the starting address can be calculated. In this way, each computing thread only needs to be responsible for the data reading and writing of the current FMU model data block, which improves the reading and writing efficiency.
[0076] The simulation method of the present application constructs multiple submodules of a target simulation model; determines a target submodule among the multiple submodules, encapsulates the target submodule into a simulink model, and encapsulates the submodules other than the target submodule among the multiple submodules into an FMU model; obtains data interaction parameters between the simulink model and multiple FMU models; and runs the target simulation model according to the data interaction parameters. The simulation method can achieve the following effects:
[0077] (1) The FMI standard can be used to unify the sub-model interface. The FMI (Functional Mock-up Interface) standard is a tool-independent standard that supports model exchange and joint simulation of dynamic models through a combination of XML files and C code. This facilitates the expansion of models in different application fields.
[0078] (2) Using Simulink to combine multiple FMU models to achieve large-scale semi-physical simulation, it is convenient to adjust local modules and improve simulation efficiency. In addition, the data blocks of each FMU model are independent, which further improves the simulation calculation efficiency and the accuracy of simulation data.
[0079] (3) The simulink model is used as the main control model, and the clock of the simulink model is uniformly adopted. The simulation calculation of each FMU model is controlled by the rate ratio, which can achieve the purpose of compatibility with multiple rates, simplify the overall simulation calculation process, and achieve high real-time performance.
[0080] (4) The data interaction between the Simulink model and the FMU model is decoupled and communicated through a cache device. The cache device can be a local shared memory, a reflective memory card, or an efficient network communication application. This can achieve single-machine and multi-machine joint simulation effects and improve the coverage of application scenarios.
[0081] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0082] Based on the same inventive concept, the embodiment of the present application also provides a simulation device for implementing the above-mentioned simulation method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more simulation device embodiments provided below can refer to the limitations on the simulation method above, and will not be repeated here.
[0083] In one embodiment, Figure 7 As shown, a simulation device is provided, comprising:
[0084] The construction module 702 is used to construct multiple sub-modules of the target simulation model.
[0085] The encapsulation module 704 determines a target submodule among the plurality of submodules, encapsulates the target submodule into a Simulink model, and encapsulates the submodules except the target submodule among the plurality of submodules into an FMU model.
[0086] The configuration parameter acquisition module 706 is used to obtain the data interaction parameters between the Simulink model and multiple FMU models.
[0087] The simulation module 708 is used to run the target simulation model according to the data interaction parameters.
[0088] In another embodiment, the encapsulation module is used to determine the sub-module with the fastest processing rate among the plurality of sub-modules as the target sub-module.
[0089] In another embodiment, the data interaction parameters include data mapping relationships between the simulink model and multiple FMU models.
[0090] The simulation module is used to load and run the FMU model; according to the data mapping relationship, the simulink model reads the calculation result of the corresponding FMU model as input data, performs simulation calculation according to the input data, obtains the simulation calculation result of the simulink model, and writes the simulation calculation result into the data cache unit; the FMU model reads the required input signal data, performs simulation calculation according to the input signal data, obtains the simulation calculation result of the FMU model, and writes the simulation calculation result of the FMU model into the data cache unit.
[0091] The data interaction parameters also include a rate ratio. A simulation module is used for each FMU model to detect the number of simulation steps of the simulink model. If the number of simulation steps meets its own rate ratio, the current FMU model reads the required input signal data and performs simulation calculation according to the input signal data.
[0092] In another embodiment, the simulation module is used to determine the number of the FMU models to be loaded; enable a corresponding number of multi-threads, and the multi-threads load the corresponding FMU models in parallel.
[0093] In another embodiment, the data interaction parameters also include data storage parameters of the model of each sub-module; in the simulation module, the thread corresponding to the FMU model calculates the starting address of the cache unit of the FMU model data and the offset of each signal based on the starting address according to the data storage parameters, and writes the simulation calculation results into the data cache unit according to the starting address and the offset.
[0094] Each module in the above-mentioned simulation device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.
[0095] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a simulation method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse, etc.
[0096] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0097] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps of the simulation method of each of the above embodiments when executing the computer program.
[0098] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the simulation method of each of the above embodiments are implemented.
[0099] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0100] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0101] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A simulation method, characterized in that: The method comprises: Construct multiple submodules of the target simulation model; Determine the submodule with the fastest processing rate among the multiple submodules as a target submodule, encapsulate the target submodule into a simulink model, and encapsulate the submodules except the target submodule among the multiple submodules into an FMU model; Obtaining data interaction parameters between the simulink model and multiple FMU models; The target simulation model is run according to the data interaction parameters.
2. The method according to claim 1, characterized in that: The data interaction parameters include the data mapping relationship between the simulink model and multiple FMU models; The running the target simulation model according to the data interaction parameters includes: Load and run the FMU model; According to the data mapping relationship, the simulink model reads the calculation result of the corresponding FMU model as input data, performs simulation calculation according to the input data, obtains the simulation calculation result of the simulink model, and writes the simulation calculation result into the data cache unit; The FMU model reads the required input signal data, performs simulation calculation according to the input signal data, obtains the simulation calculation result of the FMU model, and writes the simulation calculation result of the FMU model into the data cache unit.
3. The method according to claim 2, characterized in that The data interaction parameters also include a rate ratio; and running the target simulation model according to the data interaction parameters further includes: Each of the FMU models detects the number of simulation steps of the simulink model. If the number of simulation steps meets its own rate ratio, the current FMU model executes the steps of reading the required input signal data and performing simulation calculations according to the input signal data.
4. The method according to claim 3, characterized in that The method further comprises: Determining the number of the FMU models to be loaded; A corresponding number of multithreads are enabled, and the multithreads load the corresponding FMU model in parallel.
5. The method according to claim 4, characterized in that The data interaction parameters also include data storage parameters of the models of each submodule; the writing of the simulation calculation results of the FMU model into the data cache unit includes: The thread corresponding to the FMU model calculates the starting address of the cache unit of the FMU model data and the offset of each signal based on the starting address according to the data storage parameters, and writes the simulation calculation result into the data cache unit according to the starting address and the offset.
6. The method according to claim 5, characterized in that The data cache unit includes any one or more of a local shared memory, a reflective memory card and a network communication application program.
7. A simulation device, characterized in that: The device comprises: A construction module, used for constructing multiple sub-modules of a target simulation model; A packaging module, used for determining the submodule with the fastest processing rate among the plurality of submodules as a target submodule, packaging the target submodule into a simulink model, and packaging the submodules except the target submodule among the plurality of submodules into an FMU model; A configuration parameter acquisition module is used to obtain data interaction parameters between the simulink model and multiple FMU models; A simulation module is used to run the target simulation model according to the data interaction parameters.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Multi-dimensional joint simulation method of machine belt seawater cooling system
CN114035449A
Spacecraft motion simulation system and related product
CN117806287A