A numerical integration method for solving initial value problems of stiff ordinary differential equations in simulation

By employing BDF, IBDF, SDISRK34, and SDISRK44 algorithms and the d-LM method in simulations, combined with a variable step size strategy, the instability and efficiency of numerical solutions for initial value problems of rigid ordinary differential equations are addressed, achieving efficient and stable solution results suitable for system-level simulations.

CN114154110BActive Publication Date: 2024-11-26西安中锐创联科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111479747.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2024-11-26
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

When dealing with initial value problems of rigid ordinary differential equations, especially in large-scale or multidisciplinary system simulations, existing technologies struggle to balance stability and efficiency in numerical solutions. Foreign commercial and open-source tools have failed to effectively incorporate new algorithms from recent years, and China lacks an independently developed ODE-IVP solver.

Method used

The BDF, IBDF, SDISRK34 and SDISRK44 algorithms are used as the basis for integral solving algorithms. Combined with the damped-Levenberg-Marquardt optimization method (d-LM method) and variable step size strategy, a numerical integral solving method for rigid ordinary differential equations in simulation is constructed. The initial value of the iteration is optimized by the prediction-correction method, and the damping coefficient and variable step size mechanism are introduced to improve stability and efficiency.

Benefits of technology

It provides solvers applicable to both rigid and non-rigid ordinary differential equations, improving solution efficiency and stability, filling a gap in the domestic market, and achieving a computational level comparable to foreign commercial tools. It is suitable for system-level simulation, especially large-scale multidisciplinary system simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0003394855920000081
    Figure BDA0003394855920000081
  • Figure BDA0003394855920000101
    Figure BDA0003394855920000101
  • Figure BDA0003394855920000102
    Figure BDA0003394855920000102
Patent Text Reader

Abstract

The present invention discloses a numerical integral solution method applicable to the initial value problem of rigid ordinary differential equations. On the basis of ensuring the solution accuracy, the d-LM method is proposed, which further improves the implicit operation stability. On the basis of filling the domestic gap, its operation efficiency is close to that of similar foreign products; compared with foreign commercial system simulation software tools, the numerical method of the present invention is more novel, and the new numerical solution method after the 1990s is realized and applied, and the numerical solution process is more stable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of simulation, and relates to a numerical integration solution method for an initial value problem of a rigid ordinary differential equation in simulation. Background Art

[0002] Many phenomena in engineering technology, such as the operation of control systems, the operation of power systems, the movement of aircraft, the process of chemical reactions, etc., have mathematical models that are initial value problems (IVP) of ordinary differential equations (ODE). Many partial differential equations can also be approximately simplified into initial value problems of ordinary differential equations for solution. Generally speaking, the numerical solution of ordinary differential equations is relatively mature, the theory is also very complete, and there are many mature solution algorithms to choose from.

[0003] However, there is a class of ordinary differential equations that encounter considerable difficulties in numerical solution. Some of the components of the solutions of this type of ordinary differential equations change very quickly, while others change very slowly. From the perspective of numerical solution, a smaller integration step should be used when the solution changes quickly, and a larger integration step can be used when the fast-changing components tend to be stable. However, a large amount of theory and practice have proved that regardless of whether the solution changes steadily, the integration step cannot be enlarged, otherwise the numerical solution will be unstable and then divergent. When conducting system dynamics analysis, this phenomenon will bring great difficulties and troubles to the numerical solution, especially when the system is large or involves multiple disciplines. This phenomenon is very common.

[0004] This property of ordinary differential equations is called stiffness, and this type of problem is called a stiffness problem. Stiffness problems are also called ill-conditioned equations or badly conditioned equations in some literature. This phenomenon is often encountered in actual engineering. For example, in a control system, the inertia of the controlled object is large and has a large time scale, while the controller is sensitive and has a small time scale; for flight dynamics, its attitude movement is fast and the center of mass movement is relatively slow; in a thermal fluid system, the pressure fluctuation is very fast and propagates at the speed of sound in the fluid, while the heat transfer process is slow, and the change scale is obviously not on the same order of magnitude; for complex power systems, affected by parasitic capacitance, the time scales between different components will also be very different.

[0005] Along with the third wave of industrial revolution represented by atomic energy, aerospace, computer and other high-tech technologies starting in the 1950s, numerical calculation of system dynamics problems has gradually moved from mathematical theory to engineering practice, giving rise to numerous open source programs and commercial simulation tools.

[0006] The more widely used open source solvers include: CVODE, which uses the BDF algorithm and is still frequently updated; RADAU5, which uses the implicit Runge-Kutta method; Dop853 and Dopri5, which use the explicit Runge-Kutta method; SDIRK, which uses the diagonal implicit Runge-Kutta method; MEBDF based on the improved generalized BDF algorithm; DIFSUB and LSODE, which are designed based on the classic BDF algorithm and are widely used; Python's open source computing package scipy.integrate.ode (its underlying layer is still calling LSODE and ODEPACK); the DeSolve engineering package in R language based on the explicit Runge-Kutta method (according to the official website description, its underlying layer is still calling the open source ODEPACK computing package of FORTRAN language, the program package based on the explicit Euler / Runge-Kutta method, and the program package RADAU based on the implicit Runge-Kutta method); the Julia suite "DifferentialEquations.jl" for high-performance solvers of differential equations, etc.

