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

ModelicaML source code usage

ModelicaML source code usage

Hello everyone,

I am currently trying to use a few parts of ModelicaML within the project that my team is working on. However, for various reasons, I have a hard time compiling the source code and using it to pinpoint which components I will require (Basically, the code that transforms the graphical model to Modelica code).
Are there any developers around who might be able to point me to which plug-in project may be involved ?
I was able to find the code that calls OMC to compile Modelica code and get the simulation results back in the project org.openmodelica.modelicaml.generate.modelica, I am not quite sure however that this is the actual code that is called when simulating a ModelicaML model, but it does what I need, which is providing a simple way to call OMC.
The other thing I need is model transformation. I suspect somewhere in the code is a plug-in that translates the drawn graphical model and translates it into Modelica code. This part of the code I can't find.

Thank you for your help,

Yann

Re: ModelicaML source code usage

Hi Yann,

The Modelica code is generated from .uml files. The .uml file contains only the model and no diagrams.
The plugin used for Modelica code generation is "org.openmodelica.modelicaml.gen.modelica" (it is based on Acceleo 2.x). The one you mentioning (org.openmodelica.modelicaml.generate.modelica) is based on Acceleo 3.x and is still ongoing work.

Wladimir

Re: ModelicaML source code usage

So this means I would only have to generate .uml models from my own models, do you think such a thing would be doable without proving to be tedious ? Mostly, the problems that I am representing are quite simple, a few physical objects connected together with a few specific values in their attributes, nothing too fancy, so I probably don't need all the possibilities that ModelicaML might provide. I have absolutely no experience with Acceleo so I don't really know where to start. Please tell me there's simply a class in which you call a "transform" method on a file and the rest is taken care of by the application current/big_smile
Also, is there a place where I could download .uml samples to see the general aspect of the models that ModelicaML uses and which concepts of UML are being used ?

Thanks,

Yann

Edit : I think I may have found the entrypoint in the org.openmodelica.modelicaml.gen.modelica.popupactions package, as for the uml samples, I'd still appreciate a few, but I will also try to create some directly through the application.

Re: ModelicaML source code usage

Modelica code is generated from  a .uml file that contains the UML model with ModelicaML stereotypes applied. See the ModelicaML profile description at http://www.ida.liu.se/labs/pelab/modeli … 1_3_2.html for UML concepts used.

You can look at: "/org.openmodelica.modelicaml.gen.modelica/src/org/openmodelica/modelicaml/gen/modelica/popupactions/GenerateModelicaCodeFromEntireModelicaMLModelAction.java" to see how the CG is invoked from Java code (e.g. the runchain() operation).

I can send you an example of a ModelicaML model ...

Re: ModelicaML source code usage

Thank you for your answer and for providing a model, it is really helpful.

I've been trying to create very simple models for experimenting and understanding the strings behind it all, but I'm having a few issues. Most of the problems I am modeling are as simple as the following code :

Code:

model example_floor_1

  inner Modelica.Mechanics.MultiBody.World world;
  Modelica.Mechanics.MultiBody.Parts.Fixed fixed;
  MechanicalComponents.Floor floor;
  MechanicalComponents.Object obj1(r_0.start = {1, 0, 0}, each r_0.fixed = true);
  MechanicalComponents.FrictionForce friction1(force = extf1.f_world + obj1.gravity_force, floorinfo = floor.info,mu=1);
  MechanicalComponents.ExternalForce extf1(f_0 = {0.1, 0, 0});
equation
  connect(fixed.frame_b, floor.frame_start);
  connect(obj1.frame_a, extf1.frame_b);
  connect(friction1.frame_b, obj1.frame_a);
end example_floor_1;

I can easily create a model with variables of the corresponding types, however, when it comes to connecting them, I can't really find a way to do so.
If I'm using a predefined class such as MechanicalComponents.Object, do I still have to define connection ports for using frame_a and frame_b ? I may be missing something here, but shouldn't I be able to access these fields directly when defining my connections ?

Again, thank you for your help

There are 0 guests and 0 other users also viewing this topic
You are here: