Modelica

About the development of the FEM module/workbench.

Moderator: bernd

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

Modelica

Post 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.

Modelica
https://en.wikipedia.org/wiki/Modelica

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

And next to get a bit deeper in to using Modelica directly
https://www.youtube.com/watch?v=39F___xyI0k Introduction to MODELICA & DYMOLA
https://www.youtube.com/watch?v=zjHxU2KImxc Complex Systems simulations with open standards & Dymola
https://www.youtube.com/watch?v=8msC1CihT18 Introduction to Modelica
https://www.youtube.com/watch?v=-mvEUuc-sWE Component Oriented Modeling of Physical Systems
https://www.youtube.com/watch?v=Hl1vjQWxvOA Why Would Anybody Care About Modelica?
https://www.youtube.com/watch?v=X2FgEFyfnfQ A Simple ODE
https://www.youtube.com/playlist?list=P ... QA6sJiLpkB
https://www.youtube.com/playlist?list=P ... yiz1misw3a
http://book.xogeny.com/

https://marcobonvini.com/modelica/2020/ ... elica.html All about Modelica

https://www.eradity.com/blog/29-modelic ... o-modelica Introduction to Modelica
https://www.eradity.com/blog/30-modelic ... n-modelica Writing Equations in Modelica
https://www.eradity.com/blog/31-modelic ... -and-types Connectors and Types
https://www.eradity.com/blog/32-modelic ... -functions Using Functions
https://www.eradity.com/blog/34-modelic ... r-overflow Wastewater Overflow

https://www.claytex.com/tech-blog/model ... ipulation/ Introduction to the model translation and symbolic processing
https://www.claytex.com/tech-blog/creat ... jacobians/ The Analytical Jacobian
https://www.claytex.com/tech-blog/calcu ... f-a-model/ Calculating partial derivatives of a model
https://www.claytex.com/tech-blog/a-wat ... on-system/ A Water Well Pump and Distribution System
https://www.claytex.com/tech-blog/model ... in-dymola/ Modelling a Wind Turbine in Dymola

Wolfram U Modeling & Simulation
https://www.wolfram.com/wolfram-u/catal ... imulation/

https://www.modelica.org/
https://www.modelica.org/education/educ ... erview.pdf
http://www.bromans.com/david/publ/thesi ... broman.pdf
https://github.com/modelica/ModelicaStandardLibrary
https://github.com/modelica-3rdparty

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.mic-journal.no/PDF/2020/MIC-2020-4-1.pdf
https://www.openmodelica.org/doc/OpenMo ... de/latest/
https://www.openmodelica.org/openmodelicaworld/tools
https://github.com/OpenModelica/OpenModelica

https://ibpsa.github.io/project1/

https://modelica-buildingsystems.de/
https://github.com/UdK-VPT/BuildingSystems

https://www.ebc.eonerc.rwth-aachen.de/c ... 58/lidx/1/
https://www.ebc.eonerc.rwth-aachen.de/go/id/obmj/lidx/1
https://github.com/RWTH-EBC/AixLib

https://www.ebc.eonerc.rwth-aachen.de/c ... 25/lidx/1/
https://github.com/RWTH-EBC/TEASER

https://simulationresearch.lbl.gov/modelica/
https://github.com/lbl-srg/modelica-buildings

https://www.colorado.edu/lab/sbs/tools
https://vimeo.com/464446924
https://vimeo.com/464445684
https://vimeo.com/464376624
https://vimeo.com/464373709

https://github.com/open-ideas/IDEAS

https://github.com/christiankral/HanserModelica
https://www.youtube.com/watch?v=esGAcZ_ViRU

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 1D simulations, 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 Aug 09, 2023 1:51 pm, edited 36 times in total.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Modelica

Post 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.
+1
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Modelica

Post 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.
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Modelica

Post 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.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
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Modelica

Post by bernd »

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

Re: Modelica

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

Re: Modelica

Post by microelly2 »

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.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Modelica

Post 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: 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 pmthis 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.
EkaitzEsteban
Posts: 108
Joined: Wed Sep 12, 2018 1:31 pm

Re: Modelica

Post by EkaitzEsteban »

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: 108
Joined: Wed Sep 12, 2018 1:31 pm

Re: Modelica

Post by EkaitzEsteban »

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 10795 times
Post Reply