[0007] In addition to open source solvers, many excellent commercial simulation solving tools have also gradually appeared in front of the public since the 1970s. Among all commercial system simulation tools, MATLAB / simulink is generally considered to have the best overall performance. Its ODE solver contains almost all conventional algorithms that can be seen, such as BDF method, improved BDF method, Adams method, explicit or implicit Runge-Kutta method, etc.; in addition, Dymola, SimulationX, Motion, Adams and AMESim are also very good dynamic solving tools. Since the models handled by these tools are mainly multidisciplinary or multi-body dynamics and other problems, this type of model generally has greater rigidity, so the solvers of these software basically use implicit multi-step methods, the most common of which is BDF and its improved method.

[0008] my country's Mworks is also a simulation tool for solving Modelica model dynamics, but its solver is still implemented by calling some foreign algorithm packages. Compared with the existing technology accumulation in foreign countries, my country has obvious deficiencies in the following two aspects: on the one hand, there is no domestically produced ODE-IVP solver in China, and most of them call foreign packages (including commercial and open source), such as CVODE, Dassl, Radau5, MEBDF, LSODE, etc., which is completely blank in China in this field; on the other hand, foreign open source packages were formed at an early age, and most of them do not include new methods in recent years. In addition, foreign commercial tools generally entered the Chinese market around 2000, and the solver kernel has not been greatly changed. Like the open source packages, no new algorithms in recent years have been incorporated into them. Summary of the invention

[0009] The technical problem solved by the present invention is to provide a numerical integration solution method for the initial value problem of rigid ordinary differential equations in simulation, providing underlying support for solving system-level simulation (especially large-scale, multidisciplinary system simulation).

[0010] The present invention is achieved through the following technical solutions:

[0011] A numerical integration method for solving initial value problems of stiff ordinary differential equations in simulation includes the following operations:

[0012] 1) According to the problem to be solved, select the necessary parameters including the integral solution algorithm, initial integral step size, and convergence residual;

[0013] The integral solution algorithm is selected from the BDF algorithm, the IBDF algorithm, the SDISRK34 algorithm and the SDISRK44 algorithm;

[0014] 2) Make a judgment based on the selected solution algorithm: if a multi-step method is used, then determine whether the current solver uses the BDF or IBDF method. After the judgment is completed, continue to execute 3);

[0015] If the single-step method is used, then determine whether the current solver uses the SDISRK34 algorithm or the SDISRK44 algorithm. After the determination is completed, jump to execution 5);

[0016] 3) Construct the target nonlinear equations according to the selected solution algorithm;

[0017] 4) Using multiple prediction step algorithms to execute multiple predicted values ​​of real solutions, respectively substitute them into the target nonlinear equation group, and select a set of solution vectors with the smallest error as the solution vector of the prediction step;

[0018] 5) The solution vector obtained in the prediction step is used as the initial value of the iteration to solve the least squares solution of the target nonlinear equation system;

[0019] When solving, the iterative formula is first constructed, and the damping coefficient of the iterative step is introduced; then the iterative step is updated to determine whether the convergence requirement is met; if so, the result is output as the true solution vector, otherwise the iterative process is repeated to continuously obtain a new solution vector until the convergence error requirement is met;

[0020] 6) Execute variable step-size integration strategy: respectively execute the step-size optimization mechanism for providing the integration step size, the switching mechanism for judging and changing the integration step size, and the variable step-size numerical back-interpolation mechanism for ensuring the correctness of the calculation results;

[0021] After the variable step-size integration strategy is executed, determine whether the error meets the requirements; if so, execute 7);

[0022] If not satisfied, return to 1) and reset the integration step size according to the variable step size strategy;

[0023] 7) The time axis moves forward one time step to determine whether the simulation needs to be ended;

[0024] If satisfied, execute 8); if not satisfied, return to 1) and reset the integral step size according to the variable step size strategy;

[0025] 8) End the simulation calculation, store and display the calculation results.

[0026] Compared with the prior art, the present invention has the following beneficial technical effects:

[0027] The numerical integration solution method for the initial value problem of rigid ordinary differential equations in simulation provided by the present invention is benchmarked against mainstream commercial and open source system simulation solvers abroad, and provides a solver suitable for solving the initial value problem of rigid and non-rigid ordinary differential equations (ODE-IVP), providing underlying support for solving system-level simulations (especially large-scale, multidisciplinary system simulations).

[0028] The present invention integrates the damped Newton method on the basis of the classic Levenberg-Marquardt optimization algorithm and proposes a damped-Levenberg-Marquardt optimization method (abbreviated as d-LM method); this algorithm can take into account both operating efficiency and stability. By comparing with similar calculation programs in foreign commercial tools MATLAB, the present method is equivalent to foreign commercial tools in terms of efficiency.

[0029] The present invention predicts the solution through a variety of relatively simple explicit algorithms in the prediction-correction method, with the aim of providing a point closer to the true solution to ensure that the implicit solution in the next step converges more easily. This step is for the sake of protecting the stability of the solution, but it will sacrifice a little bit of efficiency. Although such a processing method will lose some computational efficiency in the prediction step, it can provide a better initial value for the iteration for the correction step, thereby reducing the number of iterations m. After comprehensive consideration and a large number of tests, it is found that such processing has a significant improvement in global efficiency.

