A Modelica model compilation method, device, equipment and storage medium

By determining the model and component types of the Modelica model and performing targeted compilation operations, the problem of insufficient compilation efficiency in the existing technology is solved, and the compilation efficiency and development efficiency of the Modelica model are improved.

CN119847534BActive Publication Date: 2025-07-18SUZHOU TONGYUAN SOFT CONTROL INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510330249.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2025-07-18
Estimated Expiration
2045-03-20

AI Technical Summary

Technical Problem

When compiling Modelica models, the prior art compiles each instance based on a single standard semantic, resulting in insufficient compilation efficiency, especially in large and complex systems that affect model development efficiency and increase computing resource consumption.

Method used

By determining the model type and component type of the target Modelica model, including replaceable models, non-replaceable models, fixed components, candidate components or template components, perform corresponding compilation operations based on the component type to improve compilation efficiency.

Benefits of technology

It improves the compilation efficiency of Modelica model, reduces compilation time and computing resource consumption, and improves model development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847534B_ABST
    Figure CN119847534B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a Modelica model compilation method, device, equipment, and storage medium. The method includes: determining a target model type of a target Modelica model; where the target model type includes: a replaceable model or a non-replaceable model; in the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determining a target component type of the component; where the target component type includes: a fixed component, a candidate component, or a template component; based on the target component type of the component, performing a corresponding component compilation operation on the component. The technical solution of the embodiment of the present invention can perform corresponding compilation operations based on the component types of the components in the Modelica model, improving the compilation efficiency of the Modelica model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of industrial software, and in particular, to a Modelica model compilation method, apparatus, device, and storage medium. Background Art

[0002] Mechanisms such as Modification and redeclare in the Modelica language enable different models and variants to be derived from the same model, facilitating model reuse. However, these reuse mechanisms pose challenges to model compilation.

[0003] At the language level, a Modelica model is a type, a special type that does not require instance declaration, and an instance of a type is a component. In the physical world, a type is a collection of entities with the same characteristics. For example, resistors in electricity are a type, a collection of various resistor components, and a component is an instance of a type, corresponding to parts or individuals in the physical world.

[0004] Model reuse is to declare instances of a type and apply modifications or redeclarations to change the parameters, characteristics of the type, or replace components in the type. These reused instances have both exactly the same content and different content. Compiling according to the semantics in the Modelica specification requires processing these instances one by one. However, since Modelica reusable models often contain a large number of instances of the same type, compilation efficiency becomes a key issue. Especially in reusable models of large and complex systems, processing these instances one by one is a time-consuming process, which not only affects the model development efficiency but also increases the consumption of computing resources due to the too long compilation time. Summary of the Invention

[0005] The embodiments of the present invention provide a Modelica model compilation method, apparatus, device, and storage medium. The technical solutions of the embodiments of the present invention solve the problem that in the prior art, when compiling a Modelica model, each instance is compiled based on a single specification semantics, resulting in insufficient compilation efficiency. The corresponding compilation operations can be executed based on the component types of the components in the Modelica model, improving the compilation efficiency of the Modelica model.

[0006] In a first aspect, the embodiments of the present invention provide a Modelica model compilation method, which includes:

[0007] Determine the target model type of the target Modelica model; wherein, the target model type includes: replaceable model or non-replaceable model; in the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; wherein, the target component type includes: fixed component, candidate component or template component; based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0008] In a second aspect, an embodiment of the present invention provides a Modelica model compilation device, and the device includes:

[0009] A model type determination module, configured to determine the target model type of the target Modelica model; wherein, the target model type includes: replaceable model or non-replaceable model; a component type determination module, configured to, in the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; wherein, the target component type includes: fixed component, candidate component or template component; a component compilation module, configured to, based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0010] In a third aspect, an embodiment of the present invention provides a computer device, and the computer device includes:

[0011] One or more processors;

[0012] A memory, configured to store one or more programs;

[0013] When the one or more programs are executed by the one or more processors, the one or more processors implement the Modelica model compilation method described in any embodiment.

[0014] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the Modelica model compilation method described in any embodiment is implemented.

