Modelica

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
saso
Posts: 1332
Joined: Fri May 16, 2014 1:14 pm
Contact:

Modelica

Postby saso » Sat Dec 01, 2018 1:17 pm

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
https://www.youtube.com/watch?v=9RgdZUvEjPw
https://www.youtube.com/watch?v=MCqQuIShmLM

And next to get a bit deeper in to using Modelica directly
https://www.youtube.com/watch?v=39F___xyI0k
https://www.youtube.com/watch?v=zjHxU2KImxc
https://www.youtube.com/watch?v=8msC1CihT18
https://www.youtube.com/watch?v=-mvEUuc-sWE
http://book.xogeny.com/

https://www.modelica.org/
https://www.modelica.org/education/educ ... erview.pdf

https://www.openmodelica.org/ <- get openmodelica if you just want to quickly start playing with it :)
https://www.openmodelica.org/doc/Modeli ... 202-BT.pdf
https://www.openmodelica.org/doc/OpenMo ... de/latest/
https://www.openmodelica.org/openmodelicaworld/tools
https://github.com/OpenModelica/OpenModelica

https://jmodelica.org/
https://www.reddit.com/r/Python/comment ... 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,...)
Last edited by saso on Wed Oct 23, 2019 10:06 am, edited 10 times in total.
User avatar
microelly2
Posts: 4409
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Modelica

Postby microelly2 » Sat Dec 01, 2018 2:01 pm

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.
+1
looo
Posts: 2905
Joined: Mon Nov 11, 2013 5:29 pm

Re: Modelica

Postby looo » Sun Dec 02, 2018 3:02 pm

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.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
User avatar
saso
Posts: 1332
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Modelica

Postby saso » Sun Dec 02, 2018 3:40 pm

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.org, "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:
User avatar
bernd
Posts: 8428
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Modelica

Postby bernd » Sun Dec 02, 2018 8:11 pm

if it makes sence to connect it to FreeCAD sooner or later there will be someone who connect it to FreeCAD ...
User avatar
saso
Posts: 1332
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Modelica

Postby saso » Mon Dec 03, 2018 5:39 pm

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:
User avatar
microelly2
Posts: 4409
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Modelica

Postby microelly2 » Mon Dec 03, 2018 6:09 pm

modelica is very powerful tool and I think it would be good to invest some time in an interface
https://www.youtube.com/user/Systemdyna ... 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.
looo
Posts: 2905
Joined: Mon Nov 11, 2013 5:29 pm

Re: Modelica

Postby looo » Mon Dec 03, 2018 10:19 pm

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: http://book.xogeny.com/behavior/equations/first_order/
modelica:

Code: Select all

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

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.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
EkaitzEsteban
Posts: 100
Joined: Wed Sep 12, 2018 1:31 pm

Re: Modelica

Postby EkaitzEsteban » Thu Dec 06, 2018 6:42 am

Hello,

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

https://fmi-standard.org/

https://pypi.org/project/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:

https://en.wikipedia.org/wiki/Functiona ... _Interface
EkaitzEsteban
Posts: 100
Joined: Wed Sep 12, 2018 1:31 pm

Re: Modelica

Postby EkaitzEsteban » Sat Dec 08, 2018 7:37 am

Hello,

More info in page 139 https://tel.archives-ouvertes.fr/tel-01565658/document

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
toolchain.PNG (53.37 KiB) Viewed 1786 times