[0030] The present invention also adopts a new variable step-size strategy that can greatly improve the efficiency of integral solution. On the basis of filling the domestic gap, the computational efficiency is at the same level as similar foreign products; further, the d-LM method is proposed on the basis of ensuring the accuracy of the solution, which improves the computational stability. Compared with foreign commercial system simulation software tools, the numerical method of the present invention is more novel, and the new numerical solution method after the 1990s is implemented and applied, and the numerical solution process is more stable. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a schematic diagram of the overall process of the present invention,

[0032] Figure 2-Figure 5 They are Figure 1 The enlarged view of the first to fourth parts;

[0033] Figure 6 It is a schematic diagram of the Butcher matrix of the 3rd level 4th order single diagonal implicit symplectic RK method;

[0034] Figure 7 It is a schematic diagram of the Butcher matrix of the 4th level 4th order single diagonal implicit symplectic RK method;

[0035] Figure 8 This is a schematic diagram of the workflow of variable step-size integration;

[0036] Fig. 9 This is a diagram of the organization of the core code of the solver;

[0037] Fig.10 It is a schematic diagram of the calculation results of the d-LM algorithm in the solver;

[0038] Fig.11 To use the calculation results of the fsolve command in MATLAB;

[0039] Fig.12 Comparison of the computational time between the d-LM method and the fsolve command;

[0040] Fig.13 To solve the stiff equations using Simulink commercial software;

[0041] Fig.14 Comparison of the calculation results between this solver and the commercial software Simulink;

[0042] Fig.15 Comparison of the computational efficiency of this solver with foreign commercial tools;

[0043] Fig.16 is the numerical solution of y1 and y2 and its error with the analytical solution;

[0044] Fig.17 is the numerical solution of y3 and y4 and its error with the analytical solution;

[0045] Fig.18 It is a schematic diagram of the three-dimensional evolution trajectory of the Lorenz system;

[0046] Fig.19 It is a schematic diagram of the pipeline model;

[0047] Fig. 20 It is a schematic diagram of the pressure at the left and right ends of the pipeline of the pipeline model;

[0048] Fig.21 It is a schematic diagram for comparing the calculation of the present invention with that of Simulink under pipeline model and pressure boundary conditions. DETAILED DESCRIPTION

[0049] The present invention is further described in detail below in conjunction with the embodiments, which are intended to explain the present invention rather than to limit it.

[0050] To achieve an efficient and stable solver in simulation, we focus on three aspects:

[0051] First, we need to choose a suitable calculation method, which should have good stability, otherwise it will not be easy to converge; at the same time, we must also take into account the accuracy of the numerical solution, and the order of the selected numerical algorithm should not be too low;

[0052] Secondly, we must fully consider whether the selected algorithm is suitable for typical stiffness problems, including but not limited to: stiffness oscillation problems, nonlinear delay differential problems, stiffness problems with discrete events, etc. These typical problems are widely present in dynamic system simulation;

[0053] Finally, in the process of implementing the algorithm, the code's running efficiency should be improved as much as possible, otherwise it will have no engineering significance.

[0054] To this end, the present invention proposes the following methods and strategies to solve the problem.

[0055] 1. Develop ODE solvers based on linear multi-step method and Runge-Kutta method

[0056] Based on the theories of linear multi-step method and Runge-Kutta method, this solver selects four numerical algorithms with good stability and satisfactory accuracy, namely BDF, improved BDF and two 4th-order single diagonal implicit symplectic RK, as the underlying core processing methods. The proposed numerical integration solver suitable for initial value problems of stiff ordinary differential equations can solve ODE-IVP problems efficiently and stably, especially for stiff problems. This solver provides a variable step size mechanism for the above four solution methods, which can give full play to their advantages of large stability domain.

[0057] 2. A new method for solving the least squares problem of nonlinear equations

[0058] When applying implicit algorithms to solve initial value problems of ordinary differential equations, it is necessary to calculate the least squares problem of nonlinear equations. This solver combines the damped Newton method with the classic Levenberg-Marquardt optimization algorithm and proposes a damped-Levenberg-Marquardt optimization method, referred to as the d-LM method. This algorithm can take into account both operating efficiency and stability. Compared with similar calculation programs in foreign commercial tools such as MATLAB, this method is comparable in efficiency to foreign commercial tools.

[0059] 3. Optimal strategy for prediction step algorithm

[0060] The linear multi-step method is an implicit solution method. The most commonly used method for solving implicit equations is the "prediction-correction" method, which is also called the PC method. The general steps of the "prediction-correction" method are P(EC) m , where P represents prediction (Predictor), E represents the derivative value obtained from the prediction step, C represents correction (Corrector), and m represents multiple iterations.

[0061] In this solver, in order to ensure the convergence and solution efficiency of m implicit iterations, it is necessary to give a prediction result as close to the true solution as possible in the prediction step. This solver provides 5 calculation methods, and these 5 calculation methods are applied to obtain 5 groups of prediction results. Among them, the group closest to the true solution is selected as the input of the correction step. Although this processing method will lose some computational efficiency in the prediction step, it can provide a better initial value for the correction step, thereby reducing the number of iterations m. After comprehensive consideration and a large number of tests, it is found that this processing has a significant improvement in global efficiency.