[0015] The technical solution provided by the embodiments of the present invention determines the target model type of the target Modelica model; wherein, the target model type includes: replaceable model or non-replaceable model; in the case that the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; wherein, the target component type includes: fixed component, candidate component or template component; based on the target component type of the component, perform a corresponding component compilation operation on the component. The technical solution of the embodiments of the present invention solves the problem in the prior art that when compiling a Modelica model, each instance is compiled based on a single specification semantics, resulting in insufficient compilation efficiency. It can perform corresponding compilation operations based on the component types of the components in the Modelica model, improving the compilation efficiency of the Modelica model. Description of the Drawings

[0016] Figure 1 is a flowchart of a Modelica model compilation method provided by an embodiment of the present invention;

[0017] Figure 2 is a structural schematic diagram of a Modelica model provided by an embodiment of the present invention;

[0018] Figure 3 is another flowchart of a Modelica model compilation method provided by an embodiment of the present invention;

[0019] Figure 4 is a flowchart of a compilation operation for a fixed component provided by an embodiment of the present invention;

[0020] Figure 5 is a flowchart of a compilation operation for a template component provided by an embodiment of the present invention;

[0021] Figure 6 is a flowchart of a compilation operation for a candidate component provided by an embodiment of the present invention;

[0022] Figure 7 is a flowchart of a compilation operation for a type provided by an embodiment of the present invention;

[0023] Figure 8 is a flowchart of the work for performing Modelica model compilation provided by an embodiment of the present invention;

[0024] Figure 9 is a structural schematic diagram of a Modelica model compilation device provided by an embodiment of the present invention;

[0025] Figure 10 is a structural schematic diagram of a computer device provided by an embodiment of the present invention. Detailed implementation manners

[0026] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts shall fall within the protection scope of the present invention.

[0027] Figure 1 It is a flowchart of a Modelica model compilation method provided by an embodiment of the present invention. The embodiment of the present invention is applicable to the scenario of compiling a Modelica model. This method can be executed by a Modelica model compilation device, and the device can be implemented in software and / or hardware manners.

[0028] As Figure 1 shown, the Modelica model compilation method includes the following steps:

[0029] S110. Determine the target model type of the target Modelica model.

[0030] Among them, the target Modelica model may be a Modelica model that needs to be compiled. The result of Modelica model compilation is a DAE (Differential Algebraic Equation, differential algebraic equation) in a mathematical sense, including variables and equations. The variables of the DAE are the atomic components in the Modelica model. The so-called atomic components refer to those with only a single attribute in their types and cannot be further split, and such a type is the atomic type. The equations of the DAE come from the equations described in three ways in the Modelica model. One is the ordinary equation in the equation area, expressed according to the mathematical form of the equation. The second is the connection equation, generated through the connection statements in the equation area. The third is the declaration equation, defined when the component is declared, and the form is that the variable is always equal to a value. Among them, the ordinary equation and the connection equation cannot be changed during the model reuse process, while the declaration equation can replace the value after the equal sign through the variant mechanism during reuse, deriving new components with different characteristics. The "equations and connections" described in the embodiments of the present invention below include ordinary equations, connection equations and declaration equations.

[0031] Exemplarily Figure 2 It is a structural schematic diagram of a Modelica model provided by an embodiment of the present invention. The "type" in the first column of boxes represents the Modelica model. As Figure 2As shown, a Modelica model can include multiple levels. At the first level, the Modelica model can include multiple components (Component 1 to Component n), as well as equations and connections associated with the components at this level. Further, the components at the first level can also have corresponding subordinate levels. For example, Component 1 can include multiple sub-components (Component 1-1 to Component 1-m), as well as equations and connections associated with the sub-components at this level; the components at the second level can also have corresponding subordinate levels. For example, Component 1-m can include multiple sub-components (Component 1-1-1 to Component 1-m-k), as well as equations and connections associated with the sub-components at this level; and so on until the component is an atomic component. Among them, the set composed of multiple components, equations and connections at the same level can be collectively referred to as a "type". In addition, it should be noted that the "equations and connections associated with the components" in the following includes the equations and connections associated with the components at each level. For example, in the case where Component 1-m is an atomic component, the equations and connections associated with Component 1 include: the equations and connections associated with Component 1 at the first level, the equations and connections associated with Component 1 at the second level, and the equations and connections associated with Component 1 at the third level.

