Modelica - 指定模拟默认参数
我知道我可以更改 File_init.txt 的定义,但我想知道是否有某种方法可以在类文件(.mo)或编译器(omc)的指令中执行此操作。
长话短说,是否有像下面的(伪代码)示例这样的指令?
class MainSim
extends BaseSim;
...
simulation.stop = 1E-9;
simulation.step = 1E-12;
simulation.outputFormat = "csv";
...
equation
...
end MainSim;
I know I can change File_init.txt
's definitions, but I was wondering if there is some way to do it in the class file (.mo) or in a directive to the comiler (omc).
In an attempt to alleviate myself of the lack of a 'has-a' relationship in Modelica, I am writing a Perl wrapper that writes the highest level of my Modelica simulation (with my has-a
's turned into if
and when
statements) and the compiles (omc +s
then make
) and simulates. This would work perfectly if I could specify such parameters as stop
, step
, outputFormat
in some other way, rather than having to open the init file and do a regexp replace on them which is really clunky.
Long story short, is there some directive like the (pseudo-code) example below?
class MainSim
extends BaseSim;
...
simulation.stop = 1E-9;
simulation.step = 1E-12;
simulation.outputFormat = "csv";
...
equation
...
end MainSim;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几乎乔尔,正确的方法是:
model 模型注释(experiment(StopTime=6.28)); ... end Model;
您还可以使用 Modelica 标准库中的“示例”模型(通常放置在
.Examples
子包中)。他们都应该有该注释(如果没有,请随时报告:))。Almost Joel, the correct way would be:
model Model annotation( experiment( StopTime=6.28 ) ); ... end Model;
You can also have at "example" models (normally placed in a
.Examples
subpackage) from the Modelica Standard Library. They all should have that annotation in place (and if not feel free to report it :)).我不知道OMC如何处理这个问题,但是实验参数有标准注释。您可以在规范(版本 3.2)的第 17.7 节中找到信息。
看一下,如果这解决了您的问题,请告诉我。
I don't know how OMC handles this, but there are standard annotations for experiment parameters. You can find the information in Section 17.7 of the specification (version 3.2).
Take a look at that and let me know if that addresses your question.