[0062] 4. A new variable step-size strategy that can significantly improve the efficiency of integral solution

[0063] The traditional variable step-size solution strategy generally tries to solve the next step value y with h as the integration step size. (h), and then reduce the step size according to a given ratio (such as h / 2 or h / 3) and solve again to get the value y for the next step (h / 2) or (h / 3) . Then, by judging ||y (h) -y (h / 2) ||or||y (h) -y (h / 3) Is a certain norm of || less than the pre-given error ε? If so, the current step size is considered appropriate and the time axis moves forward; if not, the current time step is considered inappropriate and a new integral step size h needs to be recalculated according to a certain step size reduction strategy. new .

[0064] The present invention adds an additional judgment strategy on the basis of the above strategy, introduces the concepts of "step length adjustment" and "step length stability" in the variable step length process, and when several consecutive integral step lengths h and errors ε are kept within a pre-agreed range during the solution process, it is considered that the current model being solved has entered a "step length stability" state, in which there is no need to solve and adjust the above integral step length, and the previous integral step length can be directly used; otherwise, it is considered that the current model being solved has entered a "step length adjustment" state, and the solution is performed according to the traditional variable step length solution strategy. The biggest advantage of this processing method is that it greatly reduces the number of calculations while ensuring the accuracy of the calculation results, thereby improving the solution efficiency.

[0065] The simulation solution method of the present invention is described in detail below.

[0066] The numerical integration method for solving the initial value problem of the rigid ordinary differential equation in the simulation provided by the present invention is equivalent to solving the initial value problem of an N-dimensional ordinary differential equation in the real number domain, and its expression is:

[0067]

[0068] Where y is the differential variable, y' represents the derivative of y, t is the time, and t 0 and t end represents the start and end integration times, N is the dimension of the equation system (i.e., the dimension of y), and y 0 Indicates t 0 The value of y at that moment.

[0069] Based on the theories of linear multi-step method and Runge-Kutta method, this paper selects four numerical algorithms with good stability and satisfactory accuracy as the underlying core processing methods:

[0070] 1. Classical BDF (3rd to 5th order) method, also known as GEAR method;

[0071] 2. Improved BDF method, i.e. IBDF (3rd to 5th order) algorithm;

[0072] 3.3-level 4th-order single diagonal implicit symplectic Runge-Kutta method, namely SDISRK34 algorithm;

[0073] 4.4-level 4th-order single diagonal implicit symplectic Runge-Kutta method, i.e. SDISRK44 algorithm.

[0074] Based on the above method, a numerical integration solver suitable for initial value problems of stiff ordinary differential equations is constructed, which can solve ODE-IVP problems efficiently and stably, especially for stiff problems. A variable step size mechanism is provided for the above four solution methods, which can give full play to their advantages of large stability domain.

[0075] See also Figure 1-Figure 5 , the numerical integration solution method for the initial value problem of the stiff ordinary differential equation in the simulation includes the following operations:

[0076] Step 1: Select the necessary parameters such as the integral solution algorithm, initial integral step size, convergence residual, etc., and then proceed to step 2;

[0077] The integral solution algorithm is selected from the BDF algorithm, the IBDF algorithm, the SDISRK34 algorithm and the SDISRK44 algorithm;

[0078] Step 2: Make a judgment based on the selected solution algorithm:

[0079] If a multi-step method is used, determine whether the current solver uses the BDF method or the IBDF method (an improved BDF method). After the determination is completed, proceed to step 3;

[0080] If the single-step method is used, determine whether the current solver uses the SDISRK34 or SDISRK44 method. After the determination is completed, jump to step 5;

[0081] Step 3: According to the solution algorithm selected in the previous step, construct the target nonlinear equation group, and then proceed to step 4;

[0082] Step 4: Execute the optimization strategy of the prediction step results, use multiple prediction step algorithms to execute and obtain the predicted values ​​of multiple real solutions, substitute them into the target nonlinear equation group, and select a set of solution vectors with the smallest error as the solution vector of the prediction step; after completion, continue to step 5;

[0083] Step 5: Use the solution vector obtained in the prediction step as the initial value of the iteration and apply the d-LM method to solve the least squares solution of the target nonlinear equation system;

[0084] When solving, the iterative formula is first constructed, and the damping coefficient of the iterative step is introduced; then the iterative step is updated to determine whether the convergence requirement is met; if so, the result is output as the true solution vector, otherwise the iterative process is repeated to continuously obtain a new solution vector until the convergence error requirement is met;

[0085] Step 6: Execute variable step-size integration strategy: respectively execute the step-size optimization mechanism that provides the integration step size, the switching mechanism that determines the change of the integration step size, and the variable step-size numerical value back-interpolation mechanism that ensures the correct calculation results;

[0086] Determine whether the error meets the requirements; if so, proceed to step 7;

[0087] If not satisfied, return to step 1 and reset the integration step size according to the variable step size strategy.

[0088] Step 7: Move the time axis forward by one time step to determine whether the simulation needs to be ended;

[0089] If satisfied, proceed to step 8;

[0090] If not satisfied, return to step 1 and reset the integration step size according to the variable step size strategy.

[0091] Step 8: End the simulation calculation, store and display the calculation results.

