Modelica - 指定模拟默认参数

发布于 2024-10-16 21:01:26 字数 740 浏览 5 评论 0原文

我知道我可以更改 File_init.txt 的定义,但我想知道是否有某种方法可以在类文件(.mo)或编译器(omc)的指令中执行此操作。

试图缓解 Modelica 中缺乏“has-a”关系的问题< /a>,我正在编写一个 Perl 包装器,用于编写最高级别的 Modelica 模拟(我的 has-a 变成了 ifwhen< /code> 语句)并编译(omc +s 然后 make)和模拟。如果我可以以其他方式指定 stopstepoutputFormat 等参数,而不必打开 init 文件,那么这将完美地工作并对它们进行正则表达式替换,这确实很笨拙。

长话短说,是否有像下面的(伪代码)示例这样的指令?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感情废物 2024-10-23 21:01:26

几乎乔尔,正确的方法是:

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 :)).

憧憬巴黎街头的黎明 2024-10-23 21:01:26

我不知道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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文