协同仿真的Simulink:逐步执行和与外部应用参数交换 [英] Co-Simulation with Simulink: stepwise execution and interchange of parameters with external application

查看:250
本文介绍了协同仿真的Simulink:逐步执行和与外部应用参数交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现的Simulink耦合模拟和外部应用程序(LS-DYNA)。领先的仿真在Simulink中,在这里我想实现一个功能块如下进行:

I have to realise a coupled simulation with Simulink and an external application (LS-DYNA). The leading simulation is done in Simulink, where I want to implement a function block as following:

交互使用Windows的CMD完成,因此Simulink模块应做到以下几点:

The interaction is done using the cmd of windows, so the Simulink block should do the following:

function [ x,y ] = ExternalSimlation( u,v )

% open the windows cmd and run the external simulation by passing u and v
[status,cmdout] = system( 'command for executing the external simulation -u -v');

    function [ x,y ] = readcmd( cmdout )
        %algorithm to evaluate the cmd output
    end

    [x,y] = readcmd(cmdout);

end

确切code不应该与此有关。我的问题是,我怎么能实现该接口到Simulink模型?我可以使用自定义功能模块之一,用我的code以上,这是否行得通呢?但哪一个,我实在看不出区别。

The exact code should NOT be relevant here. My question is, how can I implement the interface into the simulink model? Can I just use one of the custom function blocks, use my code above, and it will work? But which one, I don't really see the difference.

OR,我的另一个想法是建立类似以下内容:

OR, my other idea was to build something like the following:

,然后使用whil​​e循环是这样的:

And then use a while-loop like this:

while ... do
[u,v] = sim('model', 'x',x,'y', y, 'some option just to run a single step');
[x,y] = ExternalSimlation( u,v )
[u,v] = sim('model' .... next step ...)

执行SIMULINK模拟一步一步。我如何才能实现呢? (模拟的其余部分包含复杂的控制算法,推导和集成)

to execute the simulink simulations step-by-step. How can I realise that? (The rest of the simulation contains complex control algorithms, derivations and integrations)

我没有书面的批处理文件的经验,但对我来说似乎是可能的。

I don't have experiences in writing batch files, but that seems possible for me as well.

如果你想知道为什么我不只是测试的东西出来,那是因为我没有可用的外部应用程序(我只知道怎么输入和输出的作品),并且不希望在编写一个浪费时间替代应用程序只是用于测试,如果这是不可能的。

If you wonder why I'm not just testing things out, it's because I don't have the external application available (I just know how the in- and output works) and don't want to waste time in coding a substitutional application just for testing, if it's not possible at all.

在加上模拟使用Simulink任何提示和经验的高度AP preciated!
谢谢!

Any hints and experiences in coupled simulations with simulink are highly appreciated! Thank you!

推荐答案

据我所知道的正确的方式耦合SIMULINK到其他应用程序是写
S-功能。如果外部应用程序有一个C / C ++接口,这也应该是迄今为止最好的解决办法的性能代价:
http://www.mathworks.de/de/help /simulink/create-cc-s-functions.html

As far as I know the "proper" way to couple simulink to other applications would be to write S-Functions. If the external application has a C/C++ interface this should also by far be the best solution performance-wise: http://www.mathworks.de/de/help/simulink/create-cc-s-functions.html

这篇关于协同仿真的Simulink:逐步执行和与外部应用参数交换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