[0092] A more specific description of the steps is given below.

[0093] A. In the second step of the above solution, this solver provides four solution algorithms, namely two linear multi-step methods and two single-step high-precision methods, which are named "Method A" to "Method D" respectively.

[0094] Method A (3-5th order traditional BDF):

[0095]

[0096] Method B (3rd to 5th order improved BDF):

[0097]

[0098] Method C (3rd level 4th order single diagonal implicit symplectic Runge-Kutta):

[0099]

[0100] The coefficients of the 3rd-order 4th-order single diagonal implicit symplectic RK method are generally given in the form of a Butcher matrix, such as Figure 6 shown.

[0101] Method D (4th-level 4th-order single diagonal implicit symplectic Runge-Kutta):

[0102]

[0103] The expression of the 4th-order 4th-order single diagonal implicit symplectic RK method is the same as that of method C, and the only difference is the coefficients of the Butcher matrix. The Butcher matrix of the 4th-order 4th-order single diagonal implicit symplectic RK method is as follows: Figure 7 shown.

[0104] For general equations, you can use "Method A" or "Method B". The solution process of these two methods requires less calculation and has higher solution efficiency.

[0105] For some rigid oscillation, random, discrete-continuous mixed or complex nonlinear problems, you can try using "Method C" or "Method D". The solution process of these two methods is computationally intensive and the solution efficiency is relatively low, but the advantage is that they have good numerical stability ("Method C" and "Method D" are A-stable, "Method A" or "Method B" are A(ɑ)-stable). At the same time, these two methods both belong to the "Symplectic Schemes". Compared with "Method A" and "Method B", they have smaller numerical dissipation and therefore better numerical fidelity.

[0106] B. Construction of the target nonlinear equation system

[0107] The four solution algorithms provided by the present invention are all implicit solutions, so they all need to construct a target nonlinear equation group.

[0108] The target nonlinear equations of method A are expressed as:

[0109]

[0110] The target nonlinear equations of method B are expressed as:

[0111]

[0112] In the above nonlinear equations, y n+k is the unknown number to be solved, and the rest are known data. n+k ) is the target nonlinear equation set.

[0113] The target nonlinear equations of methods C and D are solved by the coefficients of the implicit RK, which are expressed as follows:

[0114]

[0115] In the above nonlinear equations, K i is the unknown number to be solved, and the rest are known data. i ) is the target nonlinear equation set.

[0116] C. Optimal strategy for predicting step results

[0117] Prediction step calculation is used in Method A and Method B. In the prediction step, the solver provides 5 algorithms for estimating the true solution:

[0118] 1. Use the explicit Euler method as the prediction step to obtain the predicted value x of the true solution 1 ;

[0119] 2. Display the 2nd-order Runge-Kutta method as the prediction step and get the predicted value x of the true solution 2 ;

[0120] 3. Display the 3rd order Runge-Kutta method as the prediction step and get the predicted value x of the true solution 3 ;

[0121] 4. Display the 4th-order Runge-Kutta method as the prediction step and get the predicted value x of the true solution 4 ;

[0122] 5. Use the result of the previous step as the prediction step to get the predicted value x of the true solution 5 .

[0123] Substitute the above five solution vectors into the "target nonlinear equation group" and select a set of solution vectors x with the smallest error. pre As input to the "correction step".

[0124]

[0125] D. Apply the d-LM method to solve the target nonlinear equations

[0126] The solution vector x obtained in the prediction step pre As the initial value of the iteration, the d-LM method is applied to solve the least squares solution of the "target nonlinear equation group", and the final result is the true solution vector.

[0127] The solution process of the d-LM method is:

[0128] 1) Introduce the target nonlinear equations and construct an iterative formula based on the Levenberg-Marquardt method

[0129] (J T J+ηI)h LM =-J T F,g=J T F,η≥0 (10)

[0130]

[0131]

[0132]

[0133] Where F is the target nonlinear equation group to be solved, J is the Jacobian matrix of the target nonlinear equation group F, and J T is the transposed matrix of J, η is the adjustment coefficient between the gradient descent method (first-order optimization algorithm) and the Newton iteration method (second-order optimization algorithm), I is the unit matrix, ρ is the trust region radius, and h LM is the convergence step size for each iteration, and v is a process variable used to calculate the trust region radius.

[0134] 2) Calculate the damping coefficient

[0135] The most prominent advantage of Newton's method is its fast convergence speed and local second-order convergence. However, the initial point of the basic Newton method needs to be close enough to the minimum point, otherwise the algorithm may not converge. In order to ensure the stability of the calculation process, the damping coefficient of the iterative step is introduced by referring to the damped Newton method.

[0136]

[0137] Where λ is the iterative step damping coefficient to be solved, h LM is the convergence step size of each iteration, and x is the solution vector at the current moment.

[0138] 3) Update the iteration step size to determine whether the convergence requirements are met. If so, output the result. Otherwise, continue to repeat the iteration process to continuously obtain a new solution vector x new , until the convergence error requirement is met.

[0139] h LM =(J T J+ηI) -1 (-J T F) (15)

[0140] x new =x+λh LM (16)

[0141] E. Variable step-size integration strategy (see Figure 8 )

