主要内容

Choose a Solver

To simulate a dynamic system, you compute its states at successive time steps over a specified time span. This computation uses information provided by a model of the system.时间步骤是计算发生时的时间间隔。这个时间间隔的大小称为step size。以这种方式计算模型状态的过程称为解决该模型。没有单一的解决模型的方法适用于所有系统。金宝appSimulink®提供一组名为的程序solvers。Each solver embodies a particular approach to solving a model.

A solver applies a numerical method to solve the set of ordinary differential equations that represent the model. Through this computation, it determines the time of the next simulation step. In the process of solving this initial value problem, the solver also satisfies the accuracy requirements that you specify.

Mathematicians have developed a wide variety of numerical integration techniques for solving the ordinary differential equations (ODEs) that represent the continuous states of dynamic systems. An extensive set of fixed-step and variable-step continuous solvers are provided, each of which implements a specific ODE solution method (see比较求解器)。在求解器pane of model configuration parameters.

All solvers provided by MATLAB®and Simulink follow a similar naming convention:,然后是两个或三个数字,指示求解器的顺序。一些求解器可以求解刚性的微分方程,它们使用的方法由s,t, ortbsuffixes.

求解器选择标准

The appropriate solver for simulating a model depends on these characteristics:

  • 系统动力学

  • 解决方案稳定性

  • 计算速度

  • 求解器鲁棒性

As such, the numerical solvers provided by Simulink can be broadly classified by two properties.

计算步骤尺寸类型

  • Fixed-step solvers, as the name suggests, solve the model using the same step size from the beginning to the end of the simulation. You can specify the step size or let the solver choose it. Generally, decreasing the step size increases the accuracy of the results and the time required to simulate the system.

  • 可变步骤求解器在模拟过程中改变步长。这些求解器降低了步骤大小以提高模型模拟过程中某些事件的准确性,例如快速状态变化,零交叉事件等。此外,它们会增加步骤大小,以避免在模型状态时采取不必要的步骤慢慢改变。计算步骤大小在每个步骤中添加到计算开销。但是,它可以减少步骤的总数,从而为具有零交叉,快速变化的状态以及其他需要额外计算的事件保持指定准确性所需的仿真时间。

Model States

  • 连续求解器使用数值集成在当前时间步长以前的时间步骤和状态导数时计算模型的连续状态。连续求解器依靠单个块来计算每个时间步骤的模型的离散状态值。

  • 离散的solvers are primarily used for solving purely discrete models. They compute only the next simulation time step for a model. When they perform this computation, they rely on each block in the model to update its individual discrete state. They do not compute continuous states.

使用一个迭代方法选择y的解决者our requirements. Compare simulation results from several solvers and select a solver that offers the best performance with minimal tradeoffs.

以这些方式为您的模型选择一个求解器:

  • 使用自动求解器。默认情况下,新型号将其求解器选择设置为自动求解器。自动求解器为您的型号推荐固定步骤或可变步骤求解器以及最大步长尺寸。有关更多信息,请参阅Select Solver Using Auto Solver

  • 如果您对使用自动求解器的仿真结果不满意,请在求解器模型配置参数中的窗格。

When you build and simulate a model, you can choose the solver based on the dynamics of your model. A variable-step solver is better suited for purely continuous models, like the dynamics of a mass spring damper system. A fixed-step solver is recommended for a model that contains several switches, like an inverter power system, due to the number of solver resets that would cause a variable-step solver to behave like a fixed-step solver.

Note

When you deploy a model as generated code, you can use only a fixed-step solver. If you select a variable-step solver during simulation, use it to calculate the step size required for the fixed-step solver that you need at deployment.

该图表提供了Simulink库中求解器的广泛分类。金宝app

要定制所选求解器到您的模型,请参阅Check and Improve Simulation Accuracy

理想情况下,您选择的求解器应:

  • Solve the model successfully.

  • 对于可变步骤求解器,请在您指定的公差极限内提供解决方案。

  • Solve the model in a reasonable duration.

单个求解器可能无法实现所有这些目标。在进行选择之前,请尝试使用不同的求解器模拟。

The Simulink library provides several solvers, all of which can work with the algebraic loop solver. For more information, see代数循环求解器的工作方式

在里面求解器pane of model configuration parameters, the Simulink library of solvers is divided into two major types. SeeFixed-Step Versus Variable-Step Solvers

有关比较求解器的其他方法,请参见:

Related Examples

More About