FreeCAD as pre-post procesor for MBDyn

About the development of the FEM module/workbench.

Moderator: bernd

josegegas
Posts: 22
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

FreeCAD as pre-post procesor for MBDyn

Postby josegegas » Sun Sep 08, 2019 5:21 am

Hi all. For my PhD I've been using MBDyn to do simulations of engines and other mechanisms. It is a free and open source multi body dynamics software. It is very powerful but it lacks pre and post processing graphic interface. I've been using FreeCAD as pre and post processing tool for MBDyn and all works very well. Both programs can be integrated nicely through python scripts. I think they could also be integrated in a new workbench. A few days ago I started programing a new workbench with this purpose and though it may be a good idea to share the results here and see if people are interested. In the video you can see a simulation of a simple pendulum under different initial conditions (mass, initial angular velocity, gravitational acceleration, etc). Then I add another body, a simple cylinder, and give it some initial conditions too. FreeCAD can then be used to visualize the MBDyn results. Wat you see in the video is the two objects moving and the reaction forces in the "hinge", which is how they call the joint in MBDyn. Let me know what do you think and if its worth keep working on this! In the end we could be able to give FreeCAD similar features as MSC Adams or something....

https://www.facebook.com/josegabriel.eg ... 599267675/

In this video I've already added the plot tool, so you can visualize the position, angular position, acceleration, and angular acceleration of each "node" in the simulation. A node can be defined as a point within the body:

https://www.youtube.com/watch?v=V0cVsi3 ... e=youtu.be
RatonLaveur
Posts: 317
Joined: Wed Mar 27, 2019 10:45 am

Re: FreeCAD as pre-post procesor for MBDyn

Postby RatonLaveur » Sun Sep 08, 2019 6:40 am

That is sick, Sir! Perhaps a call to the FEM crowd, such as Bernd (FEM) or Oliveroxtoby (CFD) to continue this discussion on how best to integrate efforts?
vocx
Posts: 1423
Joined: Thu Oct 18, 2018 9:18 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby vocx » Mon Sep 09, 2019 12:25 am

josegegas wrote:
Sun Sep 08, 2019 5:21 am
I've been using MBDyn to do simulations of engines and other mechanisms. It is a free and open source multi body dynamics software. It is very powerful but it lacks pre and post processing graphic interface. I've been using FreeCAD as pre and post processing tool for MBDyn and all works very well. Both programs can be integrated nicely through python scripts. I think they could also be integrated in a new workbench.
I don't know MBDyn, but it sounds like it would be in the same ballpark as Modelica. Saso has a keen interest in something like this, but so far no real development has taken place; see Modelica.

It'd be awesome if you could develop something that is general, that is, able to use different solvers, one of which could be MBDyn and another Modelica. That's basically how the FEM Workbench works.
saso wrote:
Sat Dec 01, 2018 1:17 pm
ping
User avatar
microelly2
Posts: 4361
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Postby microelly2 » Mon Sep 09, 2019 11:43 am

It realy would be nice to have an interface to MBDyn.
Implement a protytype and see how comformatable it will be.
User avatar
saso
Posts: 1310
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Postby saso » Mon Sep 09, 2019 12:32 pm

Above demo videos indeed look very nice, in the past there has been a similar demo done also with Bullet Physics but there were some concerns if it is really appropriate for real engineering work... MBDyn license is GPL so it would have to be installed separately, ok, but it seems like default installation packages are only for linux? We have also been already looking at https://projectchrono.org/ and Modelica.
mfasano
Posts: 49
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby mfasano » Mon Sep 09, 2019 2:43 pm

I have just started a work bench as a pre and post processor for MBDyn. I was going to use assembly 4 as a base. I thought the use of local coordinate systems would be useful and I would not need a constraint solver because MBDyn would notify if there was a problem. I also thought it would be difficult to translate constraints from assembly 3 or A2+ into MBDyn joints.

One issue with using FreeCAD for multibody dynamics is there is no routine to calculate moment of inertia for arbitrary shapes(part design); that would need to be written.
User avatar
Kunda1
Posts: 5505
Joined: Thu Jan 05, 2017 9:03 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby Kunda1 » Tue Sep 10, 2019 1:53 am

Just an aside, looking at the original clips by OP and how many times they needed to increase/decrease the widget window, that's a useability issue. Looking at the UI it's pretty surprising how much space title bars and tabs take up. But this discussion would be better the UI/UX subforum.

Also, maybe at some point a potential workbench like this would for sure benefit from a node based paradigm: pyflow.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
josegegas
Posts: 22
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Postby josegegas » Tue Sep 10, 2019 2:53 am

mfasano wrote:
Mon Sep 09, 2019 2:43 pm
I have just started a work bench as a pre and post processor for MBDyn.
Sounds great that you had the same idea! Would you mind sharing some details? My approach has been to create customized objects in FreeCAD that contain the properties of each object required by MBDyn. Thus, I create a "Gravity" object in FreeCAD that has the gravitational acceleration and the direction vector. There is also a "Rigid Body" object that has the mass, center of mass, inertia tensor, etc. A "Node" object that has the initial conditions, etc... Then my Python script reads the objects and writes the txt file (.mbd) to be read by MBDyn. I then run the simulation, and read the output files to animate the objects in FreeCAD. What is your approach?
josegegas
Posts: 22
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Postby josegegas » Tue Sep 10, 2019 2:59 am

mfasano wrote:
Mon Sep 09, 2019 2:43 pm
I was going to use assembly 4 as a base.
Why would you need assembly 4? I mean, MBDyn already takes care of the mechanism assembly. It will yield an error if the assembly was not consistent. My approach to animate the simulation results is just to use a timer (imported from Qt) to update each part's position and orientation. This is very straightforward since MBDyn writes the simulation results in a simple text file, from where all I do is read the values and move the 3D objects accordingly. MBDyn gives me XYZ positions and Euler angles, exactly what FreeCAD loves haha
josegegas
Posts: 22
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Postby josegegas » Tue Sep 10, 2019 3:05 am

mfasano wrote:
Mon Sep 09, 2019 2:43 pm
I would not need a constraint solver because MBDyn would notify if there was a problem. I also thought it would be difficult to translate constraints from assembly 3 or A2+ into MBDyn joints.
I thought exactly the same. There is no need for constraint solver because MBDyn already does this. My idea is to use FreeCAD only as pre and post processor. MBDyn is already a very powerful tool. If we could use FreeCAD to make MBDyn more user friendly, by avoiding the complicated input files, this would be awesome! :D