[0142] The four AD solution methods given in the present invention all allow the use of a variable step-size integration strategy, which can significantly improve the efficiency of integral solution; the variable step-size integration strategy mainly has the following three mechanisms:

[0143] The first is the optimization mechanism of the integral step size; in this mechanism, the step size decreases exponentially:

[0144]

[0145]

[0146] where dt new is the updated integration step, dt is the current integration step, error is the current calculation error, ε is the allowable error given in advance, y p is the solution vector obtained by the p-order p-step method, z p+1 is the solution vector obtained by the p+1-order p+1-step method;

[0147] Calculate y p and z p+1 , when error≤1.0, it indicates that the calculation result meets the given allowable error ε requirement, the current calculation result can be accepted, and the current integration step ends;

[0148] The second is the judgment and switching mechanism between the two states of "step length adjustment" and "step length stability"

[0149] In theory, each integration step should be given an initial integration step, and then an appropriate integration step is obtained by iterating through formulas (17) and (18). Such a compensation adjustment mechanism is the "step adjustment" state. If each integration step is calculated according to this mechanism, the calculation result must be correct, but the solution efficiency must be very slow. In order to further improve the solution efficiency, a "step stability" state is proposed here.

[0150] When several consecutive integration steps (this solver considers 5 consecutive steps) are calculated according to the "step adjustment" state, the next time step can be calculated directly using the average value of the previous integration steps without iteration. However, formula (18) needs to be used for monitoring at this time. If the condition of 0.75≤error≤1 is met at this time, the current integration step is directly considered to have completed the calculation and the time axis can be directly moved forward.

[0151] The third is the variable step-size numerical back-interpolation mechanism, which is only activated and effective in the multi-step method and does not need to be executed in the single-step method. When solving with a variable step-size, since each integral step is different, the two linear multi-step methods (methods A and B) provided by this solver require the integral step sizes of the first few steps to be the same, otherwise it will cause numerical divergence, so the numerical back-interpolation method is introduced here, where Interp_1D is a one-dimensional interpolation function:

[0152]

[0153] The beneficial effects of the above three mechanisms on the solver are:

[0154] The step size optimization mechanism provides the solver with an appropriate integration step size, which is neither too large to cause distorted results nor too small to increase the number of calculations and thus slow down the overall solution efficiency.

[0155] The judgment and switching mechanism between the step size adjustment and step size stabilization states can reasonably judge whether the integration step size needs to be changed. If it is not necessary, the integration step size will not be adjusted as much as possible, which saves the extra calculation caused by the step size adjustment and further improves the solution efficiency.

[0156] The variable step-size numerical back-interpolation mechanism ensures the correctness of the calculation results in the linear multi-step method and avoids the distortion of the results caused by the change of step size.

[0157] The above three mechanisms jointly support the variable step-size integration strategy, and none of them can be missing.

[0158] Specifically, the solver of the present invention uses C++ as the development language, relies on the open source linear algebra computing package Eigen (V3.3.9), and the compiler uses the Intel Math Kernel Library (MKL) for optimization and acceleration. Its basic code organization structure is as follows: Fig. 9 shown.

[0159] Specific examples are given below.

[0160] Example 1: Efficiency comparison between the d-LM method and the fsolve command

[0161] BDF and IBDF in this solver are two very efficient solving methods. Solving nonlinear equations is an indispensable and important part of the problem. This solver innovatively proposes the d-LM method. In order to verify its solving efficiency, MATLAB is selected as the control verification benchmark to compare the differences between the d-LM method developed based on C++ given by this solver and the fsolve command in MATLAB for solving nonlinear equations.

[0162] This example selects the following nonlinear equation group as the test object.

[0163]

[0164] The initial value of the solution vector of the above equation is [0,0,0]. The d-LM of this solver and fsolve of MATLAB are used to solve the equation. The calculation results are as follows: Fig.10 and Fig.11 shown.

[0165] According to the above calculation results, we can see that the same solution is obtained for the same mathematical model, namely x=[10.0449,4.9796,-0.0653], and the correctness is verified.

[0166] In addition, it can be seen that fsolve in MATLAB requires 9 iterations to achieve a solution accuracy of 1e-12 for the equation group, while the d-LM method provided by this solver only requires 7 steps to achieve a solution accuracy of 1e-12. Fewer iterations means the possibility of higher efficiency.

[0167] Fig.12 The figure shows the time consumption statistics of the d-LM method and fsolve of the present invention when the solution calculation is repeated 20 times. It can be seen from the calculation results that the d-LM method and fsolve are at the same level, but the efficiency of the fsolve command is low at the beginning of the calculation, and the efficiency will be improved after repeated calculations.

[0168] Example 2: Typical rigidity problem example

[0169] In chemical reactions, we often encounter the following type of reaction rate equation, where y 1 ,y 2 ,y 3 represents the concentration of the reactant. This model is a typical rigid problem and is often used in simulation verification of various numerical solution methods.

[0170]

[0171] Using MATLAB / simulink commercial tools to solve the above ordinary differential equation, we can get Fig.13 Using this as a comparison benchmark, the 4-step 4-order improved BDF algorithm in this solver is used to solve the above ordinary differential equation, and the obtained result is subtracted from the simulink result to obtain the following Fig.14 From the error curve shown, it can be seen that the two are very consistent.

