Page 1 of 4


Posted: Sat Dec 01, 2018 1:17 pm
by saso
So, this is not about FEM :) but I am posting it here since it is closely related and can be complementary with it and since I believe that those users that have interest in FEM/CFD will also be most competent using it and have interest in it.

First, here are some videos to get a more higher level understanding of its possibilities and get some inspiration from an commercial tool implementation of it with an parametric 3d model

And next to get a bit deeper in to using Modelica directly ... QA6sJiLpkB ... yiz1misw3a ... erview.pdf ... broman.pdf <- get openmodelica if you just want to quickly start playing with it :) ... 202-BT.pdf ... de/latest/ ... ython_and/

I believe it would be very useful to explore the possibilities to connect it with FreeCAD. I know there were in the past already some suggestions to use it for animations, but I hope that we can see from the above examples that it can be used for much much more and that its core powers are in system dynamics, solving differential, algebraic and discrete equations, lumped and logical models, systems engineering,...

While most of the usage examples that can be found around the internet are more from mechanical systems, and I am sure that there are many FreeCAD users that have a lot of interest in that, personally I am interested more in how it could be used in building construction (eg. structural calculations, thermal and energy calculations, noise transmissions, MEP and electrical systems,...)

Re: Modelica

Posted: Sat Dec 01, 2018 2:01 pm
by microelly2
saso wrote:
Sat Dec 01, 2018 1:17 pm
I believe it would be very usefully to explore the possibilities to connect it with FreeCAD.

Re: Modelica

Posted: Sun Dec 02, 2018 3:02 pm
by looo
In my mind the "one library that has it all" is the wrong approach to this kind of problems (talking about surrogates, optimization, uncertainty quantification, ...). With python there are libraries for nearly every kind of task.

It would be nice to have a simple gui for this kind of tasks in python. In my mind a node-editor would be the best way to connect the data from CAD with some parameter-variations, optimizations. This would definetly be a nice thing. Once such an environment is included in FreeCAD it shouldn't b too difficult to connect data from FreeCAD with other tools to optimize what ever needs to be optimized.

Re: Modelica

Posted: Sun Dec 02, 2018 3:40 pm
by saso
I suggest to take the time to go over the above links and check around the internet a bit more to understand how big Modelica actually is in the industry. Also, it is not a library, from, "Modelica is a non-proprietary, object-oriented, equation based language". From an industrial robot example "doing 1000 non-trivial algebraic equations, 80 states, faster as real-time on slow PC"... I do like Python libraries and for sure they can still be used here and there, but you will probably realize that this monster is eating Python libraries for breakfast :roll:

Re: Modelica

Posted: Sun Dec 02, 2018 8:11 pm
by bernd
if it makes sence to connect it to FreeCAD sooner or later there will be someone who connect it to FreeCAD ...

Re: Modelica

Posted: Mon Dec 03, 2018 5:39 pm
by saso
The absurd thing about Modelica is that it seems to be mostly unknown outside the big industries and academia even when the Modelica language, its standard libraries and some of the simulation environments (like openmodelica and jmodelica) are all opensource. The sad thing about it however seems to be that it is also mostly unknown to other industries besides automotive and aerospace where it is very big, even when the language itself is again very generic and works across multiple domains (e.g., mechanical, electrical, electronic, hydraulic, thermal,...). If I understand it correctly it should be able for example to do a real-time simulation (or close to it) of an steel frame structure under an earthquake down to "sensor" data of every bolt in every steel connection... But for now it is an open question, that needs more research and testing to see if I am right about that :roll:

Re: Modelica

Posted: Mon Dec 03, 2018 6:09 pm
by microelly2
modelica is very powerful tool and I think it would be good to invest some time in an interface ... y=modelica
whenever I have finished my investigations in freeform surfaces I will come back to this task.
I see the large number of facets of FreeCAD extensions and having access to a powerful simulation software may imporove usability.

Re: Modelica

Posted: Mon Dec 03, 2018 10:19 pm
by looo
yes you are right I do not yet know what modelica aims at. I guess a big part is solving ode's. So I did a simple comparison:

example from here:

Code: Select all

model FirstOrder
  Real x;
  der(x) = 1-x;
end FirstOrder;

Code: Select all

from scipy.integrate import odeint
import numpy as np

def f(x, t):
    return [1 - x[0]]

t = np.linspace(0, 10, 1000)
x = odeint(f, [0], t)
For the python code you have to know how to transform a differential equation of higher order into a system of first order differential equations. I guess this is what modelica does in the background.

This example is too simple to make any conclusions. Python is generic and has tools for solving different kind of tasks (like ode's). Modelica aims directly at modeling systems. I guess the graphical component is the big advantage that makes modelica great. Such a graphical interface would be a nice addition for FreeCAD too. But I think such an interface is not only about modeling systems. There are endless possibilities that can be done with this. (see blenders node-editor which is used for the material-definitions, for geometry-definitons (sverchok), postprocessing and so on.

So in my opinion a node-editor would be a generic tool which fits perfectly between the gui-functionality and scripting and would be a perfect addition for FreeCAD. The gui-stuff done with modelica can be done with a good node-editor too. That's why I think a node-editor is one of the most essential things needed for FreeCAD. But this should eventually go into another topic, as this topic should be about modelica.
saso wrote:
Sun Dec 02, 2018 3:40 pm
this monster
I guess not everyone is a big fan of monsters. Especially maintainers fear them a lot. We already pull in quite some monsters (vtk, qt, coin, ...) FreeCAD is already one of the most difficult libraries because of the insane dependency tree. Adding another programming language is not what makes any maintainer happy... :D

But for sure having modelica as an addon somehow integrated into FreeCAD would be a really nice addition.

Re: Modelica

Posted: Thu Dec 06, 2018 6:42 am
by EkaitzEsteban

I tried a little bit with Modelica years ago and I know that it can be connected with python via PyFMI.

A colleague was able to run simulations of a model developed in OpenModelica with python via PyFMI.

M. Gonzalez, E. Esteban, O. Salgado, M. Urchegui, J. Croes, B. Pluymers and W. Desmet,. Model-based virtual sensing approaches for the estimation of forces in guiding systems, In proccedings of International Conference on Noise and Vibration engineering (ISMA) and International Conference on Uncertainty in Structural Dynamics (USD), 2016.

Maybe this can help in the integration of Modelica in FreeCAD...

more general info: ... _Interface

Re: Modelica

Posted: Sat Dec 08, 2018 7:37 am
by EkaitzEsteban

More info in page 139

Regarding the connection between FreeCAD and OpenModelica, the “OMPython” Python library ensures the connection between Python scripts from FreeCAD and OpenModelica. This library can be used to launch simulations and read results. However, OMPython cannot be used to automatically generate a Modelica file, thus it must be generated manually.
Finally, the interface between these different software tools for the different model transformations will be ensured by the Python language and FreeCAD will play the role of coordinator, as described in the following paragraph.
Furthermore, as FreeCAD software is an opensource software application, it can be compiled with additional libraries, such as Pywin32 (to provide the interface between PTC software, Python language, and OMPython). The compiled version of FreeCAD is therefore portable and a batch script has been implemented in order to install the compiled FreeeCAD model to facilitate the further reutilization of the demonstrator.
toolchain.PNG (53.37 KiB) Viewed 3532 times