Skip to content

Commit

Permalink
Modelica3D updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Jun 6, 2015
1 parent c8e04de commit 33e7b0e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 78 deletions.
127 changes: 51 additions & 76 deletions usersguide-sphinx/source/modelica3d.rst
@@ -1,115 +1,90 @@
Modelica3D
==========

.. highlight:: modelica

Modelica3D is a lightweight, platform independent 3D-visualisation
library for Modelica. Read more about the Modelica3D library here
`*https://mlcontrol.uebb.tu-berlin.de/redmine/projects/modelica3d-public* <https://mlcontrol.uebb.tu-berlin.de/redmine/projects/modelica3d-public>`__.
library for Modelica. Read more about the Modelica3D library `here <https://mlcontrol.uebb.tu-berlin.de/redmine/projects/modelica3d-public>`__.

Installing Modelica3D
---------------------

Windows
-------
~~~~~~~

In order to run Modelica3D on windows you need following softwares;

- Python – Install python from
`*http://www.python.org/download/* <http://www.python.org/download/>`__.
http://www.python.org/download/.
Python2.7.3 is recommended.

- PyGTK – Install GTK+ for python from
`*http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/* <http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/>`__.
http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/.
Download the all-in-one package. Recommmended is
pygtk-all-in-one-2.24.2.win32-py2.7.msi.

Run the Modelica3D server by executing the dbus-server.py script located
at OPENMODELICAHOME/lib/omlibrary-modelica3d/osg-gtk.

python dbus-server.py

This will start the Modelica3D server and on success you should see the
output,

Running dbus-server...

Now run the simulation. The following commands will load the Modelica3D
library and simulates the DoublePendulum example,

loadModelica3D(); getErrorString();

loadString("model DoublePendulum

extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;

inner ModelicaServices.Modelica3D.Controller m3d\_control;

end DoublePendulum;"); getErrorString();

simulate(DoublePendulum); getErrorString();

If everything goes fine a visualization window will pop-up. To visualize
any models from the MultiBody library you can use this script and change
the extends to point to the model you want. Note that you will need to
add visualisers to your model similarly to what Modelica.MultiBody
library has. See some documentation of the visualizers available here:
`*https://build.openmodelica.org/Documentation/Modelica.Mechanics.MultiBody.Visualizers.html* <https://build.openmodelica.org/Documentation/Modelica.Mechanics.MultiBody.Visualizers.html>`__

loadModelica3D(); getErrorString();

loadString("

model Visualize\_MyModel

inner ModelicaServices.Modelica3D.Controller m3d\_control;

extends **MyModel**;

end Visualize\_MyModel;

");

simulate(Visualize\_MyModel); getErrorString();

MacOS
-----
~~~~~

On MacOS you can use the 3d visualization like this. Note that on your
system the paths used here might vary. In one terminal type:

# start the dbus server (you only need to do this once)
.. code-block :: bash
> sudo launchctl load -w
/opt/openmodelica/Library/LaunchDaemons/org.freedesktop.dbus-system.plist
# start the dbus server (you only need to do this once)
sudo launchctl load -w /opt/openmodelica/Library/LaunchDaemons/org.freedesktop.dbus-system.plist
launchctl load -w /opt/openmodelica/Library/LaunchAgents/org.freedesktop.dbus-session.plist
# export python path
export PYTHONPATH=/opt/openmodelica/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:$PYTHONPATH
> launchctl load -w
/opt/openmodelica/Library/LaunchAgents/org.freedesktop.dbus-session.plist
Running Modelica3D
------------------

# export python path
Run the Modelica3D server by executing the dbus-server.py script located
in your OpenModelica or Modelica3D installation, for example:

.. omc-mos ::
> export
PYTHONPATH=/opt/openmodelica/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:$PYTHONPATH
"python " + getInstallationDirectoryPath() + "/lib/omlibrary-modelica3d/osg-gtk/dbus-server.py"
# run the dbus-server.py
Running this command in a command prompt will start the Modelica3D
server and on success you should see the output:

# go to your openmodelica installation /lib/omlibrary-modelica3d/osg-gtk
Running dbus-server...

Now run the simulation. The following commands will load the Modelica3D
library and the modified DoublePendulum example:

> python dbus-server.py
.. omc-mos ::
In another terminal type:
loadModelica3D()
> cat > modelica3d.mos
.. omc-loadstring ::
loadModelica3D();getErrorString();
model DoublePendulum
extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;
inner ModelicaServices.Modelica3D.Controller m3d_control;
end DoublePendulum;
loadString("model DoublePendulum
Then simulate the DoublePendulum:

extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;
>>> simulate(DoublePendulum)

inner ModelicaServices.Modelica3D.Controller m3d\_control;
If everything goes fine a visualization window will pop-up. To visualize
any models from the MultiBody library you can use this script and change
the extends to point to the model you want. Note that you will need to
add visualisers to your model similarly to what Modelica.MultiBody
library has. The documentation of the visualizers is available `here <https://build.openmodelica.org/Documentation/Modelica.Mechanics.MultiBody.Visualizers.html>`__

end DoublePendulum;");getErrorString();
.. omc-mos ::
instantiateModel(DoublePendulum); getErrorString();
loadModelica3D()
simulate(DoublePendulum); getErrorString();
.. omc-loadstring ::
CTRL+D
model Visualize_MyModel
inner ModelicaServices.Modelica3D.Controller m3d_control;
extends MyModel;
end Visualize_MyModel;
> omc modelica3d.mos
>>> simulate(Visualize_MyModel)
6 changes: 4 additions & 2 deletions usersguide-sphinx/source/profiler.rst
@@ -1,5 +1,5 @@
Modelica Performance Analyzer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#############################

A common problem when simulating models in an equation-based language
like Modelica is that the model may contain non-linear equation systems.
Expand Down Expand Up @@ -59,9 +59,11 @@ We simulate as usual, but set measureTime=true to activate the profiling:
:target: ProfilingTest_prof.999.svg
system("pandoc -o ProfilingTest_prof.rst ProfilingTest_prof.html")
system("sed -i= 's/:target: ProfilingTest_prof.*/:width: 32px/' ProfilingTest_prof.rst")
system("mv ProfilingTest_prof.rst ../source/ProfilingTest_prof.inc")
system("rm ProfilingTest_prof.html")
system("cp ProfilingTest_prof* ../source/")
.. include :: ProfilingTest_prof.rst
.. include :: ProfilingTest_prof.inc
Genenerated JSON for the Example
================================
Expand Down

0 comments on commit 33e7b0e

Please sign in to comment.