Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

MultiBody in OMNotebook?

MultiBody in OMNotebook?

Hello,

Is it possible to use Modelica.Mechanics.MultiBody in OMNotebook?
I'm running my model using OMEdit now, but I want to run it with a range of parameter values overnight, without having to click on simulate for every simulation.

Kind regards,

Pieter

Edited by: PietervD - Jan-10-12 13:24:32

Re: MultiBody in OMNotebook?

Yes, you can do that. It might be better to run OpenModelica script-files from command-line:

Code:

omc a.mos

You can also run the same script from OMShell/OMNotebook:

Code:

cd("/path/to/workingDir/");

runScript("a.mos");

The advantage of running the script from command-line is that you get incremental progress. You can see how far OMC has gotten in the script, while OMNotebook/OMShell block the GUI until all commands have finished.

a.mos:

Code:

loadModel(Modelica);getErrorString();

simulate(Modelica.Mechanics...);getErrorString();
...

Re: MultiBody in OMNotebook?

Thanks for your reply. I've tried simulating a very simple model, to see if I understand you correctly.

I've created an a.onb file with the following contents:

Code:


cd("c:/OpenModelica1.7.0/work/");
runScript("a.mos");

a.mos contains:

Code:


loadModel(pendulum.mo);getErrorString();
simulate(pendulum, stopTime = 3);getErrorString();

and pendulum.mo contains a model for a simple pendulum, which runs fine in OMEdit:

Code:


model pendulum
  inner Modelica.Mechanics.MultiBody.World world;
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(useAxisFlange = false, n = {0,0,1});
  Modelica.Mechanics.MultiBody.Parts.BodyBox element1(r_0(start = {0,0,0}, fixed = true), r = {1,0,0}, width = 0.1);
equation
  connect(world.frame_b,  revolute1.frame_a);
  connect(revolute1.frame_b,  element1.frame_a);
end pendulum;

All files are in the c:/OpenModelica1.7.0/work/ folder.

Unfortunately, the output in OMNotebook simply says [done], but nothing seems to happen.
I'm probably making some simple mistake, since I really have no experience with this kind of programming.

Regards,

Pieter

Re: MultiBody in OMNotebook?

Oh, my bad. I keep forgetting a semicolon in OMNotebook/OMShell supresses the output. So remove the last ; after runScript and it should print the output.

Re: MultiBody in OMNotebook?

Removing the last semicolon will print the output for sure but there are some more problems with your script. Like,

- You should add loadModel(Modelica) as the first command in your script file. Since you are using Modelica Standard Library models.
- Change loadModel(pendulum.mo) to loadFile("pendulum.mo").

Adeel.

Re: MultiBody in OMNotebook?

That almost did the trick, I got an error that the class ModelicaServices.Animation.Shape was not found, so I also had to load ModelicaServices.
Now it works fine. Thank you both a lot!

Re: MultiBody in OMNotebook?

More recent OpenModelica versions automatically load ModelicaServices when Modelica is loaded current/wink

There are 0 guests and 0 other users also viewing this topic