[0032] Further, the target model type can be a type indicating whether the target Modelica model can be differentially compiled. Among them, the target model type includes: replaceable model or non-replaceable model. In the case where the target model type is a replaceable model, the content in the target Modelica model cannot be differentially compiled; in the case where the target model type is a non-replaceable model, the content in the target Modelica model can be differentially compiled. Specifically, semantic analysis can be performed on the target Modelica model, and based on whether the target Modelica model contains a preset keyword, the target model type of the target Modelica model can be determined.

[0033] Exemplarily, the model prefix name of the target Modelica model can be obtained. In the case where the model prefix name does not contain a preset replaceable identifier, it is determined that the target model type is a non-replaceable model; in the case where the model prefix name contains a preset replaceable identifier, it is determined that the target model type is a replaceable model. Among them, the model prefix name can be the file name of the file to which the target Modelica model belongs. The preset replaceable identifier can be set manually. For example, the preset replaceable identifier can be set to "replaceable". If the model prefix name of the target Modelica model contains "replaceable", then the target model type is a replaceable model, otherwise it is a non-replaceable model.

[0034] S120. When the target Modelica model is an irreplaceable model, for each component in the target Modelica model, determine the target component type of the component.

[0035] Among them, the component can be a component included in the target Modelica model. Specifically, the component can include components at each level in the target Modelica model. For example, in Figure 2 , each of the components from component 1 to component n, components 1-1 to 1-m, and components 1-1-1 to 1-m-k can be used as a component. The target component type can be a type indicating whether the component can be differentially compiled.

[0036] Among them, the target component type can include: fixed component, candidate component, or template component. For a component marked as a fixed component, the component and the associated fixed equations can be directly copied and connected to the result. If there is any variation of the fixed component in any part of the component environment information where the component is located, take the top-level equation variation. If the component has a replaceable declaration equation, use the equation variation to replace it and add it to the result set. Otherwise, add the top-level equation variation to the result set.

[0037] For a component marked as a template component, if the component is not redeclared using the redeclare keyword in the component environment information where the component is located, directly copy the component and the associated template components, equations, and connections to the result set. Otherwise, use the redeclared component to replace the template components and the template components included in the template equations and connections, and add the equations and connections to the result set.

[0038] For a component marked as a candidate component, calculate the value of its condition in the component environment information where the component is located. If it is false, the component and the associated candidate connections are directly ignored. Otherwise, copy the candidate component to the result set and copy the associated candidate connections to the result set.

[0039] Among them, the component environment information includes the set of the component's associated components at the current layer and upper layers. For example, in the layer containing the component and the upper layers declared at that layer, up to the layer of the upper component, and so on up to the top-level model in sequence, all the ordered layers and component sets above this component level are called the component environment information corresponding to this component.

[0040] Furthermore, when determining the target component type of a component, the component prefix name of the component can be obtained. When the component prefix name contains a preset replaceable identifier, determine the target component type of the component as a template component; when the component contains a conditional statement, determine the target component type of the component as a candidate component; otherwise, determine the target component type of the component as a fixed component.

[0041] Among them, the component prefix name can be the file name of the file to which the component belongs. The preset replaceable identifier here can be the same as the preset replaceable identifier in step S110. For example, the preset replaceable identifier can be set to "replaceable". If the component prefix name of the component contains "replaceable", then the target component type of the component is a template component. Further, the code corresponding to the component can be judged. If the code contains conditional statements, it is determined that the target component type of the component is a candidate component; otherwise, it is determined that the target component type of the component is a fixed component.

[0042] Optionally, in order to reduce the computational complexity of determining the target component type of the component, the determination order of different component types can be set in ascending order of the determination computational complexity. For example, it can first be determined whether the component is of the template type. If the component is not of the template type, then it is determined whether the component is of the candidate type. If the component is not of the candidate type, then it is determined whether the component is of the fixed type.

[0043] S130. Based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0044] Among them, for components of different target component types, a component compilation operation corresponding to the target component type can be performed, thereby realizing the compilation process of the target Modelica model.

[0045] The technical solution provided by the embodiments of the present invention determines the target model type of the target Modelica model; among them, the target model type includes: replaceable model or non-replaceable model; in the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; among them, the target component type includes: fixed component, candidate component or template component; based on the target component type of the component, perform a corresponding component compilation operation on the component. The technical solution of the embodiments of the present invention solves the problem in the prior art that when compiling a Modelica model, each instance is compiled based on a single standard semantics, resulting in insufficient compilation efficiency. It can perform corresponding compilation operations based on the component types of the components in the Modelica model, improving the compilation efficiency of the Modelica model.

