A flexible combined fixed-step simulation method and system
Through the elastic combination of fixed-step length simulation method, the customized step length mode and adaptive step length mode are adopted to dynamically adjust the simulation step length, which solves the difficulty of balancing the simulation efficiency of the existing fixed-step length method in complex information physics system models and difficult to balance the simulation efficiency and The problem of accuracy achieves efficient and accurate simulation calculations.
Patent Information
- Application Number
- CN202411489025.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-24
AI Technical Summary
The existing fixed-step length method is difficult to balance simulation efficiency and simulation accuracy when simulating complex information physics system models, especially in the initial stage and transient response stage, which fluctuates greatly, resulting in a decrease in simulation efficiency.
The elastic combined fixed-step length simulation method is adopted to dynamically adjust the simulation step length by customizing the step length mode and adaptive step length mode in time segments. The custom step size mode of time segments calculates the target simulation step size by customizing the number of integral steps of the sub-interval; the adaptive step size mode recalculates the appropriate small step size based on the event triggered update state change rate in the mathematical model.
While improving the simulation accuracy of sub-sections, the global simulation efficiency is also taken into account. It is suitable for the simulation of complex information physics system models, avoiding the computational efficiency problems caused by small steps in traditional fixed-step methods.
Smart Images

Figure CN119004874B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of numerical simulation calculation of industrial Internet, and in particular to a flexible combined fixed-step simulation method and system. Background Art
[0002] In the field of numerical simulation and calculation of the industrial Internet, the key to the simulation task is how to efficiently and accurately simulate the dynamic characteristics of complex information-physical system models, such as dynamic simulation of new energy vehicles and model-based control system simulation; this usually requires that the simulation model is sufficiently sophisticated, and the numerical calculation method used to solve the simulation model has good convergence and stability. Mainstream numerical calculation methods can be divided into fixed-step methods and variable-step methods. The fixed-step method fixes the time step of each integral calculation during the entire simulation process. Regardless of how the state of the system changes, the step size is a pre-set constant. The variable-step method is a type of algorithm that dynamically adjusts the time step size during the numerical integration process. This type of algorithm flexibly adjusts the step size according to changes in the system state to adapt to the complexity of the system behavior in different time periods, thereby improving the calculation efficiency while ensuring numerical accuracy.
[0003] The variable step size method is proposed to solve the contradiction between efficiency and accuracy in the fixed step size method. It is usually the preferred method for simulating complex cyber-physical system models. However, in some specific simulation scenarios, the fixed step size method has more advantages than the variable step size method, such as:
[0004] 1) Real-time system simulation: Computing resources are limited and real-time performance must be guaranteed. A fixed step size can ensure that the time for each integral calculation is constant, which facilitates real-time system scheduling tasks.
[0005] 2) Resource-constrained embedded systems: Embedded systems usually have strict requirements on computing resources, storage, and power consumption. The computational complexity of the fixed-step integration algorithm is relatively low, making it suitable for application in these resource-constrained environments.
[0006] 3) Long-term simulation: In some simulations that need to run for a long time, the fixed-step algorithm can simplify the control of numerical errors, and because the step size is constant, the error accumulation can be easily estimated.
[0007] 4) Linear system simulation: For linear or nearly linear systems, fixed-step integration algorithms are often accurate enough. The system behavior does not change much at each time step, and a fixed step size can provide a good balance, ensuring accuracy while controlling computational overhead.
[0008] Practice shows that the fixed-step method performs well in the above simulation scenarios, but when the simulation object is a complex information-physical system model, it is difficult for the fixed-step method to balance simulation efficiency and simulation accuracy. For example, the complex information-physical system model has strong state fluctuations in the initial stage of simulation and the transient response stage. In order to accurately capture these dynamic behaviors, the simulation step should be small enough, forcing the entire simulation process to use a small step, which leads to a serious decrease in overall simulation efficiency. For another example, for the simulation of the anti-interference ability of a stable operating system after external disturbances (i.e., fault injection simulation), there is only state oscillation in a small time period after the external event disturbance, and a smaller fault simulation step is required to ensure convergence and accuracy; in the stable operation stage, the simulation step may be dozens to hundreds of times the fault step. This situation also occurs in real-time simulation scenarios. When unnecessary model calculations consume too many computing resources, this will lead to an increase in overall power consumption and cost. Summary of the invention
[0009] The purpose of the present invention is to provide a flexible combined fixed-step simulation method and system in order to solve the problem that the existing fixed-step method is difficult to balance simulation efficiency and simulation accuracy when the simulation object is a complex information-physical system model.
[0010] The above-mentioned purpose of the present application is achieved through the following technical solutions:
[0011] S1: Obtain a cyber-physical system model; compile the cyber-physical system model into a mathematical model in the form of a standard state equation;
[0012] S2: Set the fixed-step simulation algorithm and basic simulation step; set the fixed-step mode used in the simulation; the fixed-step mode includes: time-segment custom step mode and adaptive step mode;
[0013] S3: Generate a simulation configuration file through a fixed-step simulation algorithm, a basic simulation step, and a fixed-step mode;
[0014] S4: Perform single-step integration through simulation configuration files and mathematical models to complete the simulation.
[0015] Optionally, step S2 includes:
[0016] If the time-division custom step mode is selected, the simulation interval is divided into time periods to obtain a preset number of sub-intervals;
[0017] Set the number of integration steps for each subinterval; calculate the target simulation step size for each subinterval by combining the number of integration steps for each subinterval with the basic simulation step size;
[0018] Target simulation step length = basic simulation step length / number of integration steps;
[0019] In each subinterval, a single-step integration is performed using the corresponding target simulation step size.
[0020] Optionally, step S2 further includes: if the adaptive step size mode is selected, setting the minimum step size in the simulation interval and the number of continuous communication steps in the step size transition period;
[0021] The minimum step size is the lower bound of the integral step size that limits the step size transition period; the number of continuous communication steps specifies the time span of the step size transition period.
[0022] Optionally, step S4 includes:
[0023] S41: Read the simulation configuration text file and initialize it. If the initialization fails, the simulation is exited, otherwise, the simulation step loop is entered;
[0024] S42: The simulation step cycle stage adopts the time-segment custom step mode: if the current simulation advancement time is in the sub-interval, select the target simulation step to perform single-step integration; if the current simulation advancement time is not in the sub-interval, select the basic simulation step to perform single-step integration;
[0025] S43: The adaptive step size mode is adopted in the simulation step cycle stage: if the current simulation advancement moment is in the step size transition period, the simulation transition step size is selected to perform single-step integration; if the current simulation advancement moment is not in the step size transition period, the basic simulation step size is selected to perform single-step integration.
[0026] Optionally, step S43 further includes:
[0027] In the adaptive step mode, when an event in the mathematical model is triggered, the mathematical model is updated, and the state change rate and state quantity of the mathematical model at the updated moment are obtained;
[0028] According to the state change rate and basic simulation step size at the updated moment, recalculate the simulation transition step size, as follows:
[0029]
[0030] in, represents the simulation transition step; represents the basic simulation step size; Represents the minimum value function; represents the floor function; Indicates the rate of state change; Indicates state quantity;
[0031] The updated simulation transition step is compared with the minimum step. If the simulation transition step is less than or equal to the minimum step, the minimum step is used as the updated simulation transition step and a single-step integration is performed.
[0032] If the simulation transition step size is greater than or equal to the minimum step size, a single-step integration is performed using the updated simulation transition step size.
[0033] A flexible combined fixed-step simulation system, the system comprising: a model compiler, a simulation configuration generator and a solver;
[0034] The model compiler is used to compile the acquired information-physical system model into a mathematical model in the form of a standard state equation, and input it into the solver;
[0035] The simulation configuration generator includes: a user interaction module and a configuration file generation module;
[0036] The user interaction module is used to implement user-defined simulation configuration and provide a visual interface and parameter configuration options;
[0037] The configuration file generation module is used to generate the user-defined simulation configuration into a simulation configuration file that can be read by the solver according to a preset format;
[0038] The solver performs fixed-step simulation calculations based on the simulation configuration file and in combination with the input mathematical model in the form of a standard state equation.
[0039] Optionally, the system further includes:
[0040] The robot information-physical system model is modeled through the model compiler to obtain the robot dynamics model, that is, the mathematical model, and the mathematical form is as follows:
[0041]
[0042]
[0043] in, represents the state variable derivative; represents the state equation, represents the state variable, represents the control variable; Indicates time; represents the output equation; Represents an output variable.
[0044] A computer-readable storage medium stores instructions. When the instructions are executed, an elastic combination fixed-step simulation method is executed.
[0045] The beneficial effects of the technical solution provided by this application are:
[0046] 1. Through the pre-designed fixed step mode, users can customize the simulation sub-intervals in the time-division custom step mode, and flexibly combine the integral steps of the sub-intervals, such as increasing the integral steps of the initial stage time interval and reducing the integral steps of the stable stage interval, so as to improve the simulation accuracy of the sub-interval while taking into account the global simulation efficiency. It is suitable for offline simulation and fault injection simulation, which have accuracy requirements for specific time intervals and predictable problem intervals. By specifying the integral steps of each sub-interval instead of directly giving the target simulation step, the problem caused by the numerical representation error is avoided. In the adaptive step mode, when an event in the mathematical model is triggered and the state suddenly changes, the appropriate small step is recalculated according to the state change rate, and the small step is used for integral calculation only during the step transition period. Users can adjust the transition period length according to stability requirements to avoid the computational efficiency problem caused by the global use of small steps. This mode also avoids the work cost of artificially dividing sub-intervals in the time-division custom step mode and solves the problem of unpredictable fault points. This mode is applicable to both offline simulation and online simulation scenarios.
[0047] 2. The design target simulation step and simulation transition step are always designed to be integer multiples of the simulation basic step, which can effectively avoid the problem of misalignment between simulation advancement time and communication time introduced by directly specifying the floating-point step value in the traditional way, making it impossible for the model to obtain valid input data. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The present application will be further described below with reference to the accompanying drawings and embodiments, in which:
[0049] Figure 1 is a step diagram in an embodiment of the present application;
[0050] Figure 2 is a schematic diagram of the system structure in an embodiment of the present application;
[0051] Figure 3 It is a schematic diagram of the simulation configuration page in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to have a clearer understanding of the technical features, purposes and effects of the present application, the specific implementation methods of the present application are now described in detail with reference to the accompanying drawings.
[0053] An embodiment of the present application provides an elastic combination fixed-step simulation method.
[0054] Please refer to Figure 1 , Figure 1 : is a step diagram of an elastic combination fixed-step simulation method in an embodiment of the present application, comprising:
[0055] S1: Obtain a cyber-physical system model; compile the cyber-physical system model into a mathematical model in the form of a standard state equation;
[0056] Specifically, the information-physical system models include: robot system model, new energy vehicle system model, and satellite system model.
[0057] S2: Set the fixed-step simulation algorithm and basic simulation step; set the fixed-step mode used in the simulation; the fixed-step mode includes: time-segment custom step mode and adaptive step mode;
[0058] Specifically, the simulation configuration generator provides a visual simulation configuration page, on which a fixed-step simulation algorithm can be selected. The fixed-step algorithm should be specifically implemented in the solver, and in some embodiments may include the Euler algorithm and various-order Runge-Kutta fixed-step algorithms. The fixed-step simulation algorithms include: the Euler algorithm and various-order Runge-Kutta fixed-step algorithms;
[0059] Specifically, the basic simulation step of the present invention has multiple functions, function one: defining the time interval for storing simulation results; function two: defining the communication interval for external input and output; function three: assisting in determining the segmented fixed step value. In this embodiment, the basic simulation step is equal to the output step, and can also be determined by the output step number, which is calculated as basic simulation step = simulation interval / output step number.
[0060] Specifically, the time-division self-defined step-size mode and the adaptive step-size mode of the present invention are two mutually exclusive modes, and only one of them can be selected for each simulation.
[0061] Step S2 includes:
[0062] If the time-division custom step mode is selected, the simulation interval is divided into time periods to obtain a preset number of sub-intervals;
[0063] Set the number of integration steps for each subinterval; calculate the target simulation step size for each subinterval by combining the number of integration steps for each subinterval with the basic simulation step size;
[0064] Target simulation step length = basic simulation step length / number of integration steps;
[0065] In each subinterval, a single-step integration is performed using the corresponding target simulation step size.
[0066] Specifically, after the user selects the time-segment custom step mode, the simulation interval can be further divided into a preset number of subintervals, which are determined by the start time and end time nodes. The user continues to specify the number of integration steps for each subinterval, and the simulation step calculation formula for each subinterval is target simulation step = basic simulation step / integration step; the solver will use the target simulation step to perform single-step integration within the subinterval, and use the basic simulation step outside the subinterval to perform single-step integration.
[0067] The present invention adopts the method of specifying the number of integral steps for each subinterval instead of directly giving the target simulation step length in order to avoid the problem caused by the numerical representation error. The basic simulation step length is used as the simulation communication interval, so the solver must ensure that the simulation advancement time coincides with the communication time, which requires that the basic simulation step length is an integer multiple of the solver simulation step length. Directly giving the target simulation step length in the form of a floating point number may cause the simulation advancement time to be misaligned with the communication time, and the model cannot obtain valid input data.
[0068] Step S2 also includes: if the adaptive step size mode is selected, setting the minimum step size in the simulation interval and the number of continuous communication steps in the step size transition period;
[0069] The minimum step size is the lower bound of the integral step size that limits the step size transition period; the number of continuous communication steps specifies the time span of the step size transition period.
[0070] Specifically, after selecting the adaptive step size mode, the user can further specify the minimum step size in the simulation interval and the number of continuous communication steps during the step size transition period. The minimum step size is the lower bound of the integral step size during the step size transition period to avoid a serious decrease in simulation efficiency due to a small simulation transition step size. The number of continuous communication steps during the step size transition period indirectly represents the time span of this stage, and the calculation formula can be expressed as: Sub-interval length = number of continuous communication steps Basic simulation step size. The user specifies the time span of the step size transition period, which helps improve simulation efficiency, accuracy and stability.
[0071] S3: Generate a simulation configuration file through a fixed-step simulation algorithm, a basic simulation step, and a fixed-step mode;
[0072] S4: Perform single-step integration through simulation configuration files and mathematical models to complete the simulation.
[0073] Step S4 includes:
[0074] S41: Read the simulation configuration text file and initialize it. If the initialization fails, the simulation is exited, otherwise, the simulation step loop is entered;
[0075] S42: The simulation step cycle stage adopts the time-segment custom step mode: if the current simulation advancement time is in the sub-interval, select the target simulation step to perform single-step integration; if the current simulation advancement time is not in the sub-interval, select the basic simulation step to perform single-step integration;
[0076] S43: The adaptive step size mode is adopted in the simulation step cycle stage: if the current simulation advancement moment is in the step size transition period, the simulation transition step size is selected to perform single-step integration; if the current simulation advancement moment is not in the step size transition period, the basic simulation step size is selected to perform single-step integration.
[0077] Step S43 also includes:
[0078] In the adaptive step mode, when an event in the mathematical model is triggered, the mathematical model is updated, and the state change rate and state quantity of the mathematical model at the updated moment are obtained;
[0079] According to the state change rate and basic simulation step size at the updated moment, recalculate the simulation transition step size, as follows:
[0080]
[0081] in, represents the simulation transition step; represents the basic simulation step size; Represents the minimum value function; represents the floor function; Indicates the rate of state change; Indicates the state quantity;
[0082] The updated simulation transition step is compared with the minimum step. If the simulation transition step is less than or equal to the minimum step, the minimum step is used as the updated simulation transition step and a single-step integration is performed.
[0083] If the simulation transition step size is greater than or equal to the minimum step size, a single-step integration is performed using the updated simulation transition step size.
[0084] Specifically, in the adaptive step mode, the solver simulation state is divided into a step stability period and a step transition period. The step stability period refers to the process in which the solver uses the basic simulation step to perform single-step integration, while the step transition period refers to the process in which the solver uses the simulation transition step calculated in real time to perform single-step integration after the event is triggered. During the simulation process, the model may be affected by internal events or external events, causing the state to change. In some embodiments, internal events include valves being opened, circuit switches being closed, etc., and external events mainly refer to changes in input instructions. When the event is triggered, the solver updates the model state and switches its own state to the step transition period. The solver immediately obtains the state change rate and calculates the simulation transition step to ensure that the basic simulation step is an integer multiple of the simulation transition step, and the lower limit of the simulation transition step is the minimum step defined by the user. Then the solver uses the simulation transition step to perform single-step integration until the specified number of continuous communication steps is completed, and the solver state is switched to the step stability period, and the simulation step is switched to the simulation basic step.
[0085] Please refer to Figure 2 , Figure 2 It is a schematic diagram of the system structure of a flexible combined fixed-step simulation system in an embodiment of the present application, wherein the system comprises: a model compiler, a simulation configuration generator and a solver;
[0086] The model compiler is used to compile the acquired information-physical system model into a mathematical model in the form of a standard state equation, and input it into the solver;
[0087] The simulation configuration generator includes: a user interaction module and a configuration file generation module;
[0088] The user interaction module is used to implement user-defined simulation configuration and provide a visual interface and parameter configuration options;
[0089] The configuration file generation module is used to generate the user-defined simulation configuration into a simulation configuration file that can be read by the solver according to a preset format;
[0090] Specifically, the main function of the user interaction module is to provide a visual simulation configuration page, please refer to Figure 3 , Figure 3 This is a schematic diagram of the simulation configuration page of this system. As an embodiment, this page provides various simulation configuration contents, including simulation start time and simulation end time, integration algorithm drop-down option bar, output interval, fixed step mode, etc.
[0091] Specifically, the configuration file generation module realizes generating a specific text configuration file that can be read by the solver according to the specific format requirements of the user-defined simulation configuration. As an embodiment, the text file is in XML (Extensible Markup Language) format, and contains simulation start time, simulation end time, integration algorithm, simulation basic step size, time-divided fixed step size, etc.
[0092] The solver performs fixed-step simulation calculations based on the simulation configuration file and in combination with the input mathematical model in the form of a standard state equation.
[0093] Specifically, the solver performs fixed-step simulation calculations according to the contents of the simulation configuration file. As an embodiment, the solver operation phase includes an instantiation phase, an initialization phase, and a simulation step loop phase. In the simulation instantiation phase, the solver reads the simulation configuration file and constructs the necessary solution data. In the simulation initialization phase, the solver completes model initialization and integration algorithm initialization. In the simulation step loop phase, the solver uses the selected integration algorithm to perform numerical integration. As an embodiment, the forward Euler method can be used, and its loop process can be expressed by the following equation:
[0094]
[0095]
[0096] in, Represents the numerical integration result The state variables at time, represents the state equation, represents the control variable, Indicates time, express The target simulation step size is determined at all times. Compared with the traditional fixed step size method, It is no longer a constant value, but can be configured according to the fixed-step mode; Indicates the calculated Output variable at time; Represents the output equation.
[0097] The system further comprises:
[0098] The robot information-physical system model is modeled through the model compiler to obtain the robot dynamics model, that is, the mathematical model, and the mathematical form is as follows:
[0099]
[0100]
[0101] in, represents the state variable derivative; represents the state equation, represents the state variable, represents the control variable; Indicates time; represents the output equation; Represents an output variable.
[0102] The present application also discloses a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the above-mentioned elastic combined fixed-step simulation method.
[0103] The above are only exemplary embodiments of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and practice, those skilled in the art will easily think of other embodiments of the present disclosure.
[0104] This application is intended to cover any variation, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the art not described in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. An elastic combination fixed-step simulation method, characterized in that: The method comprises the following steps: S1: Obtain a cyber-physical system model; compile the cyber-physical system model into a mathematical model in the form of a standard state equation; S2: Set the fixed-step simulation algorithm and basic simulation step; Set the fixed step mode used in the simulation; the fixed step mode includes: time-segment custom step mode and adaptive step mode; The basic simulation step size is equal to the output step size, which is determined by the output step number. The calculation method is basic simulation step size = simulation interval / output step number; The basic simulation step is used to define the time interval for storing simulation results, that is, the basic simulation step is equal to the output step; The basic simulation step is also used to define the communication time interval of external input and output, that is, the basic simulation step is equal to the communication time interval; Step S2 includes: If the time-division custom step mode is selected, the simulation interval is divided into time periods to obtain a preset number of sub-intervals; Set the number of integration steps for each subinterval; calculate the target simulation step size for each subinterval by combining the number of integration steps for each subinterval with the basic simulation step size; Target simulation step length = basic simulation step length / number of integration steps; In each subinterval, a single-step integration is performed using the corresponding target simulation step size; Step S2 also includes: if the adaptive step size mode is selected, setting the minimum step size in the simulation interval and the number of continuous communication steps in the step size transition period; The minimum step size is the lower bound of the integral step size that limits the step size transition period; the time span of the step size transition period is specified by the number of continuous communication steps; S3: Generate a simulation configuration file through a fixed-step simulation algorithm, a basic simulation step, and a fixed-step mode; S4: Perform single-step integration through simulation configuration files and mathematical models to complete the simulation; Step S4 includes: S41: Read the simulation configuration text file and initialize it. If the initialization fails, the simulation is exited, otherwise, the simulation step loop is entered; S42: The simulation step cycle stage adopts the time-segment custom step mode: if the current simulation advancement time is in the sub-interval, select the target simulation step to perform single-step integration; if the current simulation advancement time is not in the sub-interval, select the basic simulation step to perform single-step integration; S43: The adaptive step size mode is adopted in the simulation step cycle stage: if the current simulation advancement moment is in the step size transition period, the simulation transition step size is selected to perform single-step integration; if the current simulation advancement moment is not in the step size transition period, the basic simulation step size is selected to perform single-step integration.
2. The elastic combination fixed-step simulation method according to claim 1, characterized in that: Step S43 also includes: In the adaptive step mode, when an event in the mathematical model is triggered, the mathematical model is updated, and the state change rate and state quantity of the mathematical model at the updated moment are obtained; According to the state change rate and basic simulation step size at the updated moment, recalculate the simulation transition step size, as follows: in, represents the simulation transition step; represents the basic simulation step size; Represents the minimum value function; represents the floor function; Indicates the rate of state change; Indicates the state quantity; The updated simulation transition step is compared with the minimum step. If the simulation transition step is less than or equal to the minimum step, the minimum step is used as the updated simulation transition step and a single-step integration is performed. If the simulation transition step size is greater than or equal to the minimum step size, a single-step integration is performed using the updated simulation transition step size.
3. An elastic combination fixed-step simulation system, used to implement an elastic combination fixed-step simulation method as claimed in any one of claims 1 to 2, characterized in that: The system includes: a model compiler, a simulation configuration generator and a solver; The model compiler is used to compile the acquired information-physical system model into a mathematical model in the form of a standard state equation, and input it into the solver; The simulation configuration generator includes: a user interaction module and a configuration file generation module; The user interaction module is used to implement user-defined simulation configuration and provide a visual interface and parameter configuration options; The configuration file generation module is used to generate the user-defined simulation configuration into a simulation configuration file that can be read by the solver according to a preset format; The solver performs fixed-step simulation calculations based on the simulation configuration file and in combination with the input mathematical model in the form of a standard state equation.
4. The elastic combined fixed-step simulation system according to claim 3, characterized in that: The system further comprises: The robot information-physical system model is modeled through the model compiler to obtain the robot dynamics model, that is, the mathematical model, and the mathematical form is as follows: in, represents the state variable derivative; represents the state equation, represents the state variable, represents the control variable; Indicates time; represents the output equation; Represents an output variable.
5. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed by a computer, the method according to any one of claims 1 to 2 is executed.
Citation Information
Patent Citations
Numerical integration method for electric power system full dynamic simulation
CN101446991A
System and method for emulating hybrid systems
WO2017037659A1