简体   繁体   English

Modelica - 指定模拟默认参数

[英]Modelica - Specify simulation default parameters

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). 我知道我可以更改File_init.txt的定义,但我想知道是否有某种方法可以在类文件(.mo)或指向编译器(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. 为了减轻我自己在Modelica中缺乏“has-a”关系的问题 ,我正在编写一个Perl包装器来编写我的Modelica模拟的最高级别(我的has-a转换为ifwhen语句)和编译( omc +s然后make )和模拟。 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. 如果我可以用其他方式指定诸如stopstepoutputFormat类的参数,而不是必须打开init文件并对它们执行正则笨重的regexp替换,这将完美地工作。

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;

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. 您还可以从Modelica标准库中获得“示例”模型(通常放在.Examples子包中)。 They all should have that annotation in place (and if not feel free to report it :)). 他们都应该有适当的注释(如果没有随意报告 :))。

I don't know how OMC handles this, but there are standard annotations for experiment parameters. 我不知道OMC如何处理这个,但是有实验参数的标准注释。 You can find the information in Section 17.7 of the specification (version 3.2). 您可以在规范的第17.7节(版本3.2)中找到相关信息。

Take a look at that and let me know if that addresses your question. 看一下,如果能解决您的问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM