How does Simulink simulation engine work?

▼魔方 西西 提交于 2020-01-14 07:39:09

问题


I would like to understand how Simulink simulation engine works. Does it use a discrete event simulation mecanism (then how continous time is handled ?) ? Does it rely on a static cycle-based code generation ? Or ?


回答1:


Before the first cycle, it figures out the order of execution of the blocks (starting with the ones that don't require inputs from any other blocks)

Each cycle, it calculates the output of each block based on the inputs and the block's code. Each block's code is static, it mostly existed before you put the model together. (I don't know if block options actually change the code, or if they are evaluated only at runtime, at each iteration.)

If the simulation step is variable, than each cycle it calculates the size of the next step, based mainly on how fast the model's variables are changing. The faster they change, the smaller the step size should be, so a briefly high derivative isn't assumed to last much longer than it should. (I don't know the details of this calculation, perhaps someone else can shed a light?) So, "continuous" simulation, or variable-step, only means Simulink will make an educated guess each cycle about what step size is small enough to keep time quantization error at an acceptable level. Truly continuous simulation is literally impossible over a completely digital hardware, such as your computer's processor.




回答2:


I'm certainly not an expert, but the answer is likely to be 'it depends'.

Simulink certainly uses numerical integration for some things, and for some integrators you will end up with discrete time steps. For other integrators, the time-step can be altered as the simulation is running - this is particularly important for simulating 'stiff' sets of equations.



来源:https://stackoverflow.com/questions/3884948/how-does-simulink-simulation-engine-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!