3

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;

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

This seems to be correct. I am having some problems making this work with omc, however that may be a problem with omc (which is still in development), rather than the Spec. Thanks
3

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.

1 Comment

So you would do something like model Model annotation( experiment( stop=6.28 ) ); ... end Model; where Model is your top-level model?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.