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

OpenModelica Basics

OpenModelica Basics

Hello,

I am new to the Modelica Language and I recently started using OpenModelica (I'm using the OpenModelica 1.9.1+dev (r18473) (RML version)). I have gone through the examples present in the OpMod Connection Editor. I am having a difficult time in understanding how the systems are created (apart from the Pendulum problems). I have tried searching in the web for help but wasnt able to find any. The ones I found were mostly related on the coding part. Is there any documentation available on how to create systems, i.e the basics of creating systems/applying parameters/connecting the elements?

Also, can anyone tell me how to see the animations in the same version?

Re: OpenModelica Basics

Hi,

perhaps you could start with a tutorial by Peter Fritzson:
https://www.openmodelica.org/images/doc … itzson.pdf

For visualization follow the steps in: https://build.openmodelica.org/Document … ica3D.html
If you use OMEdit, simply add ModelicaServices of version "3.2.1 modelica3d" to the list of libraries to load on startup.

so long.
Willi

Re: OpenModelica Basics

Hi,

Thanks for suggesting the tutorial. I have already gone through it and it does not give a proper idea on how to create systems. What I mean to say is it tells how to create 2-3 systems. I need to understand how to create systems in a generic way.

About the animations part. I did not understand what the link said. (I work on a windows system). I have installed OpenModelica 1.9.1+dev (r18473) (RML version). A nightly build. It has only Connection editor, Notebook, Optimization Editor and the shell. Is that all that is required or should i install anything else as well?

Also, I could not find the dbus-server.py file. Where is it located. And what do you mean by a session?

Re: OpenModelica Basics

Read OpenModelica users guide. It is part of OpenModelica installation and is located at C:\OpenModelica1.9.1Nightly\share\doc\omc\OpenModelicaUsersGuide.pdf (assuming that you installed OpenModelica at the default location).

In particular read chapter 1 for general understanding and read chapter 11 for Modelica3D.

I checked the dbus-server.py and yes it is missing. It seems like something is wrong in the build. I will look into it.

Adeel.

Re: OpenModelica Basics

The dbus-server.py should be available now. Adrian has fixed it in r18663.

Adeel.

Re: OpenModelica Basics

Thanks adeas.

I'll download the latest version and check it out.

Wbraun had given a link for finding instructions on the visualization part which had a link to the Modelica3d Wiki page
(https://mlcontrol.uebb.tu-berlin.de/red … lic/wiki).
This page had a few video clips on Modelica3Dehich now have been removed and do not exist anymore. Any idea if those exist on some other page or website?

Thanks and Regards,
Sanjay_Kamath

Re: OpenModelica Basics

Hi,
I've installed python and pyGtk as per the instructions in the user guide. Now, when i run the dbus-server.py, I get the following error in the command prompt.

Traceback (most recent call last):
  File "D:\\OpenModelica1.9.1Nightly\\lib\\omlibrary-modelica3d\\osg-gtk\\dbus-s
erver.py", line 17, in <module>
    viewer = CDLL("libm3d-osg-gtk.dll")  # GTK/OSG backend
  File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

What is the solution for this?

Re: OpenModelica Basics

Copy that dll around to every single directory on your system so it can be found. That usually works for Windows current/smile

Or use Linux; works flawlessly there.

Re: OpenModelica Basics

You mean copy the libm3d-osg-gtk.dll to each and every folder in the openmodelica installation directory right?

Re: OpenModelica Basics

Isn't it python that needs it? I don't think OpenModelica needs it...

Re: OpenModelica Basics

so copy the libm3d-osg-gtk.dll to every folder in the python directory?

Re: OpenModelica Basics

Maybe. I don't have any Windows machine to test it on current/wink

Re: OpenModelica Basics

How do you start dbus-server.py? The libm3d-osg-gtk.dll is located in the same directory where dbus-server.py is.
I need to know how you run your python script?
If you just cd to the directory and run,

Code:

python dbus-server.py

it should work.

Adeel.

Re: OpenModelica Basics

I have OpenModelica installed in D:\
So i enter the command prompt and type
python "D:\\OpenModelica1.9.1Nightly\\lib\\omlibrary-modelica3d\\osg-gtk\\dbus-server.py"


Even if i do
cd D:\OpenModelica1.9.1Nightly\lib\omlibrary-modelica3d\osg-gtk6
and then type
python dbus-server.py

still gives me the same error

Re: OpenModelica Basics

You should do,

Code:

cd "D:\\OpenModelica1.9.1Nightly\\lib\\omlibrary-modelica3d\\osg-gtk"

python dbus-server.py

In this way your working directory is "osg-gtk" and then python can find the dll.

Adeel.

Re: OpenModelica Basics

Did that.. Still the same error. I'm reinstalling OpenModelica in the default directory. I'll check it out again and let you know.

Am I using  the correct versions of the following softwares?

I'm using python 2.7.3 64 bit.

I couldnt find the 64 bit version of  pygtk-all-in-one-2.24.2.win32-py2.7.msi. So I'm using gtk+-bundle_2.22.1-20101229_win64

Re: OpenModelica Basics

I don't think reinstalling OpenModelica will help.

You should probably try with 32 bit Python and pygtk-all-in-one-2.24.2.win32-py2.7.msi

Adeel.

Re: OpenModelica Basics

I've installed in the default directory. This is what i get in the command prompt now.

C:\OpenModelica1.9.1Nightly\lib\omlibrary-modelica3d\osg-gtk>python dbus-server.
py
Traceback (most recent call last):
  File "dbus-server.py", line 9, in <module>
    omhome = os.environ['OPENMODELICAHOME']
  File "C:\Python27\lib\os.py", line 423, in __getitem__
    return self.data[key.upper()]
KeyError: 'OPENMODELICAHOME'

Re: OpenModelica Basics

Check your OPENMODELICAHOME environment variable.

Adeel.

Re: OpenModelica Basics

It is set to C:\OpenModelica1.9.1Nightly\

Is that right?

Re: OpenModelica Basics

Yes, that is right. I don't know why then python says,

File "C:\Python27\lib\os.py", line 423, in __getitem__
    return self.data[key.upper()]
KeyError: 'OPENMODELICAHOME'

As I said try with 32 bit version of python and pygtk.

Adeel.

Re: OpenModelica Basics

I installed the 32bit versions. Finally.. dbus server ran successfully. But now there's a new problem

I opened OMShell, typed
loadModelica3D()

It returned:
true

I typed

simulate(Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum,stopTime=30)

It gave me

record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 30.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "Simulation execution failed for model: Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum
",
    timeFrontend = 2.29278456477762,
    timeBackend = 0.9708275990830332,
    timeSimCode = 0.5450928611711536,
    timeTemplates = 1.209451456002341,
    timeCompile = 12.70178292678702
end SimulationResult;
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.x_label.cylinders[1].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.x_label.cylinders[2].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.y_label.cylinders[1].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.y_label.cylinders[2].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.z_label.cylinders[1].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.z_label.cylinders[2].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.z_label.cylinders[3].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.x_arrowLine.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.x_arrowHead.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.y_arrowLine.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.y_arrowHead.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.z_arrowLine.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.z_arrowHead.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.gravityArrowLine.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller world.gravityArrowHead.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller revolute1.cylinder.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    .Modelica.Mechanics.MultiBody.World world; defined in scope: Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum. Referenced by 'outer' components: {revolute1.world}
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller boxBody1.frameTranslation.shape.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    .Modelica.Mechanics.MultiBody.World world; defined in scope: Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum. Referenced by 'outer' components: {boxBody1.frameTranslation.world, boxBody1.world, revolute1.world}
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller revolute2.cylinder.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    .Modelica.Mechanics.MultiBody.World world; defined in scope: Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum. Referenced by 'outer' components: {revolute2.world, boxBody1.body.world, boxBody1.frameTranslation.world, boxBody1.world, revolute1.world}
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
[C:\OpenModelica1.9.1Nightly\lib\omlibrary\ModelicaServices 3.2.1 modelica3d\Modelica3D\package.mo:507:5-507:33:writable] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller boxBody2.frameTranslation.shape.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    .Modelica.Mechanics.MultiBody.World world; defined in scope: Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum. Referenced by 'outer' components: {boxBody2.frameTranslation.world, boxBody2.world, revolute2.world, boxBody1.body.world, boxBody1.frameTranslation.world, boxBody1.world, revolute1.world}
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
Warning: The initial conditions are not fully specified. Use +d=initialization for more information.

Re: OpenModelica Basics

Read the rest of the commands used: https://build.openmodelica.org/Document … ica3D.html
(In particular where you need to insert this inner component to make Modelica3D happy)

Re: OpenModelica Basics

I think we should update the users guide as it is still the old example code in it.
I will fix it.

Adeel.

Re: OpenModelica Basics

Thanks a ton.. Visualization is working now current/smile

Re: OpenModelica Basics

Great. I have also updated the users guide.

Adeel.

Re: OpenModelica Basics

I keep getting this warning most of the times.

Warning: The initial conditions are not fully specified. Use +d=initialization for more information.

What is this?

To visualize other multibody examples, I have to change only the last part in the extends line, right?

Re: OpenModelica Basics

Where can I find the updated Users Guide? I dont want to download the entire nightly build again, do I?

Re: OpenModelica Basics

One last question.

For the existing examples, I can give the path through the modelica library. i.e. Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum etc etc in the extends line.

What shall i give for the models that I create?

Re: OpenModelica Basics

The path of your models e.g MyPackage.MyNestedPackage.MyModel

Adeel.

Re: OpenModelica Basics

How do i find this path?

Re: OpenModelica Basics

What do you mean how do you find this path? You know this path since you have created it.

For example if I create the following package,

Code:

package p1

  package p2
    package p3
      model m1
      end m1;
    end p3;
  end p2;
end p1;

Now i know the path of model m1 i.e p1.p2.p3.m1

There are API calls to find the class names e.g,

Code:

loadString("package p1

  package p2
    package p3
      model m1
      end m1;
    end p3;
  end p2;
end p1;");
getClassNames();
getClassNames(p1);
getClassNames(p1.p2);
getClassNames(p1.p2.p3);

Adeel.

Re: OpenModelica Basics

No. I dont create a package as such. I open OMEdit, File>NewModelicaClass, Give a Name, Specialization-Model and start off

I save these .mo files in my local directories (say D:\Temp\sample.mo). How do i access these?

Re: OpenModelica Basics

Then the name you give to it, is the path since you don't put it inside any package.
Lets say you name it "SampleModel" then your visualization script will be something like this,

Code:

loadFile("D:\Temp\sample.mo");getErrorString();

loadModelica3D();getErrorString();
loadString("model SampleModelVis
  extends SampleModel;
  inner ModelicaServices.Modelica3D.Controller m3d_control;
end SampleModelVis;");getErrorString();
simulate(SampleModelVis);

Note that you need to load your model so that the compiler can find it.

Adeel.

Re: OpenModelica Basics

Thanks.

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