[0172] The variable step size convergence error in the current example is 1e-5, so the error of the solution is basically around this order of magnitude. If you want to get a more accurate solution, you need to further tighten the variable step size convergence error, but this will definitely affect the efficiency of the calculation. Computational efficiency and accuracy are a contradiction in the solution process and need to be considered comprehensively.

[0173] In addition to comparing the accuracy, the present invention also compares the efficiency differences of different solution methods. Fig.15 The figure shows the comparison between the solving efficiency of mainstream foreign commercial tools and the calculation time of this solver.

[0174] It can be seen that the computation time of Simulink and SimulationX is distributed between 0.4 and 2.0 seconds, and the computation time of the BDF method of this solver is mainly distributed between 0.7 and 1.0 seconds. In general, the computational efficiency of this solver is basically equivalent to that of mainstream commercial tools abroad. Among them, the SDISRK method is essentially an implicit Runge-Kutta method. Due to the large amount of computation of its own algorithm, it also leads to a long computation time.

[0175] Example 3: Typical Hamiltonian system oscillation problem

[0176] The Hamilton system is a typical dynamic system and is widely used in fields such as celestial body motion and mechanism movement to describe the system dynamics process.

[0177] The Kepler equation is a typical Hamiltonian system, and its expression is:

[0178]

[0179] Its Hamilton function is:

[0180]

[0181] When the initial value of the integral is y 1 (0)=0,y 2 (0)=1,y 3 (0)=1,y 4 When (0) = 0, the mathematical expression of its analytical solution is:

[0182] y 1 = -sin(t),y 2 =cos(t),y 3 =cos(t),y 4 = sin(t)

[0183] The solver is used to numerically integrate and solve the oscillation equations described by equations (22) and (23), and the results are as follows: Fig.16 and Fig.17 shown.

[0184] It can be seen that the numerical solution and the theoretical analytical solution are in good agreement, with an error of 1e-5, which is related to the pre-settings of the solver. However, a more accurate numerical solution requires more computational time.

[0185] Example 4: Lorenz Chaotic System

[0186] The Lorenz system is a typical chaotic system with a relatively complex dynamic process. It is a typical means of testing the correctness of differential equation solution algorithms. The expression of its differential equation is:

[0187]

[0188] The above Lorenz chaotic system is numerically solved using this solver, and the results are plotted as three-dimensional evolution trajectories for comparison with the MATLAB / simulink calculation results. Fig.18 , it can be seen that the chaotic attractors reflected by the calculation results of the two are completely consistent, which can prove the correctness of this solver.

[0189] Example 5: RCR one-dimensional fluid pipeline system

[0190] In multidisciplinary system simulation, the flow resistance (R) and flow capacity (C) are mainly considered in the pipeline model. The flow resistance mainly reflects the resistance of the pipeline, and the flow capacity mainly reflects the compressibility of the pipeline. When the pipeline is long, it can be processed in sections, and the corresponding model can be expressed as RCR-···-CR.