[0046] Figure 3It is another flowchart of the Modelica model compilation method provided by the embodiments of the present invention. The embodiments of the present invention can be applied to the scenario of compiling Modelica models. Based on the above embodiments, this embodiment further illustrates how to determine the target model type of the target Modelica model; and how to perform corresponding component compilation operations on components based on the target component types of the components. The device can be implemented in software and / or hardware and integrated into a computer device with application development functions.

[0047] As Figure 3 shown, the Modelica model compilation method includes the following steps:

[0048] S210. Determine the target model type of the target Modelica model.

[0049] S220. In the case where the target Modelica model is an irreplaceable model, for each component in the target Modelica model, determine the target component type of the component.

[0050] S230. Obtain the component environment information corresponding to the component.

[0051] S240. According to the component environment information and the target component type of the component, perform corresponding component compilation operations on the component.

[0052] Among them, for components with different target component types, different component compilation operations can be performed on the components according to the component environment information.

[0053] Exemplarily, in the case where the target component type of the component is a fixed component, performing corresponding component compilation operations on the component according to the component environment information and the target component type includes: in the case where there is a new variant in the component environment information, replacing the original equation of the component based on the equation in the new variant; in the case where there is no new variant in the component environment information and the component has replaceable equations, replacing the original equation of the component based on the replaceable equations.

[0054] Among them, determining whether there is a new variant in the component environment information can be determined by whether there are new changes in the equation data in the equation component environment information. For example, if the original equation of the component records "a = 5" and the equation in the component environment information records "a = 6", it is determined that there is a new variant. Further, in the case where there is a new variant in the component environment information, the original equation of the component can be replaced based on the equation in the component environment information. Optionally, for components with a target component type of fixed components, only the declared equations corresponding to the components can be subjected to the above new variant determination, and for the fixed equations and connection equations corresponding to the components, direct copy operations can be performed.

[0055] Exemplarily, Figure 4 is a compilation operation flowchart for a fixed component provided by an embodiment of the present invention. As Figure 4 shown, the compilation operation process of the fixed component includes the following steps: Step 1, copy the component to the result set; Step 2, copy the equations marked as fixed equations and the connections marked as fixed connections associated with the component to the result set; Step 3, search the environment where the component is located. If there is a variant, add the declared equation of the new variant to the result set, otherwise copy the original declared equation to the result set.

[0056] In the case where the target component type of the component is a template component, according to the component environment information and the target component type of the component, perform corresponding component compilation operations on the component, including: when there is a preset declaration identifier in the component environment information, replace the component based on the component declared in the component environment information, and modify the equations and connections associated with the component; when there is no preset declaration identifier in the component environment information, copy the template component. Among them, the preset declaration identifier can be an identifier indicating whether to perform redeclaration. Among them, during the compilation process of the model, the user can perform editing operations on the data of the Modelica model, and the edited data can be marked with the corresponding preset declaration identifier. Exemplarily, "redeclare" can be selected as the preset declaration identifier.

[0057] Exemplarily, Figure 5 is a compilation operation flowchart for a template component provided by an embodiment of the present invention. As Figure 5 shown, the compilation operation process of the template component includes the following steps: Step 1, search the environment where the component is located. If there is "redeclare", replace the template component with the redeclared component and add it to the result set, and go to Step 2, otherwise, go to Step 3; Step 2, replace the template components marked as template equations and template connections associated with the template component with the redeclared components; Step 3, directly copy the template component to the result set, and keep the equations and connections of the template component unchanged and copy them to the result set.

[0058] In the case where the target component type of the component is a candidate component, according to the component environment information and the target component type of the component, perform corresponding component compilation operations on the component, including: when the condition in the component environment information is true, copy the candidate component and the equations and connections associated with the candidate component; when the condition in the component environment information is not true, delete the candidate component and the equations and connections associated with the candidate component. Among them, the condition being true means satisfying the conditional statement.

