Main Content

实时模拟Workflow

The figure shows the real-time simulation workflow. The connectors are exit points for returning to the real-time model preparation workflow.

The figure shows the real-time model preparation workflow. The connector is an entry point for returning to the real-time model preparation workflow from other real-time workflows (for example, the real-time simulation workflow or the hardware-in-the-loop simulation workflow).

Before performing this workflow, prepare your model for real-time simulation using the实时模型准备工作流程. The real-time model preparation workflow shows you how to obtain reference results, determine the maximum step size, and modify your model to simulate quickly and produce accurate results.

使用实时仿真工作流程,以增加模型实时功能的可能性。如果您在实时计算机上模拟这两个标准时,您的模型就可以实时符合这两个标准:

  • 基于经验数据或理论模型,结果与您的期望相匹配。

  • The model simulates without incurring an overrun.

实时仿真工作流使用有限的,即固定步骤,固定成本,模拟。固定步骤,固定成本模拟通过限制求解器使用的步长和迭代次数,从而在计算成本上设置上边界。

Make Your Model Real-Time Viable

Perform Fixed-Step, Fixed-Cost Simulation

使用固定步骤的全局求解器和本地求解器的固定固定成本配置在台式计算机上运行模型。有关用于实时仿真的固定步骤,固定成本求解器配置的更多信息,请参见Choose Step Size and Number of IterationsFixed-Cost Simulation for Real-Time Viability.

Evaluate Model Accuracy

将目标计算机上的仿真结果与您的参考结果进行比较。参考和修改模型结果是否相同?如果没有,它们是否足够相似,以至于经验或理论数据还支持修改模型的模拟结果?万博1manbetx修改模型代表您想要测量的现象吗?它是否正确地代表了这些现象?如果您打算使用模型测试控制器设计,那么模型是否足够准确,可以产生您可以依靠系统资格的结果?这些问题的答案可以帮助您确定您的实时结果是否足够准确。

Improve Accuracy by Adjusting Solver Settings

If your fixed-step, fixed-cost simulation results do not match your reference results, try to improve accuracy by adjusting solver configurations. Increasing the number of iterations or decreasing the step size can improve accuracy.

For an implicit global solver (ode14x, ode1be), increase the number of Newton’s iterations. For a Backward Euler or Trapezoidal Rule local solver, increase the number of nonlinear iterations.

对于全球求解器和任何本地求解器,都会降低步长大小。将每个本地求解器的步长配置为您为全局求解器指定的步长的整数倍数。

Return to the Real-Time Model Preparation Workflow

如果更改求解器配置不能改进或速度足够速度,请尝试通过返回实时模型准备工作流程来实现模型实时。

Adjust the fidelity or scope of your model, and then step through the other processes and decisions in the real-time model preparation workflow. Iterate on adjusting, simulating, and analyzing your model until it is fast and accurate enough for you to attempt the real-time simulation workflow again. For information, see实时模型准备工作流程.

评估超支风险

在速度方面,唯一确定模型能够实时的方法是在目标硬件模拟过程中测试超支。但是,您可以使用固定步骤的固定成本仿真来估计求解器足够快地执行以实时模拟的可能性。有关估计模拟时间的信息,请参阅Estimate Computation Costs.

Improve Simulation Speed by Adjusting Solver Settings

If your computational cost estimate indicates that your model executes too slowly to avoid an overrun on a real-time target machine, try to increase simulation speed by adjusting solver configurations. Decreasing the number of iterations or increasing the step size can improve accuracy.

隐式全局解算器(ode14x ode1be),德crease the number of Newton’s iterations. For either a Backward Euler or Trapezoidal Rule local solver, decrease the number of nonlinear iterations.

For the global solver, and for any local solvers, increase the step size. Configure the step size for each local solver as an integer multiple of the step size you specify for the global solver.

模型是实时可行的

When fixed-step, fixed-cost simulation results indicate that your model is likely real-time capable, you can attempt real-time simulation on the target hardware. For information on how you can use real-time simulation to test your controller hardware, seeBasics of Hardware-In-The-Loop simulation.

返回实时仿真工作流程

The connector is an entry point for returning to the real-time simulation workflow from another workflow (for example, the hardware-in-the-loop simulation workflow).

实时生存能力的计算能力不足

您的实时目标机可能缺乏实时运行模型的计算能力。如果在工作流程进行多次迭代后,模型复杂性和求解器设置没有使您的模型实时可行的组合,请考虑这些选择以增加处理能力:

Related Examples

More About