[0191] For a simple circular pipe with equal cross-section, it can be simply equivalent to the RCR model (such as Fig.19 Its dynamic model is:

[0192]

[0193] Where P in,out is the pipeline inlet and outlet pressure, is the pipeline mass flow rate, R is the pipeline flow resistance, ρ is the fluid medium density, η is the flow coefficient, A is the pipeline inner diameter, V is the pipeline internal volume, and a is the fluid medium sound velocity. When calculating, take the medium density ρ = 1000kg / m 3 , pipeline length 12.73m, pipeline inner diameter 10mm, medium sound velocity a=1400m / s.

[0194] The calculated pressures at the left and right ends of the pipeline are as follows: Fig. 20 As shown in the figure, under the same pipeline model and pressure boundary conditions, this solver and simulink are used to calculate and compare the calculation results of the two, as shown in the figure. Fig.21 As shown in Figure 2, it can be seen that the calculation results of this solver are completely consistent with those of Simulink.

[0195] The above embodiments are preferred examples for implementing the present invention, and the present invention is not limited to the above embodiments. Any non-essential additions and substitutions made by those skilled in the art based on the technical features of the technical solution of the present invention shall fall within the protection scope of the present invention.

Claims

1. A numerical integration method for solving the initial value problem of a rigid ordinary differential equation in simulation, characterized in that: The following operations are included: 1) For the simulation problems to be solved, including chemical reaction rate equations and fluid pipeline models, select necessary parameters including integral solution algorithm, initial integral step size, and convergence residual; The integral solution algorithm is selected from the BDF algorithm, the IBDF algorithm, the SDISRK34 algorithm and the SDISRK44 algorithm; 2) Make a judgment based on the selected solution algorithm: if a multi-step method is used, then determine whether the current solver uses the BDF or IBDF method. After the judgment is completed, continue to execute 3); If the single-step method is used, then determine whether the current solver uses the SDISRK34 algorithm or the SDISRK44 algorithm. After the determination is completed, jump to execution 5); 3) Construct the target nonlinear equations according to the selected solution algorithm; 4) Using multiple prediction step algorithms to execute multiple predicted values ​​of real solutions, respectively substitute them into the target nonlinear equation group, and select a set of solution vectors with the smallest error as the solution vector of the prediction step; 5) The solution vector obtained in the prediction step is used as the initial value of the iteration to solve the least squares solution of the target nonlinear equation system; When solving the problem, the iterative formula is first constructed, and the damping coefficient of the iterative step is introduced; Then the iteration step size is updated to determine whether the convergence requirement is met; if so, the result is output as the true solution vector, otherwise, the iteration process is repeated to continuously obtain a new solution vector until the convergence error requirement is met; 6) Execute variable step-size integration strategy: respectively execute the step-size optimization mechanism for providing the integration step size, the switching mechanism for judging and changing the integration step size, and the variable step-size numerical back-interpolation mechanism for ensuring the correctness of the calculation results; After the variable step-size integration strategy is executed, determine whether the error meets the requirements; if so, execute 7); If not satisfied, return to 1) and reset the integration step size according to the variable step size strategy; 7) The time axis moves forward one time step to determine whether the simulation needs to be ended; If satisfied, execute 8); if not satisfied, return to 1) and reset the integral step size according to the variable step size strategy; 8) End the simulation calculation, store and display the calculation results; Among them, the target nonlinear equation group is constructed as follows: The target nonlinear equations of the BDF algorithm are expressed as: The target nonlinear equations of the IBDF algorithm are expressed as: In the above nonlinear equations, y n+k is the unknown number to be solved, and the rest are known data. n+k ) is the target nonlinear equation system; The target nonlinear equations of the SDISRK34 and SDISRK44 algorithms are solved by the coefficients of the implicit RK, which are expressed as follows: Among them, K i is the unknown number to be solved, and the rest are known data. i ) is the target nonlinear equation system; The least squares solution to the target nonlinear system of equations is obtained using the following operation: 501) The target nonlinear equations are introduced and the iterative formula is constructed based on the Levenberg-Marquardt method: (J T J+ηI)h LM =-J T F,g=J T F,η≥0 If ρ>0 If η=η*max{1 / 3,1-(2ρ-1) 3 };n=2 otherwise η=η*ν;ν=2*ν Where F is the target nonlinear equation group to be solved, J is the Jacobian matrix of the target nonlinear equation group F, and J T is the transposed matrix of J, η is the adjustment coefficient between the gradient descent method and the Newton iteration method, I is the unit matrix, ρ is the trust region radius, and h LM is the convergence step size of each iteration step, v is a process variable used to calculate the trust region radius; 502) Introduce the iterative step damping coefficient: Among them, λ is the iterative step damping coefficient to be solved, h LM is the convergence step length of each iteration step, and x is the solution vector at the current moment; 503) Update the iteration step size and repeat the iteration process to continuously obtain a new solution vector x new , until the convergence error requirement is met, and the result is output: h LM =(J T J+ηI) -1 (-J T F) x new =x+λh LM ; The execution of each mechanism in the variable step size integration strategy is: 601) Optimization mechanism, the step size decreases exponentially: where dt new is the updated integration step, dt is the current integration step, error is the current calculation error, ε is the allowable error given in advance, y p is the solution vector obtained by the p-order p-step method, z p+1 is the solution vector obtained by the p+1-order p+1-step method; If error≤1.0, it means that the calculation result meets the given allowable error ε requirement, the current calculation result can be accepted, and the current integration step ends; If error>1.0, it means that the current calculation result does not meet the given allowable error requirements, and a new dt should be recalculated. new ; 602) The switching mechanism for judging and changing the integral step length is a mechanism for judging and switching between the two states of step length adjustment and step length stabilization: The step size adjustment state is: an initial integration step size is given at each integration step size, and then an integration step size is obtained by iterating through equations (17) and (18); The step size stable state is: when several consecutive integration steps are calculated according to the step size adjustment state, the next time step does not need to be iterated but is directly calculated using the average value of the previous integration steps, and is monitored using formula (18); if the condition of 0.75≤error≤1 is met during monitoring, the current integration step is directly considered to have completed the calculation, and the time axis directly moves forward; 603) Variable step value back-interpolation mechanism: This mechanism is only activated in the multi-step method, and a numerical back-interpolation method is introduced, where Interp_1D is a one-dimensional interpolation function:

2. The method for numerical integration of initial value problems of rigid ordinary differential equations in simulation according to claim 1, characterized in that: When selecting the integral solution algorithm, the SDISRK34 algorithm or SDISRK44 algorithm is used for rigid oscillation, random, discrete-continuous mixed or complex nonlinear problems; the BDF algorithm or IBDF algorithm is used for the remaining equations.

3. The method for numerical integration of initial value problems of rigid ordinary differential equations in simulation according to claim 1, characterized in that: The prediction step algorithm is used to estimate the true solution through the following algorithm: 401) The explicit Euler method is used as the prediction step to obtain the predicted value x1 of the true solution; 402) shows that the second-order Runge-Kutta method is used as the prediction step to obtain the predicted value x2 of the true solution; 403) shows that the third-order Runge-Kutta method is used as the prediction step to obtain the predicted value x3 of the true solution; 404) shows that the 4th order Runge-Kutta method is used as the prediction step, and the predicted value x4 of the true solution is obtained; 405) Use the result of the previous step as the prediction step to obtain the predicted value x5 of the true solution; Substitute the above five solution vectors into the target nonlinear equations and select a set of solution vectors x with the smallest error. pre As input to the calibration step: