FMI-based one-dimensional and three-dimensional joint simulation method and device, electronic equipment and storage medium
Through the FMI-based one-dimensional three-dimensional joint simulation method, the simulation integration of one-dimensional three-dimensional coupler and FMU is used to solve the problem of simulation integration difficulties between different fields or systems, and the standardization and universal applicability of simulation results are achieved.
Patent Information
- Application Number
- CN202411520926.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-18
AI Technical Summary
The existing technology is difficult to achieve simulation integration and collaboration between different fields or systems. It is difficult to build a general simulation integration framework. Different simulation software architectures are different, resulting in difficulty in establishing data exchange and interface standardization. The time synchronization mechanism and simulation task management functions are implemented during the simulation process. difficulty.
A one-dimensional three-dimensional joint simulation method based on FMI is proposed. The model information of each FMU is read based on FMI through a one-dimensional three-dimensional coupler, the FMU is instantiated, and the one-dimensional three-dimensional joint simulation is carried out using different coupling strategies until the coupling is completed. Save the final joint simulation results and free up resources.
One-dimensional three-dimensional joint simulation integration and coordination between different fields or different systems is realized, which reduces the difficulty of simulation, makes the simulation results closer to the real-world results, and provides a generally applicable simulation method for the simulation industry.
Smart Images

Figure CN119475722A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of simulation technology, and more specifically, relates to a one-dimensional and three-dimensional joint simulation method, electronic equipment, storage medium and device based on FMI. Background Art
[0002] In recent years, with the development and maturity of a series of emerging technologies such as cloud computing, Internet of Things, big data, artificial intelligence, 5G, etc., products have become more and more complex, and the speed of replacement is getting faster and faster, which makes enterprises face unprecedented pressure for product innovation. As the best way to optimize product design, ensure product performance, shorten the R&D cycle, and verify complex working conditions, simulation is becoming more and more widely used and has become the cornerstone and catalyst of enterprise innovation. At present, in the field of simulation, all walks of life are more focused on single discipline and single physical field for simulation applications. Due to technical barriers, multi-disciplinary and multi-physical field joint simulation is difficult, but in the real world, any object exists in multiple physical fields, so single physical field simulation is obviously far from meeting the requirements of real-world scenarios. Therefore, in order to make the simulation results closer to the real-world results, multi-physical field and multi-disciplinary joint simulation research and application are imminent. Simulation is divided into different directions: structure, fluid, dynamics, electronic control, etc.; it is divided into one-dimensional and three-dimensional according to dimensions; the simulation models in different directions are completely different, and the simulation models in the same direction cannot be reused due to differences in keywords, languages, programming logic, etc.; for the FMI protocol proposed by the EU Modelisar, although the co-simulation and exchange-model interfaces are defined, if you want to open up these interfaces, you still need a feasible framework method.
[0003] For joint simulation, the industry currently faces the following challenges:
[0004] 1. It is difficult to realize simulation integration and collaboration between different fields or systems;
[0005] 2. It is difficult to build a general simulation integration framework;
[0006] 3. Different simulation software architectures are different, which makes data exchange and interface standardization between simulation software a major challenge;
[0007] 4. During the simulation process, different simulation software need to maintain a time synchronization mechanism;
[0008] 5. There are many kinds of simulation software with the same functions, and their architectures are very different. Therefore, it is extremely difficult to build simulation process management tools and implement control functions such as configuration, start, pause, continue and stop of simulation tasks.
[0009] The information disclosed in the background technology section of the present invention is only intended to deepen the understanding of the general background technology of the present invention, and should not be regarded as acknowledging or suggesting in any form that the information constitutes the prior art already known to those skilled in the art. Summary of the invention
[0010] The purpose of the present invention is to propose a one-dimensional and three-dimensional joint simulation method, electronic device, storage medium and device based on FMI, so as to solve the problems of difficulty in realizing simulation integration and collaboration between different fields or different systems, difficulty in building a general simulation integration framework, difficulty in establishing data exchange and interface standardization between simulation software due to different simulation software architectures, difficulty in maintaining a time synchronization mechanism for different simulation software during the simulation process, and difficulty in realizing control functions such as configuration, start, pause, continue and stop of simulation tasks, so as to realize simulation integration and collaboration between different fields or different systems, realize standardization of the three-dimensional joint simulation process, and thus reduce the difficulty of simulation.
[0011] To achieve the above-mentioned purpose, the present invention proposes a one-dimensional and three-dimensional joint simulation method, electronic equipment, storage medium and device based on FMI.
[0012] According to a first aspect of the present invention, a one-dimensional and three-dimensional joint simulation method based on FMI is proposed, comprising:
[0013] The one-dimensional and three-dimensional coupler reads the model information of each FMU based on FMI and instantiates the FMU;
[0014] Wherein, the FMU includes a one-dimensional FMU and a three-dimensional FMU;
[0015] The one-dimensional and three-dimensional coupler uses different coupling strategies to perform one-dimensional and three-dimensional joint simulation based on the results of the one-dimensional solver of the one-dimensional FMU and the three-dimensional solver of the three-dimensional FMU until the coupling is completed;
[0016] The final joint simulation result is saved, each FMU is interrupted and the resources of each FMU are released.
[0017] Optionally, the one-dimensional and three-dimensional coupler reads model information of each FMU based on FMI, and instantiates the FMU including:
[0018] The one-dimensional and three-dimensional coupler reads the configuration files of each of the FMUs and the one-dimensional and three-dimensional couplers based on argparse parsing command line parameters, and obtains simulation model data and simulation calculation data from the configuration files of each of the FMUs and the one-dimensional and three-dimensional couplers by loading the configuration files in json format;
[0019] The simulation model data and the simulation calculation data are stored in a first variable and a second variable respectively;
[0020] Setting the first variable and the second variable based on the configuration files of each of the FMUs;
[0021] Use the unzip method to decompress each of the FMUs, instantiate the FMU, and set initial parameters according to different FMI versions.
[0022] Optionally, the setting of the first variable and the second variable based on the configuration files of each of the FMUs includes:
[0023] Extracting relevant parameters of the FMU from the configuration files of each of the FMUs, reading the FMU model description, and setting variable references of the first variable and the second variable;
[0024] The input and output variable references of the first variable and the second variable are set according to the definition of the input and output variables in the configuration files of each of the FMUs.
[0025] Optionally, performing one-dimensional and three-dimensional joint simulation includes:
[0026] Creating an input object based on a configuration file of each of the FMUs;
[0027] Create a simulation object based on the FMI version information of the one-dimensional and three-dimensional coupler and set the grid and data;
[0028] A record object is created, and a one-dimensional and three-dimensional joint simulation is performed based on the first variables, the second variables, the one-dimensional and three-dimensional couplers, and the input objects that have been set, until the coupling is completed.
[0029] Optionally, performing one-dimensional and three-dimensional joint simulation includes:
[0030] Initialize the simulation time t to 0 and perform the first data sampling;
[0031] The simulation loop continues until the one-dimensional and three-dimensional couplers judge that the coupling is complete;
[0032] In one iteration of the coupling process, if convergence is not achieved, the current state and time of each FMU are saved to the state variable and time variable; the maximum time step allowed by the one-dimensional and three-dimensional coupler is obtained, and the maximum time step is used for the time step dt of the FMU; the current time step is read from the one-dimensional and three-dimensional coupler, and the current time step is converted into a format that can be processed by each FMU; the converted current time step is input into each FMU, and the next time step calculation coupling is performed in combination with the FMI version information of each FMU; the dimension of the one-dimensional and three-dimensional coupling data is determined, and the next time step calculation coupling result is converted into a format that can be processed by the one-dimensional and three-dimensional coupler according to the determination result, and then input into the one-dimensional and three-dimensional coupler, the current time step dt is increased, and the simulation time is advanced; at the same time, whether convergence is determined, if not converged, the state and time of each FMU are restored based on the state variable and time variable; if converged, the data of the current time step is recorded, and the process is repeated until the coupling process ends.
[0033] Optionally, according to the output directory address of the configuration file of the one-dimensional and three-dimensional coupler, an output directory is created and the final data is written and saved in csv format.
[0034] Optionally, the different coupling strategies include:
[0035] Explicit, implicit, parallel, and serial.
[0036] According to a second aspect of the present invention, a one-dimensional and three-dimensional joint simulation device based on FMI is proposed, comprising:
[0037] A one-dimensional and three-dimensional coupler is used to read the model information of each FMU based on FMI and instantiate the FMU; use different coupling strategies to perform one-dimensional and three-dimensional joint simulation based on the results of the one-dimensional solver of the one-dimensional FMU and the three-dimensional solver of the three-dimensional FMU until the coupling is completed; save the final joint simulation results, interrupt each of the FMUs and release the resources of each of the FMUs;
[0038] One-dimensional FMU, used to provide one-dimensional simulation model data;
[0039] 3D FMU is used to provide 3D simulation model data.
[0040] According to a third aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0041] at least one processor; and,
[0042] a memory communicatively connected to the at least one processor; wherein,
[0043] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the FMI-based one-dimensional and three-dimensional joint simulation methods described in the first aspect.
[0044] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium is proposed, which stores computer instructions for enabling a computer to execute any one of the FMI-based one-dimensional and three-dimensional joint simulation methods described in the first aspect.
[0045] The beneficial effects of the present invention are as follows: the present invention establishes a universal one-dimensional and three-dimensional joint simulation integration framework through a one-dimensional and three-dimensional coupler, a one-dimensional FMU and a three-dimensional FMU, realizes the one-dimensional and three-dimensional joint simulation integration and coordination between different fields or different systems, and manages the one-dimensional and three-dimensional joint simulation process to realize the standardization of one-dimensional and three-dimensional joint simulation, thereby reducing the simulation difficulty, allowing one-dimensional and three-dimensional joint simulation to be widely used in the simulation industry, and making the simulation results closer to the real-world results.
[0046] The system of the present invention has other characteristics and advantages, which will be apparent from the drawings incorporated herein and the following detailed description, or will be described in detail in the drawings incorporated herein and the following detailed description, which together serve to explain the specific principles of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The above and other objects, features and advantages of the present invention will become more apparent through a more detailed description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, in which like reference numerals generally represent like components.
[0048] Figure 1 A flowchart showing the steps of the one-dimensional and three-dimensional joint simulation method based on FMI according to the present invention.
[0049] Figure 2 A schematic diagram of a one-dimensional and three-dimensional joint simulation device based on FMI according to the third embodiment of the present invention is shown. DETAILED DESCRIPTION
[0050] The present invention will be described in more detail below with reference to the accompanying drawings. Although preferred embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to make the present invention more thorough and complete, and to fully convey the scope of the present invention to those skilled in the art.
[0051] like Figure 1As shown, a one-dimensional and three-dimensional joint simulation method based on FMI according to the present invention includes:
[0052] The one-dimensional and three-dimensional coupler reads the model information of each FMU based on FMI and instantiates the FMU;
[0053] Among them, FMU includes one-dimensional FMU and three-dimensional FMU;
[0054] The 1D-3D coupler uses different coupling strategies to perform 1D-3D joint simulation based on the results of the 1D solver of the 1D FMU and the 3D solver of the 3D FMU until the coupling is completed;
[0055] Save the final joint simulation results, interrupt each FMU and release each FMU resource.
[0056] Specifically, FMU (Functional Mockup Unit) is a standard file format for describing simulation models, which includes model description information and mathematical formulas. FMU has the characteristics of portability and reusability, and can interact and call models in different simulation environments. FMI (Functional Mockup Interface) is an open standard for exchanging dynamic simulation models between different tools in a standard format.
[0057] The 1D-3D co-simulation process consists of three stages:
[0058] Model preparation stage: The one-dimensional and three-dimensional couplers read the model information of each FMU based on FMI and instantiate the FMU;
[0059] Among them, FMU includes one-dimensional FMU and three-dimensional FMU;
[0060] Simulation stage: The one-dimensional and three-dimensional coupler uses different coupling strategies to perform one-dimensional and three-dimensional joint simulation based on the results of the one-dimensional solver of the one-dimensional FMU and the three-dimensional solver of the three-dimensional FMU until the coupling is completed; since the one-dimensional and three-dimensional joint simulation does not involve the interaction of mesh data, the one-dimensional and three-dimensional coupler only needs to receive the results from the one-dimensional solver of the one-dimensional FMU and the three-dimensional solver of the three-dimensional FMU and couple and transmit them, and call the one-dimensional and three-dimensional simulation execution interfaces respectively according to different coupling strategies to perform calculations;
[0061] Ending stage: Save the final joint simulation results, interrupt each FMU and release each FMU resource.
[0062] The present invention establishes a universal one-dimensional and three-dimensional joint simulation integration framework through a one-dimensional and three-dimensional coupler, a one-dimensional FMU and a three-dimensional FMU, realizes the one-dimensional and three-dimensional joint simulation integration and coordination between different fields or different systems, manages the one-dimensional and three-dimensional joint simulation process, realizes the standardization of one-dimensional and three-dimensional joint simulation, thereby reducing the simulation difficulty, allowing the one-dimensional and three-dimensional joint simulation to be widely used in the simulation industry, and making the simulation results closer to the real-world results.
[0063] In one example, the one-dimensional and three-dimensional coupler reads the model information of each FMU based on the FMI, and instantiates the FMU including:
[0064] The one-dimensional and three-dimensional coupler reads the configuration files of each FMU and one-dimensional and three-dimensional coupler based on argparse parsing command line parameters, and obtains simulation model data and simulation calculation data from the configuration files of each FMU and one-dimensional and three-dimensional coupler by loading the configuration files in json format;
[0065] The simulation model data and the simulation calculation data are stored in the first variable and the second variable respectively;
[0066] Setting the first variable and the second variable based on the configuration file of each FMU;
[0067] Use the unzip method to decompress each FMU, instantiate the FMU, and set the initial parameters according to different FMI versions.
[0068] In one example, setting the first variable and the second variable based on the configuration file of each FMU includes:
[0069] Extract relevant parameters of FMU from the configuration files of each FMU, read the FMU model description, and set the variable references of the first variable and the second variable;
[0070] The input and output variable references of the first variable and the second variable are set according to the definition of the input and output variables in the configuration file of each FMU.
[0071] In one example, performing a one-dimensional and three-dimensional co-simulation includes:
[0072] Create input objects based on the configuration files of each FMU;
[0073] Create simulation objects based on the FMI version information of the 1D and 3D coupler and set the mesh and data;
[0074] A record object is created, and a one-dimensional and three-dimensional joint simulation is performed based on the first variables, the second variables, the one-dimensional and three-dimensional couplers, and the input objects that have been set, until the coupling is completed.
[0075] In one example, performing a one-dimensional and three-dimensional co-simulation includes:
[0076] Initialize the simulation time t to 0 and perform the first data sampling;
[0077] The simulation loop continues until the one-dimensional and three-dimensional couplers judge that the coupling is complete;
[0078] In one iteration of the coupling process, if convergence has not occurred, save the current state and time of each FMU to the state variable and time variable; obtain the maximum time step allowed by the one-dimensional and three-dimensional coupler, and use the maximum time step for the time step dt of the FMU; read the current time step from the one-dimensional and three-dimensional coupler, and convert the current time step into a format that each FMU can handle; input the converted current time step into each FMU, and perform the next time step calculation coupling in combination with the FMI version information of each FMU; determine the dimension of the one-dimensional and three-dimensional coupling data, and convert the next time step calculation coupling result into a format that the one-dimensional and three-dimensional coupler can handle according to the determination result, and then input it into the one-dimensional and three-dimensional coupler, increase the current time step dt, and advance the simulation time; at the same time, determine whether convergence has occurred. If not, restore the state and time of each FMU based on the state variable and time variable; if converged, record the data of the current time step, and repeat the process until the coupling process ends.
[0079] In one example, according to the output directory address of the configuration files of the one-dimensional and three-dimensional couplers, an output directory is created and the final data is written and saved in csv format.
[0080] In one example, different coupling strategies include:
[0081] Explicit, implicit, parallel, and serial.
[0082] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments, but is not intended to be limiting of the present invention. It should be noted that the embodiments and features in the embodiments of the present invention may be combined with each other without conflict.
[0083] Embodiment 1
[0084] This embodiment provides a one-dimensional and three-dimensional joint simulation method based on FMI, including:
[0085] The one-dimensional and three-dimensional coupler reads the model information of each FMU based on FMI and instantiates the FMU;
[0086] Among them, FMU includes one-dimensional FMU and three-dimensional FMU;
[0087] The 1D-3D coupler uses different coupling strategies to perform 1D-3D joint simulation based on the results of the 1D solver of the 1D FMU and the 3D solver of the 3D FMU until the coupling is completed;
[0088] Save the final joint simulation results, interrupt each FMU and release each FMU resource.
[0089] The one-dimensional and three-dimensional coupler reads the model information of each FMU based on FMI and instantiates the FMU including:
[0090] The one-dimensional and three-dimensional coupler reads the configuration files of each FMU and one-dimensional and three-dimensional coupler based on argparse parsing command line parameters, and obtains simulation model data and simulation calculation data from the configuration files of each FMU and one-dimensional and three-dimensional coupler by loading the configuration files in json format;
[0091] The simulation model data and the simulation calculation data are stored in the first variable and the second variable respectively;
[0092] Setting the first variable and the second variable based on the configuration file of each FMU;
[0093] Use the unzip method to decompress each FMU, instantiate the FMU, and set the initial parameters according to different FMI versions.
[0094] The first variable and the second variable are set based on the configuration files of each FMU, including:
[0095] Extract relevant parameters of FMU from the configuration files of each FMU, read the FMU model description, and set the variable references of the first variable and the second variable;
[0096] The input and output variable references of the first variable and the second variable are set according to the definition of the input and output variables in the configuration file of each FMU.
[0097] Performing 1D and 3D co-simulation includes:
[0098] Create input objects based on the configuration files of each FMU;
[0099] Create simulation objects based on the FMI version information of the 1D and 3D coupler and set the mesh and data;
[0100] A record object is created, and a one-dimensional and three-dimensional joint simulation is performed based on the first variables, the second variables, the one-dimensional and three-dimensional couplers, and the input objects that have been set, until the coupling is completed.
[0101] Performing 1D and 3D co-simulation includes:
[0102] Initialize the simulation time t to 0 and perform the first data sampling;
[0103] The simulation loop continues until the one-dimensional and three-dimensional couplers judge that the coupling is complete;
[0104] In one iteration of the coupling process, if convergence has not occurred, save the current state and time of each FMU to the state variable and time variable; obtain the maximum time step allowed by the one-dimensional and three-dimensional coupler, and use the maximum time step for the time step dt of the FMU; read the current time step from the one-dimensional and three-dimensional coupler, and convert the current time step into a format that each FMU can handle; input the converted current time step into each FMU, and perform the next time step calculation coupling in combination with the FMI version information of each FMU; determine the dimension of the one-dimensional and three-dimensional coupling data, and convert the next time step calculation coupling result into a format that the one-dimensional and three-dimensional coupler can handle according to the determination result, and then input it into the one-dimensional and three-dimensional coupler, increase the current time step dt, and advance the simulation time; at the same time, determine whether convergence has occurred. If not, restore the state and time of each FMU based on the state variable and time variable; if converged, record the data of the current time step, and repeat the process until the coupling process ends.
[0105] According to the output directory address of the configuration files of the 1D and 3D couplers, create an output directory and write the final data, saving it in csv format.
[0106] Different coupling strategies include:
[0107] Explicit, implicit, parallel, and serial.
[0108] Embodiment 2
[0109] This embodiment provides a one-dimensional and three-dimensional joint simulation method based on FMI, including:
[0110] Step 1. Load the configuration file: Use argparse to parse the command line parameters, the coupler reads the configuration files of the FMU and the one-dimensional and three-dimensional couplers, and uses json_load to load the configuration files in json format, and saves them in the fmi_data variables related to the simulation calculation and the 1d3d_data variables related to the simulation model.
[0111] Step 2. FMU settings: Extract the relevant parameters of the FMU from the FMU's model_description configuration file, read the FMU model description, and set the variable references. According to the definition of the input and output variables in the FMU configuration file, set the references of the input and output variables. By judging model_description.fmiVersion, use the unzip method to decompress the FMU, instantiate the FMU, and set the initial parameters according to different FMI versions.
[0112] Step 3. Create input object: read_data signal data from the instantiated FMU configuration file and create an Input object.
[0113] Step 4. Coupler settings: Check the one-dimensional and three-dimensional coupler FMI version information, create a Participant object and set the mesh and data. Since there is no mesh data for the one-dimensional FMU, you only need to use the default mesh name.
[0114] Step 5. Run the coupled simulation: Create a Recorder object to record the simulation information, model information, and result information during the simulation process, and execute the coupled simulation loop. First, set the initial time setting and sampling through Recorder.sample, initialize the simulation time t to 0, and perform the first data sampling. The main simulation loop continues until the 1D and 3D coupler determines that the coupling is complete through the participant.is_coupling_ongoing function. In one iteration of the coupling process, if it is not converged, save the current FMU state and time to the variables state_cp state and t_cp time. Get the maximum time step allowed in the 1D and 3D coupler configuration and use it for the FMU time step dt. Use participant.read_data to read the data of the current time step from the 1D and 3D coupler and convert it to a format that the FMU can handle. Apply the input signal of the current time t to the FMU through input.apply(t). Calculate the coupling for the next time step according to the FMU version and get the result. Determine the dimension of the 1D and 3D coupling data according to participant.get_data_dimension and convert the result to the write_data format suitable for writing. Write the result of the current calculation step into the one-dimensional and three-dimensional coupler, increase the current time step dt to t, and use fmirunner::doStep to advance the simulation time. At the same time, determine whether it has converged. If it has not converged, restore the FMU state to the previously saved checkpoint state and restore the time; if it has converged, there is no need to read the checkpoint, and recorder.sample records the data of the current time step. The cycle continues until the coupling process ends.
[0115] Step 6. Save the results: Create an output directory and write the final data according to the output directory address of the configuration file, saving it in csv format.
[0116] Step 7. Terminate and clean up the FMU: Use fmirunner::terminate to interrupt the FMU and fmirunner::freeInstance to release FMU resources.
[0117] Embodiment 3
[0118] like Figure 2 As shown, this embodiment provides a one-dimensional and three-dimensional joint simulation device based on FMI, including:
[0119] The one-dimensional and three-dimensional coupler (coupling controller) is used to read the model information of each FMU based on FMI and instantiate the FMU; use different coupling strategies to perform one-dimensional and three-dimensional joint simulation based on the results of the one-dimensional solver of the one-dimensional FMU and the three-dimensional solver of the three-dimensional FMU until the coupling is completed; save the final joint simulation results, interrupt each FMU and release the resources of each FMU;
[0120] One-dimensional FMU (FMU model 1), used to provide one-dimensional simulation model data;
[0121] The three-dimensional FMU (FMU model 2) is used to provide three-dimensional simulation model data.
[0122] Embodiment 4
[0123] The present disclosure also provides an electronic device, the electronic device comprising:
[0124] at least one processor; and,
[0125] a memory communicatively connected to the at least one processor; wherein,
[0126] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the one-dimensional and three-dimensional joint simulation method based on FMI in the first embodiment.
[0127] The electronic device according to an embodiment of the present disclosure includes a memory and a processor, and the memory is used to store non-temporary computer-readable instructions. Specifically, the memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may, for example, include a read-only memory (ROM), a hard disk, a flash memory, etc.
[0128] The processor may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions. In one embodiment of the present disclosure, the processor is used to run the computer-readable instructions stored in the memory.
[0129] Those skilled in the art should be able to understand that in order to solve the technical problem of how to obtain a good user experience, the present embodiment may also include well-known structures such as a communication bus and an interface, and these well-known structures should also be included in the protection scope of the present disclosure.
[0130] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.
[0131] Embodiment 5
[0132] An embodiment of the present disclosure provides a non-transitory computer-readable storage medium, which stores computer instructions for causing a computer to execute the one-dimensional and three-dimensional joint simulation method based on FMI in the first embodiment.
[0133] According to the computer-readable storage medium of the embodiment of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the above-mentioned methods of each embodiment of the present disclosure are executed.
[0134] The above-mentioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or mobile hard disk), media with built-in rewritable non-volatile memory (e.g., memory card) and media with built-in ROM (e.g., ROM box).
[0135] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments.
Claims
1. A one-dimensional and three-dimensional joint simulation method based on FMI, characterized in that: include: The one-dimensional and three-dimensional coupler reads the model information of each FMU based on FMI and instantiates the FMU; Wherein, the FMU includes a one-dimensional FMU and a three-dimensional FMU; The one-dimensional and three-dimensional coupler uses different coupling strategies to perform one-dimensional and three-dimensional joint simulation based on the results of the one-dimensional solver of the one-dimensional FMU and the three-dimensional solver of the three-dimensional FMU until the coupling is completed; The final joint simulation result is saved, each FMU is interrupted and each FMU resource is released.
2. The one-dimensional and three-dimensional joint simulation method based on the FMI standard according to claim 1 is characterized in that: The one-dimensional and three-dimensional coupler reads the model information of each FMU based on FMI, and instantiates the FMU including: The one-dimensional and three-dimensional coupler reads the configuration files of each of the FMUs and the one-dimensional and three-dimensional couplers based on argparse parsing command line parameters, and obtains simulation model data and simulation calculation data from the configuration files of each of the FMUs and the one-dimensional and three-dimensional couplers by loading the configuration files in json format; The simulation model data and the simulation calculation data are stored in a first variable and a second variable respectively; Setting the first variable and the second variable based on the configuration files of each of the FMUs; Use the unzip method to decompress each of the FMUs, instantiate the FMU, and set initial parameters according to different FMI versions.
3. The one-dimensional and three-dimensional joint simulation method based on FMI according to claim 2 is characterized in that: The setting of the first variable and the second variable based on the configuration files of each of the FMUs includes: Extracting relevant parameters of the FMU from the configuration files of each of the FMUs, reading the FMU model description, and setting variable references of the first variable and the second variable; The input and output variable references of the first variable and the second variable are set according to the definition of the input and output variables in the configuration files of each of the FMUs.
4. The one-dimensional and three-dimensional joint simulation method based on FMI according to claim 3 is characterized in that: The one-dimensional and three-dimensional joint simulation comprises: Creating an input object based on a configuration file of each of the FMUs; Create a simulation object based on the FMI version information of the one-dimensional and three-dimensional coupler and set the grid and data; A record object is created, and a one-dimensional and three-dimensional joint simulation is performed based on the first variables, the second variables, the one-dimensional and three-dimensional couplers, and the input objects that have been set, until the coupling is completed.
5. The one-dimensional and three-dimensional joint simulation method based on FMI according to claim 1, characterized in that: The performing of one-dimensional and three-dimensional joint simulation comprises: Initialize the simulation time t to 0 and perform the first data sampling; The simulation loop continues until the one-dimensional and three-dimensional couplers judge that the coupling is complete; In one iteration of the coupling process, if convergence is not achieved, the current state and time of each FMU are saved to the state variable and time variable; the maximum time step allowed by the one-dimensional and three-dimensional coupler is obtained, and the maximum time step is used for the time step dt of the FMU; the current time step is read from the one-dimensional and three-dimensional coupler, and the current time step is converted into a format that can be processed by each FMU; the converted current time step is input into each FMU, and the next time step calculation coupling is performed in combination with the FMI version information of each FMU; the dimension of the one-dimensional and three-dimensional coupling data is determined, and the next time step calculation coupling result is converted into a format that can be processed by the one-dimensional and three-dimensional coupler according to the determination result, and then input into the one-dimensional and three-dimensional coupler, the current time step dt is increased, and the simulation time is advanced; at the same time, whether convergence is determined, if not converged, the state and time of each FMU are restored based on the state variable and time variable; if converged, the data of the current time step is recorded, and the process is repeated until the coupling process ends.
6. The one-dimensional and three-dimensional joint simulation method based on FMI according to claim 5, characterized in that: According to the output directory address of the configuration file of the one-dimensional and three-dimensional coupler, create an output directory and write the final data, saving it in csv format.
7. The one-dimensional and three-dimensional joint simulation method based on FMI according to claim 1, characterized in that: The different coupling strategies include: Explicit, implicit, parallel, and serial.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the one-dimensional and three-dimensional joint simulation method based on FMI as described in any one of claims 1-7.
9. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, which are used to enable a computer to execute the one-dimensional and three-dimensional joint simulation method based on FMI as described in any one of claims 1-7.
10. A one-dimensional and three-dimensional joint simulation device based on FMI, characterized in that: include: One-dimensional and three-dimensional couplers are used to read the model information of each FMU based on FMI and instantiate FMU; Based on the results of the one-dimensional solver of the one-dimensional FMU and the three-dimensional solver of the three-dimensional FMU, different coupling strategies are used to perform one-dimensional and three-dimensional joint simulation until the coupling is completed; saving the final joint simulation results, interrupting each of the FMUs and releasing the resources of each of the FMUs; One-dimensional FMU, used to provide one-dimensional simulation model data; 3D FMU is used to provide 3D simulation model data.