[0059] Exemplarily, Figure 6 is a compilation operation flowchart for a candidate component provided by an embodiment of the present invention. AsFigure 6 As shown in the figure, the compilation operation process of the candidate components includes the following steps: Step 1, search the environment where the candidate components are located. If the conditions of the candidate components are true, copy the candidate components, candidate equations, and candidate connections into the result set; otherwise, go to Step 2. Step 2, ignore the candidate components, candidate equations, and candidate connections.

[0060] Optionally, it is also possible to determine whether there is a redeclaration of the type, and then perform the compilation operation according to the determination result. Exemplarily, Figure 7 is a flowchart of the compilation operation for types provided by an embodiment of the present invention. As Figure 7 shown, the compilation operation process of the type includes the following steps: Search the environment where the type is located. If there is a "redeclare", compile the redeclared type, and add the components, equations, and connections therein to the result set; otherwise, go to Step 2. Step 2, compile the replaceable type, and add the components, equations, and connections therein to the result set.

[0061] Optionally, during the compilation of the model, the compilation tasks of components at the same level can all be executed in parallel as a separate task, but the compilation tasks of components at different levels can only be executed serially in the top-down order.

[0062] Exemplarily, to better understand the technical solution provided by the present invention, specific embodiments are introduced below. Figure 8 is a flowchart of the work for compiling a Modelica model provided by an embodiment of the present invention. As Figure 8 shown, the work process for compiling a Modelica model includes the following steps:

[0063] (1) Select the target Modelica model as the current type.

[0064] (2) Parse the prefix of the current type. If there is a replaceable, mark the model type as a replaceable type and go to (11).

[0065] (3) Select the next component in the current type, parse the prefix of the component. If there is a replaceable, mark the component as a template component, and mark the equations and connections associated with the component as template equations and template connections respectively, and go to (7).

[0066] (4) Parse the conditions of the component. If there are conditions, mark the component as a candidate component, and mark the equations and connections associated with the component as candidate equations and candidate connections respectively, and go to (7).

[0067] (5) Parse the variants of the component. If there are variants, mark the declared equations of the variants as replaceable declared equations.

[0068] (6) The component is marked as a fixed component, and the associated equation and connection are marked as a fixed equation and a fixed connection respectively.

[0069] (7) If there are fixed marks in the marks of the equations and connections associated with the component and there are template or candidate marks at the same time, remove the fixed marks.

[0070] (8) The component, equation, and connection are converted into an internal data representation, and the connection generates a local connection diagram.

[0071] (9) Obtain the type of the component. If the type is not an atomic type, set the component type to the current type and go to (2).

[0072] (10) If there are still components of the current type, go to (3).

[0073] (11) The type processing is completed.

[0074] The technical solution provided by the embodiment of the present invention determines the target model type of the target Modelica model; in the case where the target Modelica model is an irreplaceable model, for each component in the target Modelica model, determines the target component type of the component; obtains the component environment information corresponding to the component; and performs corresponding component compilation operations on the component according to the component environment information and the target component type of the component. The technical solution of the embodiment of the present invention solves the problem in the prior art that when compiling a Modelica model, each instance is compiled based on a single specification semantics, resulting in insufficient compilation efficiency, and can perform corresponding compilation operations based on the component types of the components in the Modelica model, improving the compilation efficiency of the Modelica model.

[0075] Figure 9 It is a schematic structural diagram of a Modelica model compilation device provided by an embodiment of the present invention. The embodiment of the present invention is applicable to the scenario of compiling a Modelica model. The device can be implemented in a software and / or hardware manner and integrated in a computer device with application development functions.

[0076] As Figure 9 shown, the Modelica model compilation device includes: a model type determination module 310, a component type determination module 320, and a component compilation module 330.

[0077] Among them, the model type determination module 310 is used to determine the target model type of the target Modelica model; among them, the target model type includes: replaceable model or non-replaceable model; the component type determination module 320 is used to, when the target Modelica model is a non-replaceable model, determine the target component type of each component in the target Modelica model; among them, the target component type includes: fixed component, candidate component or template component; the component compilation module 330 is used to perform corresponding component compilation operations on the components based on the target component types of the components.

