Simulation calculation method, device, equipment and storage medium
By dividing the simulation system into multiple subsystems and determining the number of simulations, the problem of waste of computing resources caused by the maximum common divisor in the prior art is solved, and more efficient simulation calculations are achieved.
Patent Information
- Application Number
- CN202210565145.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2042-05-23
AI Technical Summary
In the prior art, when there are multiple subsystems with different sampling periods in the simulation model established by the user, the simulation step size used during simulation generally uses the greatest common divisor of the sampling period of each group of subsystems, resulting in the sampling period of the total system being too small, causing the emulator to perform a large number of invalid simulation calculations and waste the system's computing resources.
By dividing the entire simulation system into N groups of subsystems, and obtaining the system sampling period T and the sampling period Ti of each subsystem according to the simulation cycle, the number of simulation times and calculation result data of the subsystem in the current simulation step is determined, which avoids the integer multiple limit of the sampling period and expands the setting range of the system simulation cycle.
It effectively reduces ineffective simulation calculations, saves computing resources, improves simulation efficiency, and makes the simulation step size not affected by the sampling period of each module, which is more in line with engineering application scenarios.
Smart Images

Figure CN114912282B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic circuits, and in particular to a simulation calculation method, device, equipment and storage medium. Background Art
[0002] In the prior art, when there are multiple subsystems with different sampling periods in the simulation model established by the user, the simulation step size used in the simulation generally adopts the greatest common divisor of the sampling periods of each group of subsystems. For example, if the period of subsystem 1 is 0.5; the sampling period of subsystem 2 is 0.75, then the greatest common divisor is 0.25; the sampling period of the total system should be, for example, 0.05, 0.125, 0.0625, 0.01; that is, the greatest common divisor is an integer multiple of the sampling period. Especially when the number of subsystems is relatively large, the greatest common divisor will be very small, resulting in a smaller sampling period of the total system, causing the simulator to perform a large number of invalid simulation calculations, wasting the system's computing resources. Summary of the invention
[0003] The purpose of the embodiments of the present invention is to provide a simulation calculation method, device, equipment and storage medium to solve the above-mentioned problems.
[0004] To achieve the above object, an embodiment of the present invention provides a simulation calculation method, including:
[0005] Before the simulation starts, the entire simulation system is divided into N groups of subsystems according to the simulation cycle, where N is greater than or equal to 1;
[0006] Obtaining the system sampling period T of the entire simulation system and the sampling period Ti of each subsystem in the N subsystems; 1≤i≤N;
[0007] When the entire simulation system is running, when the simulation time reaches the simulation step number n,
[0008] For the i-th group of subsystems, determining the number of simulations of the subsystems in the current simulation step of the entire simulation system according to the number of simulation steps n, the system sampling period T and the sampling period Ti of the subsystems;
[0009] The simulation calculation result data of the subsystem in the current simulation step of the entire simulation system is determined according to the simulation number.
[0010] In one embodiment, determining the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation number includes:
[0011] If the simulation number is greater than or equal to 1, then the subsystems are simulated for a corresponding number of times in sequence;
[0012] Get the simulation calculation result data of the last simulation calculation;
[0013] Using the simulation calculation result data of the last simulation calculation as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system; or,
[0014] If the simulation times is equal to 0, then obtaining the historical simulation calculation result data of the subsystem closest to the current time;
[0015] The historical simulation calculation result data is used as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system.
[0016] In one embodiment, multiple simulation calculations are performed on the subsystem in sequence; and the simulation calculation result data of the last simulation calculation is obtained, including:
[0017] Calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0018] Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0019] Calculate the difference between the system simulation time Time and the subsystem simulation time Timei;
[0020] C = Time-Timei;
[0021] Determine whether the difference C is greater than or equal to the sampling period Ti of the subsystem;
[0022] If yes, a simulation calculation is performed on the subsystem, and ni is increased by 1;
[0023] Calculate repeatedly until the difference C is less than the sampling period Ti of the subsystem;
[0024] Get the simulation calculation result data of the last simulation calculation.
[0025] In one embodiment, multiple simulation calculations are performed on the subsystem in sequence; and the simulation calculation result data of the last simulation calculation is obtained, including:
[0026] Determine the number of simulations of the subsystem in the current simulation step of the entire simulation system;
[0027] Perform multiple simulation calculations on the subsystem according to the number of simulations;
[0028] Get the simulation calculation result data of the last simulation calculation.
[0029] In one implementation, determining the number of simulations of the subsystem in a current simulation step of the entire simulation system includes:
[0030] Calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0031] Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0032] Calculate the difference between the system simulation time Time and the subsystem simulation time Timei;
[0033] C = Time-Timei;
[0034] Calculate the quotient of the difference C and the sampling period Ti of the subsystem:
[0035] V = C / Ti;
[0036] Round V to get the number of simulations:
[0037] B=[V].
[0038] In one implementation, before the simulation starts, the entire simulation system is divided into N groups of subsystems according to the simulation cycle, including:
[0039] Get the simulation cycle of each simulation module in the system;
[0040] Determine a plurality of simulation modules corresponding to each simulation cycle;
[0041] The plurality of simulation modules are divided into the same group of subsystems.
[0042] In a second aspect, the present application proposes a simulation computing device, comprising:
[0043] A partitioning module is used to divide the entire simulation system into N groups of subsystems according to the simulation cycle before the simulation starts, where N is greater than or equal to 1;
[0044] An acquisition module, used to acquire a system sampling period T of the entire simulation system and a sampling period Ti of each subsystem in the N subsystems; 1≤i≤N;
[0045] The first simulation calculation module is used for determining the number of simulations of the subsystem in the current simulation step of the entire simulation system according to the simulation step number n, the system sampling period T and the sampling period Ti of the subsystem for the i-th group of subsystems when the simulation time reaches the simulation step number n during the simulation operation of the entire simulation system;
[0046] Determine the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation number;
[0047] The second simulation calculation module is used to simulate the entire simulation system according to the simulation calculation result data of each group of subsystems.
[0048] In one implementation, the first simulation calculation module is further configured to, if the number of simulations is greater than or equal to 1, sequentially perform simulation calculations on the subsystems for a corresponding number of times;
[0049] Get the simulation calculation result data of the last simulation calculation;
[0050] Using the simulation calculation result data of the last simulation calculation as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system; or,
[0051] If the simulation times is equal to 0, then obtaining the historical simulation calculation result data of the subsystem closest to the current time;
[0052] The historical simulation calculation result data is used as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system.
[0053] In one embodiment, multiple simulation calculations are performed on the subsystem in sequence; and the simulation calculation result data of the last simulation calculation is obtained, including:
[0054] Calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0055] Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0056] Calculate the difference between the system simulation time Time and the subsystem simulation time Timei;
[0057] C = Time-Timei;
[0058] Determine whether the difference C is greater than or equal to the sampling period Ti of the subsystem;
[0059] If yes, a simulation calculation is performed on the subsystem, and ni is increased by 1;
[0060] Calculate repeatedly until the difference C is less than the sampling period Ti of the subsystem;
[0061] Get the simulation calculation result data of the last simulation calculation.
[0062] In one embodiment, multiple simulation calculations are performed on the subsystem in sequence; and the simulation calculation result data of the last simulation calculation is obtained, including:
[0063] Determine the number of simulations of the subsystem in the current simulation step of the entire simulation system;
[0064] Perform multiple simulation calculations on the subsystem according to the number of simulations;
[0065] Get the simulation calculation result data of the last simulation calculation.
[0066] In one implementation, determining the number of simulations of the subsystem in a current simulation step of the entire simulation system includes:
[0067] Calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0068] Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0069] Calculate the difference between the system simulation time Time and the subsystem simulation time Timei;
[0070] C = Time-Timei;
[0071] Calculate the quotient of the difference C and the sampling period Ti of the subsystem:
[0072] V = C / Ti;
[0073] The simulation times are obtained by rounding V:
[0074] B=[V].
[0075] In one embodiment, the partitioning module is further used to obtain the simulation cycle of each simulation module in the system; determine a plurality of simulation modules corresponding to each simulation cycle; and partition the plurality of simulation modules into the same group of subsystems.
[0076] In order to achieve the above-mentioned purpose, according to the third aspect of the present application, an electronic device is provided; comprising at least one processor and at least one memory; the memory is used to store one or more program instructions; the processor is used to run one or more program instructions to execute any of the steps described above.
[0077] According to a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium contains one or more program instructions, and the one or more program instructions are used to execute any one of the steps described above.
[0078] According to the above technical solution of the present invention, when the whole system simulation is running, when the simulation time reaches the simulation step number n, for any i-th group of subsystems, the number of simulations of the subsystem in the current simulation step of the whole simulation system is determined according to the simulation step number n, the system sampling period and the sampling period Ti of the subsystem; the simulation calculation result data of the subsystem in the current simulation step of the whole simulation system is determined according to the simulation number; wherein the system sampling period can be greater than, less than or equal to the greatest common divisor of the simulation periods of each group of subsystems. The system sampling period is not restricted by the greatest common divisor, which avoids the restriction in the prior art that the greatest common divisor of the simulation periods of each group of subsystems must be an integer multiple of the simulation period, and expands the setting range. Especially when the number of subsystems is relatively large, the greatest common divisor is relatively small, and the system simulation period is set to be even smaller, resulting in a large number of invalid calculations and wasting system resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.
[0080] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with the technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantial technical significance. Any structural modification, change in proportion or adjustment of size shall still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.
[0081] Figure 1A A schematic diagram of the structure of a simulation system provided by an embodiment of the present invention;
[0082] Figure 1B A multi-cycle simulation sampling timing distribution diagram provided by an embodiment of the present invention;
[0083] Figure 2 A flowchart of a simulation method provided by an embodiment of the present invention;
[0084] Figure 3A flowchart of another simulation method provided by an embodiment of the present invention;
[0085] Figure 4 A schematic diagram of the structure of a simulation device provided by an embodiment of the present invention;
[0086] Figure 5 A schematic diagram of the structure of a simulation device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0087] The following is a description of the implementation of the present invention by specific embodiments. People familiar with the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0088] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0089] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0090] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0091] In the prior art, when there are modules / subsystems with different sampling periods in the simulation model established by the user, in the actual simulation, the greatest common divisor of the sampling periods is an integer multiple of the simulation step length used by the overall system. This setting is to ensure that when the sampling period of each group of subsystems arrives, the overall system can sample each group of subsystems on time, but it increases the workload of the overall system and causes a large waste of computing resources.
[0092] See also Figure 1AA simulation system diagram is shown in Figure 1. This system is a motor system. The M part in the model represents the motor, the C part represents the controller, and the S part represents the speed sensor. For the C part, the control cycle range that the computing power of the chip used in the project can achieve when running the controller code should be considered, so as to set the sampling period of C accordingly; and for S, the sampling period should be set according to the communication frequency between the sensor and the chip used in the project. This results in the simulation step size determined by the basic sampling period of the entire model being different from the control period of C and the communication period S of the sensor, which deviates from the actual project.
[0093] See also Figure 1B , the user sets the sampling periods of the two modules to 0.5s and 0.75s respectively, and the basic sampling period is 0.25s. The simulator will perform a simulation calculation at each basic sampling period. At 0.25 seconds, even if no module is sampling, the system simulator will still perform a simulation calculation, resulting in a waste of computing resources.
[0094] Based on this, this application proposes a simulation method, see the attached Figure 2 A flow chart of a simulation method shown; the method comprises the following steps:
[0095] Step S202: before the simulation starts, the entire simulation system is divided into N groups of subsystems according to the simulation cycle, where N is greater than or equal to 1.
[0096] For example, referring to FIG1 , the sampling period of the controller is set to Tc=10ms according to the computing power of the micro central controller MCU, the sampling period of the controlled object M is set to Tm=3ms, and the sampling period of the sensor S is set to Ts=5ms according to the sensor model and communication parameters used.
[0097] The controlled object M is set as the first subsystem, the sensor S is set as the second subsystem, and the controller C is set as the third subsystem.
[0098] Step S204, obtaining the system sampling period T of the entire simulation system and the sampling period Ti of each subsystem in the N subsystem groups; 1≤i≤N.
[0099] Step S206, when the simulation time reaches the simulation step number n during the simulation operation of the entire simulation system, for the i-th group of subsystems, the number of simulation times of the subsystem in the current simulation step of the entire simulation system is determined according to the simulation step number n, the system sampling period T and the sampling period Ti of the subsystem.
[0100] Step S208, determining the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation number.
[0101] Step S210, simulating the entire simulation system according to the simulation calculation result data of each group of subsystems.
[0102] According to the above method of the present application, the sampling period of the entire simulation system does not need to be constrained by the greatest common divisor of each group of subsystems, thereby expanding the value range. The sampling period of the entire system can be greater than, less than or equal to the greatest common divisor of the simulation periods of each group of subsystems, thereby removing the restriction that the greatest common divisor of the simulation periods of each group of subsystems must be an integer multiple of the simulation period of the entire system. The sampling period of the entire simulation system can be set to a relatively large value, thereby avoiding the problem of hardware resource waste caused by a too small system sampling period.
[0103] In one implementation, step S208, determining the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation times, adopts the following two methods;
[0104] One way is:
[0105] If the simulation number is greater than or equal to 1, then the subsystems are simulated for a corresponding number of times in sequence;
[0106] Get the simulation calculation result data of the last simulation calculation;
[0107] The simulation calculation result data of the last simulation calculation is used as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system.
[0108] Specifically, this method is divided into the following two implementation methods:
[0109] One implementation method is as follows: Figure 3 A flowchart of another simulation calculation method shown;
[0110] S301, calculating the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0111] S302, calculating the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0112] S303, calculating the difference between the system simulation time Time and the subsystem simulation time Timei;
[0113] C = Time-Timei;
[0114] S304, determining whether the difference C is greater than or equal to the sampling period Ti of the subsystem;
[0115] If yes, execute step S305;
[0116] Step S305, the subsystem performs a simulation calculation and increases ni by 1;
[0117] Return to step S301,
[0118] If not, execute step S306;
[0119] Step S306, end.
[0120] The simulation data obtained from the last calculation is used as the result value.
[0121] Exemplary,system description: the system sampling period is T=0.4s;
[0122] The number of subsystems included in the system is: 2;
[0123] The sampling period of the first subsystem is: 0.5s;
[0124] The sampling period of the second subsystem is: 0.75s;
[0125] System simulation step number 3.
[0126] The (0)th system simulation step:
[0127] Step 0 simulation, all subsystems and the entire system perform simulation calculation process
[0128] Calculate the (1)th subsystem and obtain the calculation results;
[0129] After n1 is initialized: n1 = 0;
[0130] Calculate the (2)th subsystem and obtain the calculation results;
[0131] After n2 is initialized: n2 = 0;
[0132] According to the calculation results of each subsystem, the simulation calculation of the whole system in step (0) is carried out
[0133] The first system simulation step:
[0134] Decide the simulation behavior of the (1)th subsystem in the current simulation step of the system and obtain the simulation value:
[0135] First decision:
[0136] The time difference does not satisfy the situation of being greater than or equal to: (n×T-n1×T1=1×0.400000-0×0.500000=0.400000<0.500000);
[0137] Decide the simulation behavior of the (2)th subsystem in the current simulation step of the system and obtain the simulation value;
[0138] First decision:
[0139] The time difference does not satisfy the situation of being greater than or equal to: (n×T-n2×T2=1×0.400000-0×0.750000=0.400000<0.750000);
[0140] Based on the calculation results of each subsystem, the simulation calculation of step (1) of the entire system is performed.
[0141] The second system simulation step:
[0142] Decide the simulation behavior of the (1)th subsystem in the current simulation step of the system and obtain the simulation value
[0143] First decision:
[0144] The time difference satisfies the scenario of being greater than or equal to: (n×T-n1×T1=2×0.400000-0×0.500000=0.800000≥0.500000)
[0145] Calculate the (1)th subsystem and obtain the calculation results;
[0146] After n1 increases by 1: n1=1;
[0147] Second decision:
[0148] The time difference does not satisfy the situation of being greater than or equal to: (n×T-n1×T1=2×0.400000-1×0.500000=0.300000<0.500000);
[0149] Decide the simulation behavior of the (2)th subsystem in the current simulation step of the system and obtain the simulation value
[0150] First decision:
[0151] The time difference satisfies the scenario of being greater than or equal to: (n×T-n2×T2=2×0.400000-0×0.750000=0.800000≥0.750000)
[0152] Calculate the (2)th subsystem and obtain the calculation results;
[0153] After n2 increases by 1: n2 = 1;
[0154] Second decision:
[0155] The time difference does not satisfy the situation of being greater than or equal to: (n×T-n2×T2=2×0.400000-1×0.750000=0.050000<0.750000);
[0156] Perform simulation calculation of step (2) of the entire system based on the calculation results of each subsystem;
[0157] The (3rd) system simulation step:
[0158] Decide the simulation behavior of the (1)th subsystem in the current simulation step of the system and obtain the simulation value
[0159] First decision:
[0160] The time difference satisfies the scenario of being greater than or equal to: (n×T-n1×T1=3×0.400000-1×0.500000=0.700000≥0.500000);
[0161] Calculate the (1)th subsystem and obtain the calculation results;
[0162] After n1 increases by 1: n1 = 2;
[0163] Second decision:
[0164] The time difference does not satisfy the situation of being greater than or equal to: (n×T-n1×T1=3×0.400000-2×0.500000=0.200000<0.500000);
[0165] Decide the simulation behavior of the (2)th subsystem in the current simulation step of the system and obtain the simulation value;
[0166] First decision:
[0167] The time difference does not satisfy the situation of being greater than or equal to: (n×T-n2×T2=3×0.400000-1×0.750000=0.450000<0.750000);
[0168] Perform simulation calculation of step (3) of the entire system based on the calculation results of each subsystem;
[0169] Another implementation method is to directly calculate the number of simulations of the subsystem in the current simulation step of the entire simulation system;
[0170] According to the above simulation times, multiple simulation calculations are performed on the subsystem;
[0171] Get the calculation result data of the last simulation calculation.
[0172] The following steps are used to determine the number of simulations of the subsystem in the current simulation step of the entire simulation system:
[0173] Calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0174] Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0175] Wherein, Ti is the sampling period of the i-th group of subsystems;
[0176] Calculate the difference between the system simulation time Time and the subsystem simulation time Timei;
[0177] C = Time-Timei;
[0178] Simulation calculation times:
[0179] V = C / Ti;
[0180] The simulation times are obtained by rounding V:
[0181] B=[V].
[0182] Exemplarily, the system sampling period is T=1.3s;
[0183] The number of subsystems included in the system is: 2;
[0184] The sampling period of the first subsystem is: 0.5s;
[0185] The sampling period of the second subsystem is: 0.75s;
[0186] System simulation step number 3;
[0187] The (0)th system simulation step:
[0188] Step 0 simulation, all subsystems and the entire system perform simulation calculation process;
[0189] Calculate the (1)th subsystem and obtain the calculation results;
[0190] After n1 is initialized: n1 = 0;
[0191] Calculate the (2)th subsystem and obtain the calculation results;
[0192] After n2 is initialized: n2 = 0;
[0193] According to the calculation results of each subsystem, the simulation calculation of the whole system in step (0) is performed;
[0194] The first system simulation step:
[0195] Decide the simulation behavior of the (1)th subsystem in the current simulation step of the system and obtain the simulation value;
[0196] The time difference satisfies the scenario of being greater than or equal to: (n×T-n1×T1=1×1.300000-0×0.500000=1.300000≥0.500000);
[0197] The difference is 2.600000 times T1, and the integer multiple is 2;
[0198] Perform (2) calculations on the (1)th subsystem and obtain the final calculation result;
[0199] After n1 increases by 2: n1 = 2;
[0200] Decide the simulation behavior of the (2)th subsystem in the current simulation step of the system and obtain the simulation value;
[0201] The time difference satisfies the scenario of being greater than or equal to: (n×T-n2×T2=1×1.300000-0×0.750000=1.300000≥0.750000);
[0202] The difference is 1.733333 times T2, and the integer multiple is 1;
[0203] Perform (1) calculation on the (2)th subsystem and obtain the last calculation result;
[0204] After n2 increases by 1: n2 = 1;
[0205] Perform simulation calculation of step (1) of the entire system based on the calculation results of each subsystem;
[0206] The second system simulation step:
[0207] Decide the simulation behavior of the (1)th subsystem in the current simulation step of the system and obtain the simulation value;
[0208] The time difference satisfies the scenario of being greater than or equal to: (n×T-n1×T1=2×1.300000-2×0.500000=1.600000≥0.500000);
[0209] The difference is 3.200000 times T1, and the integer multiple is 3;
[0210] Perform (3) calculations on the (1)th subsystem and obtain the final calculation result;
[0211] After n1 increases by 3: n1=5;
[0212] Decide the simulation behavior of the (2)th subsystem in the current simulation step of the system and obtain the simulation value;
[0213] The time difference satisfies the scenario of being greater than or equal to: (n×T-n2×T2=2×1.300000-1×0.750000=1.850000≥0.750000);
[0214] The difference is 2.466667 times T2, and the integer multiple is 2;
[0215] Perform (2) calculations on the (2)th subsystem and obtain the final calculation result;
[0216] After n2 increases by 2: n2 = 3;
[0217] Based on the calculation results of each subsystem, the simulation calculation of step (2) of the entire system is carried out.
[0218] Another method is: if the simulation times is equal to 0, then obtaining the historical simulation calculation result data of the subsystem closest to the current time;
[0219] The historical simulation calculation result data is used as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system.
[0220] In one embodiment, in step S102, the simulation cycle of each simulation module in the system is obtained; the simulation cycle of each simulation module in the system is obtained; a plurality of simulation modules corresponding to each simulation cycle are determined; and the plurality of simulation modules are divided into the same group of subsystems.
[0221] For example, if there are 4 sub-modules in the system, the simulation period of sub-module 1 is 1ms; the simulation period of sub-module 2 is 2ms; the simulation period of sub-module 3 is 1ms; the simulation period of sub-module 4 is 3ms; the sub-modules with a simulation period of 1ms are sub-module 1 and sub-module 3; the sub-module with a simulation period of 2ms is sub-module 2; the sub-module with a simulation period of 3ms is sub-module 4; sub-module 1 and sub-module 3 are divided into the same group of subsystems, subsystem 1; sub-module 2 is divided into sub-system 2; sub-module 4 is divided into sub-system 3.
[0222] Another simulation method is described below in conjunction with FIG. 1 , which adopts the following steps:
[0223] In the first step, before the simulation starts, the model is partitioned according to the sampling period. The input signal and controller C are the first subsystem, and its sampling period Tc is 10ms. The controlled object M and sensor S are the second subsystem, and its sampling period is equal to Tm, which is 5ms.
[0224] The second step is to calculate the results of the controller C, the controlled object M and the sensor S in sequence at time 0 after the solution starts.
[0225] The third step is to calculate the simulation time corresponding to the current simulation step: TIME = n × T, where n is the sequence number of the simulation step and the starting value is 0.
[0226] The fourth step is to calculate the last simulation time of each group of subsystems in the model that is closest to the above simulation time: TIME1=Tc×n1, TIME2=Tm×n2, where n1 and n2 are the calculation times corresponding to the first subsystem and the second subsystem respectively, and the initial value is 0.
[0227] The fifth step is to calculate the difference between the current simulation time and the previous simulation time of each subsystem. If the difference is greater than or equal to N times the sampling period of the corresponding subsystem, perform N simulation calculations on this subsystem and increase the corresponding count value by N, where N is greater than or equal to 1. Otherwise, no calculation is performed on this subsystem, and the calculated simulation data of this subsystem uses the historical value closest to the current simulation time.
[0228] Exemplarily, taking the first subsystem as an example, if (TIME-TIME1) ≥ N×Tc, this simulation step calculates the input and controller C, performs an addition operation on n1, and then recalculates the difference between Timei and Time-Timei. If the difference is greater than the sampling period Ti of the subsystem, the input and controller C continue to be calculated, and an addition operation is performed on n1. This cycle is repeated N times until the difference is less than Ti, and the simulation data obtained by the last calculation is used as the result value.
[0229] The above method of the present application can configure any sampling period for different modules without affecting the solution step of the entire system, so that the simulation is more in line with engineering application scenarios. A mechanism is proposed to compare the current simulation time with the time of each subsystem to determine whether to simulate the current subsystem in the current simulation step. The problem of too small simulation steps caused by the mixing of different sampling periods is reduced, simulation resources are saved, and simulation efficiency is improved. The simulation step of the simulation model is not affected by the sampling period of each module in the model, thereby allowing the sampling period of each module in the simulation model to be consistent with its corresponding actual device.
[0230] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0231] In the second aspect, the present application proposes a simulation computing device, see the attached Figure 4 A structural schematic diagram of a simulation computing device shown; the device comprises:
[0232] A division module 41 is used to divide the entire simulation system into N groups of subsystems according to the simulation cycle before the simulation starts, where N is greater than or equal to 1;
[0233] An acquisition module 42 is used to acquire a system sampling period T of the entire simulation system and a sampling period Ti of each subsystem in the N subsystems; 1≤i≤N;
[0234] The first simulation calculation module 43 is used for determining the number of simulations of the subsystem in the current simulation step of the entire simulation system according to the simulation step number n, the system sampling period T and the sampling period Ti of the subsystem for the i-th group of subsystems when the simulation time reaches the simulation step number n during the simulation operation of the entire simulation system;
[0235] Determine the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation number;
[0236] The second simulation calculation module 44 is used to simulate the entire simulation system according to the simulation calculation result data of each group of subsystems.
[0237] In one implementation, the first simulation calculation module 43 is further configured to, if the number of simulations is greater than or equal to 1, perform simulation calculations on the subsystems for a corresponding number of times in sequence;
[0238] Get the simulation calculation result data of the last simulation calculation;
[0239] Using the simulation calculation result data of the last simulation calculation as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system; or,
[0240] If the simulation times is equal to 0, then obtaining the historical simulation calculation result data of the subsystem closest to the current time;
[0241] The historical simulation calculation result data is used as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system.
[0242] In one implementation, the first simulation calculation module 43 is further used to calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0243] Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0244] Calculate the difference between the system simulation time Time and the subsystem simulation time Timei;
[0245] C = Time-Timei;
[0246] Determine whether the difference C is greater than or equal to the sampling period Ti of the subsystem;
[0247] If yes, a simulation calculation is performed on the subsystem, and ni is increased by 1;
[0248] Calculate repeatedly until the difference C is less than the sampling period Ti of the subsystem;
[0249] Get the simulation calculation result data of the last simulation calculation.
[0250] In one embodiment, the first simulation calculation module 43 is further used to determine the number of simulations of the subsystem in the current simulation step of the entire simulation system;
[0251] Perform multiple simulation calculations on the subsystem according to the number of simulations;
[0252] Get the simulation calculation result data of the last simulation calculation.
[0253] In one implementation, the first simulation calculation module 43 is further used to calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system;
[0254] Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present;
[0255] Calculate the difference between the system simulation time Time and the subsystem simulation time Timei;
[0256] C = Time-Timei;
[0257] Calculate the quotient of the difference C and the sampling period Ti of the subsystem:
[0258] V = C / Ti;
[0259] The simulation times are obtained by rounding V:
[0260] B=[V].
[0261] In one implementation, the division module 41 is further used to obtain the simulation cycle of each simulation module in the system; determine a plurality of simulation modules corresponding to each simulation cycle; and divide the plurality of simulation modules into the same group of subsystems.
[0262] According to a third aspect of the present application, an electronic device is provided. Figure 5 The structural diagram of the electronic device shown; comprises at least one processor 51 and at least one memory 52; the memory 52 is used to store one or more program instructions; the processor 51 is used to run one or more program instructions to execute any one of the above methods.
[0263] In a fourth aspect, the present application further proposes a computer-readable storage medium, which contains one or more program instructions, and the one or more program instructions are used to execute any of the methods described above.
[0264] The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The processor reads the information in the storage medium and completes the steps of the above method in combination with its hardware.
[0265] The storage medium may be a memory, which may be, for example, a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memory.
[0266] Among them, the non-volatile memory can be a read-only memory (ROM), a programmable ROM (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory.
[0267] The volatile memory may be a random access memory (RAM) which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDRSDRAM), enhanced synchronous DRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus DRAM (DRRAM).
[0268] The storage media described in the embodiments of the present invention are intended to include, but are not limited to, these and any other suitable types of memory.
[0269] Those skilled in the art will appreciate that in one or more of the above examples, the functions described in the present invention can be implemented using a combination of hardware and software. When software is used, the corresponding functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any media that facilitates the transmission of computer programs from one place to another. Storage media can be any available media that can be accessed by general or special-purpose computers.
[0270] Although the present invention has been described in detail above by general description and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all belong to the scope of protection claimed by the present invention.
Claims
1. A simulation calculation method, characterized in that: Methods for use in motor systems include: Before the simulation starts, the entire simulation system is divided into N groups of subsystems according to the simulation cycle, where N is greater than or equal to 1; Obtaining the system sampling period T of the entire simulation system and the sampling period Ti of each subsystem in the N subsystems; 1≤i≤N; When the entire simulation system is running, when the simulation time reaches the simulation step number n, For the i-th group of subsystems, determining the number of simulations of the subsystems in the current simulation step of the entire simulation system according to the number of simulation steps n, the system sampling period T and the sampling period Ti of the subsystems; Determine the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation number, wherein the subsystem is simulated multiple times in sequence; obtain the simulation calculation result data of the last simulation calculation, including: determine the simulation number of the subsystem in the current simulation step of the entire simulation system; perform multiple simulation calculations on the subsystem according to the simulation number; obtain the simulation calculation result data of the last simulation calculation; Perform simulation based on simulation calculation result data of each group of subsystems; Wherein, determining the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation number includes: if the simulation number is greater than or equal to 1, performing simulation calculations on the subsystem for a corresponding number of times in sequence; obtaining the simulation calculation result data of the last simulation calculation; using the simulation calculation result data of the last simulation calculation as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system; or, if the simulation number is equal to 0, obtaining the historical simulation calculation result data of the subsystem closest to the current time; using the historical simulation calculation result data as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system; Perform multiple simulation calculations on the subsystem in sequence; obtain the simulation calculation result data of the last simulation calculation, including: calculating the system simulation time Time = n × Tz corresponding to the current simulation step number n of the entire simulation system; calculating the simulation time Timei = ni × Ti of the subsystem; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present; calculating the difference between the system simulation time Time and the simulation time Timei of the subsystem; C = Time-Timei; judging whether the difference C is greater than or equal to the sampling period Ti of the subsystem; if so, performing a simulation calculation on the subsystem and increasing ni by 1; looping the calculation until the difference C is less than the sampling period Ti of the subsystem; obtaining the simulation calculation result data of the last simulation calculation.
2. The simulation calculation method according to claim 1, characterized in that: Determining the number of simulations of the subsystem in the current simulation step of the entire simulation system includes: Calculate the system simulation time Time=n×Tz corresponding to the current simulation step number n of the entire simulation system; Calculate the simulation time of the subsystem Timei=ni×Ti; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present; Calculate the difference between the system simulation time Time and the subsystem simulation time Timei; C = Time-Timei; Calculate the quotient of the difference C and the sampling period Ti of the subsystem: V = C / Ti; Round V to get the number of simulations: B=[V].
3. The simulation calculation method according to claim 1, characterized in that: Before the simulation starts, the entire simulation system is divided into N groups of subsystems according to the simulation cycle, including: Get the simulation cycle of each simulation module in the system; Determine a plurality of simulation modules corresponding to each simulation cycle; The plurality of simulation modules are divided into the same group of subsystems.
4. A simulation computing device, characterized in that: Devices for motor systems include: A partitioning module is used to divide the entire simulation system into N groups of subsystems according to the simulation cycle before the simulation starts, where N is greater than or equal to 1; An acquisition module, used to acquire a system sampling period T of the entire simulation system and a sampling period Ti of each subsystem in the N subsystems; 1≤i≤N; The first simulation calculation module is used for determining the number of simulations of the subsystem in the current simulation step of the entire simulation system according to the simulation step number n, the system sampling period T and the sampling period Ti of the subsystem for the i-th group of subsystems when the simulation time reaches the simulation step number n during the simulation operation of the entire simulation system; Determine the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system according to the simulation number, wherein the subsystem is simulated multiple times in sequence; obtain the simulation calculation result data of the last simulation calculation, including: determine the simulation number of the subsystem in the current simulation step of the entire simulation system; perform multiple simulation calculations on the subsystem according to the simulation number; obtain the simulation calculation result data of the last simulation calculation; The second simulation calculation module is used to simulate the entire simulation system according to the simulation calculation result data of each group of subsystems; Wherein, the first simulation calculation module is also used for, if the number of simulations is greater than or equal to 1, then performing simulation calculations on the subsystem for a corresponding number of times in sequence; obtaining the simulation calculation result data of the last simulation calculation; using the simulation calculation result data of the last simulation calculation as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system; or, if the number of simulations is equal to 0, obtaining the historical simulation calculation result data of the subsystem closest to the current time; using the historical simulation calculation result data as the simulation calculation result data of the subsystem in the current simulation step of the entire simulation system; Perform multiple simulation calculations on the subsystem in sequence; obtain the simulation calculation result data of the last simulation calculation, including: calculating the system simulation time Time = n × Tz corresponding to the current simulation step number n of the entire simulation system; calculating the simulation time Timei = ni × Ti of the subsystem; wherein ni is the number of historical calculations of the i-th group of subsystems up to the present; calculating the difference between the system simulation time Time and the simulation time Timei of the subsystem; C = Time-Timei; judging whether the difference C is greater than or equal to the sampling period Ti of the subsystem; if so, performing a simulation calculation on the subsystem and increasing ni by 1; looping the calculation until the difference C is less than the sampling period Ti of the subsystem; obtaining the simulation calculation result data of the last simulation calculation.
5. An electronic device, characterized in that: include: at least one processor and at least one memory; The memory is used to store one or more program instructions; The processor is used to run one or more program instructions to execute the method according to any one of claims 1-3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes one or more program instructions, and the one or more program instructions are used to execute the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Testing platform and method for combined cooling, heating and power system
CN104714539A
Network control system co-simulation method based on NS3 and MATLAB
CN110457747A