[0078] The technical solution provided by the embodiments of the present invention determines the target model type of the target Modelica model; among them, the target model type includes: replaceable model or non-replaceable model; when the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; among them, the target component type includes: fixed component, candidate component or template component; based on the target component types of the components, perform corresponding component compilation operations on the components. The technical solution of the embodiments of the present invention solves the problem in the prior art that when compiling a Modelica model, each instance is compiled based on a single specification semantics, resulting in insufficient compilation efficiency, and can perform corresponding compilation operations based on the component types of the components in the Modelica model, improving the compilation efficiency of the Modelica model.

[0079] In an optional implementation manner, the component type determination module 320 is specifically used to: obtain the component prefix name of the component, and when the component prefix name contains a preset replaceable identifier, determine that the target component type of the component is a template component; when the component contains a conditional statement, determine that the target component type of the component is a candidate component; otherwise, determine that the target component type of the component is a fixed component.

[0080] In an optional implementation manner, the model type determination module 310 is specifically used to: obtain the model prefix name of the target Modelica model, and when the model prefix name does not contain a preset replaceable identifier, determine that the target model type is a non-replaceable model; when the model prefix name contains a preset replaceable identifier, determine that the target model type is a replaceable model.

[0081] In an alternative embodiment, the component compilation module 330 is specifically configured to: obtain the component environment information corresponding to the component; wherein the component environment information includes the set of components in this layer and the upper-layer components associated with the component; and perform corresponding component compilation operations on the component according to the component environment information of the component and the target component type.

[0082] In an alternative embodiment, the component compilation module 330 includes: a fixed component compilation unit, configured to: replace the original equation of the component based on the equation in the new variant when there is a new variant in the component environment information; and replace the original equation of the component based on the replaceable equation when there is no new variant in the component environment information and the component has a replaceable equation.

[0083] In an alternative embodiment, the component compilation module 330 includes: a template component compilation unit, configured to: replace the component based on the component declared in the component environment information and modify the equations and connections associated with the component when there is a preset declaration identifier in the component environment information; and copy the template component when there is no preset declaration identifier in the component environment information.

[0084] In an alternative embodiment, the component compilation module 330 includes: a candidate component compilation unit, configured to: copy the candidate component and the equations and connections associated with the candidate component when the condition in the component environment information is true; and delete the candidate component and the equations and connections associated with the candidate component when the condition in the component environment information is not true.

[0085] The Modelica model compilation device provided by the embodiments of the present invention can execute the Modelica model compilation method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the method.

[0086] Figure 10 It is a schematic structural diagram of a computer device provided by an embodiment of the present invention. Figure 10 The block diagram of an exemplary computer device 12 suitable for implementing the embodiments of the present invention is shown. Figure 10 The shown computer device 12 is only an example, and should not bring any limitation to the functions and usage scope of the embodiments of the present invention. The computer device 12 can be any terminal device with computing capabilities and can be configured in the Modelica model compilation device.

[0087] Such as Figure 10As shown, the computer device 12 is presented in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects different system components (including the system memory 28 and the processing unit 16).

[0088] The bus 18 can be one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.

[0089] The computer device 12 typically includes a variety of computer system-readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.

[0090] The system memory 28 may include computer system-readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 34 can be used for reading and writing on non-removable, non-volatile magnetic media ( Figure 10 not shown, commonly referred to as a "hard disk drive"). Although Figure 10 not shown in the figure, a disk drive for reading and writing on removable non-volatile disks (such as a "floppy disk"), and an optical disk drive for reading and writing on removable non-volatile optical disks (such as CD-ROM, DVD-ROM, or other optical media) can be provided. In these cases, each drive can be connected to the bus 18 through one or more data media interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0091] A program / utility 40 having a set (at least one) of program modules 42 can be stored, for example, in the system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. The program modules 42 generally execute the functions and / or methods described in the embodiments of the present invention.

[0092] The computer device 12 can also communicate with one or more external devices 14 (such as a keyboard, a pointing device, a display 24, etc.), and can also communicate with one or more devices that enable a user to interact with the computer device 12, and / or communicate with any device that enables the computer device 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through an input / output (I / O) interface 22. Moreover, the computer device 12 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As Figure 10 shown, the network adapter 20 communicates with other modules of the computer device 12 through a bus 18. It should be understood that although Figure 10 not shown in the figure, other hardware and / or software modules can be used in combination with the computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0093] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28. For example, it implements the Modelica model compilation method provided by the embodiments of the present invention. The method includes:

[0094] Determine the target model type of the target Modelica model; wherein, the target model type includes: a replaceable model or a non-replaceable model; in the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; wherein, the target component type includes: a fixed component, a candidate component, or a template component; based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0095] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the Modelica model compilation method provided by any embodiment of the present invention, including:

[0096] Determine the target model type of the target Modelica model; wherein, the target model type includes: a replaceable model or a non-replaceable model; in the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; wherein, the target component type includes: a fixed component, a candidate component, or a template component; based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0097] The computer storage medium of the embodiments of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium may be any tangible medium that contains or stores a program, which can be used by or in combination with an instruction execution system, apparatus, or device.

[0098] The computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device.

[0099] The program code contained on the computer-readable medium may be transmitted by any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0100] The computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).

[0101] Those of ordinary skill in the art should understand that the various modules or steps of the present invention described above can be implemented using a general-purpose computing device. They can be concentrated on a single computing device or distributed across a network composed of multiple computing devices. Optionally, they can be implemented using program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0102] Note that the above is only a preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments here, and various obvious changes, re-adjustments, and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments only. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for compiling a Modelica model, characterized in that, Including: Determine the target model type of the target Modelica model; wherein, the target model type includes: replaceable model or non-replaceable model; In the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determine the target component type of the component; wherein, the target component type includes: fixed component, candidate component or template component; Based on the target component type of the component, perform a corresponding component compilation operation on the component.

2. The method according to claim 1, wherein The determining the target component type of the component includes: Obtain the component prefix name of the component, and in the case where the component prefix name contains a preset replaceable identifier, determine that the target component type of the component is a template component; In the case where the component contains a conditional statement, determine that the target component type of the component is a candidate component; Otherwise, determine that the target component type of the component is a fixed component.

3. The method according to claim 1, wherein The determining the target model type of the target Modelica model includes: Obtain the model prefix name of the target Modelica model, and in the case where the model prefix name does not contain a preset replaceable identifier, determine that the target model type is a non-replaceable model; In the case where the model prefix name contains a preset replaceable identifier, determine that the target model type is a replaceable model.

4. The method according to claim 1, wherein The performing a corresponding component compilation operation on the component based on the target component type of the component includes: Obtain the component environment information corresponding to the component; wherein, the component environment information includes the set of the components in the current layer and the upper-layer components associated with the component; According to the component environment information and the target component type of the component, perform a corresponding component compilation operation on the component.

5. The method according to claim 4, characterized in that, In the case where the target component type of the component is a fixed component, the performing a corresponding component compilation operation on the component according to the component environment information and the target component type of the component includes: In the case where there is a new variant in the component environment information, replace the original equation of the component based on the equation in the new variant; In the case where there is no new variant in the component environment information and the component has a replaceable equation, replace the original equation of the component based on the replaceable equation.

6. The method according to claim 4, wherein In the case where the target component type of the component is a template component, the performing a corresponding component compilation operation on the component according to the component environment information and the target component type of the component includes: In the case where there is a preset declaration identifier in the component environment information, replace the component based on the component declared in the component environment information, and modify the equation and connection associated with the component; In the case where there is no preset declaration identifier in the component environment information, copy the template component.

7. The method according to claim 4, characterized in that, In the case where the target component type of the component is a candidate component, the performing a corresponding component compilation operation on the component according to the component environment information and the target component type of the component includes: In the case where the condition in the component environment information is true, copy the candidate component and the equations and connections associated with the candidate component; In the case where the condition in the component environment information is not true, delete the candidate component and the equations and connections associated with the candidate component.

8. A Modelica model compilation device, characterized in that, The apparatus includes: a model type determination module configured to determine a target model type of a target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; a component type determination module configured to, in the case where the target Modelica model is a non-replaceable model, determine a target component type of each component in the target Modelica model; wherein the target component type includes: a fixed component, a candidate component, or a template component; a component compilation module configured to perform a corresponding component compilation operation on the component based on the target component type of the component.

9. A computer device, characterized in that, The computer device includes: one or more processors; a memory configured to store one or more programs; when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the Modelica model compilation method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it implements the Modelica model compilation method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Reusable satellite power supply energy balance simulation system and modeling method thereof

    CN106202681A

  • Method, device and equipment for realizing parallel or concurrent simulation of Modelica model

    CN118051296A