FreeCAD as pre-post processor for MBDyn

About the development of the FEM module/workbench.

Moderator: bernd

JamesLiu
Posts: 26
Joined: Sat Apr 28, 2018 6:23 am

Re: FreeCAD as pre-post processor for MBDyn

Post by JamesLiu »

MBDyn has a module cont-contact for the continuous contact constitutive law, https://mail.mbdyn.org/pipermail/mbdyn- ... 01917.html

It would be great if this workbench can handle the cont-contact easily.
josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

ChainSalad wrote: Wed Dec 22, 2021 1:31 am I'm impressed at the progress achieved!
I saw the videos "elastic contact" and "Bouncing Brick". While it seems like in "elastic contact" the contact force is a structural z-force where the modifier probably depends on the distance between the plane and the ball center, I'm curious how this was done in the case of the bouncing brick.
It would be great if it would be possible to define groups of surfaces which can collide, with elastic contact force direction, perhaps even friction being calculated automatically.
I believe this would be more important to users like me (mechanical engineer) than integrated FEM (where once you have joint forces you can calculate things per body, one by one)
Is this possible yet?
I regularly use the 2D simulation tool "Algodoo", which has a similar feature with added friction and bounce energy dissipation values. Very useful!
Thanks.

The elastic contact example was set exactly as you described it. There is a structural force determined by the distance between the two nodes. It is basically an adaptation of this example:

https://www.sky-engin.jp/en/MBDynExampl ... /ex09.html

The "bouncing brick" is also the same, although there is one node at each corner of the brick, to which a structural force is applied. All the nodes are rigidly attached together.

It is not possible yet to model collisions and contact between surfaces. It would be great to implement this in the future!

By now I am not really focused on adding new MBDyn tools to this workbench, but more on finding what new possibilities can arise from the combination of the CAD software and the MBD software. There are so many interesting things to do! One example. I have been using FreeCAD to design mechanisms for abut 5 years, and I always struggle to find out if there will be collision between parts. I do not mean a model of the physical collision such as in the "bouncing brick", but only to detect if, once the "real-world" mechanism is assembled, the parts will collide. This can be easily done with most commercial CAD packages, but not yet with FreeCAD. This is something I will implement in my workbench, using a simple algorithm such as this:

https://www.youtube.com/watch?v=M_V6QYEa56c

Another great possibility is what I have described before: to convert CAD shapes into scalar functions. There are many possible applications of this! For instance the inverse kinematic for robots I have shown before, or finding the paths for CNC tools, laser cutters, etc.

Something I have been working on is the integration of units. The idea is that FreeCAD will take care of ensuring the correct units go into MBDyn.

Another thing I have been working on is using App:PropertyLink to make joints and nodes parametric. This is very useful, since one can have the parts in separate files and change their dimensions, and the MBD model will not break. Basically the nodes can be attached to any edge or face of any body, and the joints become defined by parts of the CAD geometry as well. The software will then calculate all the relative offsets and orientations, after a joint or a node have moved due to a change in the CAD model.

Another fantastic development for the future is the integration with the FEM workbench. MBDyn can provide the dynamic forces, and these can then be used to perform FEM dynamic analyses of the parts. Calculix can certainly do dynamic analyses, although these have not been implemented in the FEM workbench. As far as I know, only static analyses are possible with the FEM workbench? If someone is interested in this please let me know! It would be great to have some discussion on how to achieve this...
josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

JamesLiu wrote: Wed Dec 22, 2021 2:48 am MBDyn has a module cont-contact for the continuous contact constitutive law, https://mail.mbdyn.org/pipermail/mbdyn- ... 01917.html

It would be great if this workbench can handle the cont-contact easily.
Thanks!! I didn´t know about this, as it is not described in the input file manual...
josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

Hi.

There is a brand-new version of the workbench in my Gitlab:

https://gitlab.com/josegegas/freecad-mb ... -workbench

The main changes relative to the old one are:

1.- Now the whole workbench makes use of FreeCAD units. As is known, MBDyn does not care about units, and leaves to the user the task of checking that the units used are consistent. FreeCAD does this automatically now, ensuring MBDyn gets the input values in the correct units independently on what the user inputs in the GUI.

2.- All the joints use now "App::PropertyLinkSub", so that they are parametric. A revolute-pin joint, for instance, may be attached to tow faces or edges of a given part, and so if these faces or edges are moved, the joint moves accordingly.

3.- Nodes also have a "App::PropertyLinkSub" property now, so that they can be attached to specific points of the CAD geometry.

4.- The user can now create three types of scalar functions: user-defined, polar and Cartesian. I call user-defined scalar functions to those in which the user manually inputs the range of the function. Polar and Cartesian scalar functions are parametric, attached to edges of the CAD geometry. In a polar function the range is defined by the polar coordinates of a set of points evenly distributed along a set of CAD edges, taking as reference a given node. The same goes for a Cartesian function, although this contains specific components of the Cartesian coordinates. This is very cool, it allows the user simulate things such a contact between CAD objects, cam-follower mechanisms, etc. In this example one Cartesian function is used to model the contact between the tires and the "ground":

phpBB [video]


In this one, a polar function is used to model the cam-followers:

phpBB [video]


or these examples, in which three Cartesian scalar functions are used to calculate the inverse kinematics of robots:

phpBB [video]


phpBB [video]


These, along with 50 working examples of different mechanisms including both rigid and flexible bodies, have been uploaded to Gitlab...

Tutorials coming soon, although the workflow is basically the same as with the old version.

Let me know what you think of this new version.

Merry Christmas!
JamesLiu
Posts: 26
Joined: Sat Apr 28, 2018 6:23 am

Re: FreeCAD as pre-post processor for MBDyn

Post by JamesLiu »

Congratulations! Love to evaluate the new release.

Tutorials on scalar functions would be very helpful.
vm4dim
Posts: 129
Joined: Tue Nov 23, 2021 1:05 am

Re: FreeCAD as pre-post processor for MBDyn

Post by vm4dim »

This should work?
I wanted to create a static node from a simple cube (Part_Box) and get errors:

Code: Select all

File ".../structuralstaticnode.py", line 59, in __init__
    obj.addProperty("App::PropertyString","label","Structural static node","label",1).label = baseBody.label    

'PrimitivePy' object has no attribute 'label'
Current: = baseBody.label
https://gitlab.com/josegegas/freecad-mb ... ode.py#L59

Previously: = baseBody.Label
https://gitlab.com/josegegas/freecad-mb ... ode.py#L86

OS: Debian GNU/Linux bookworm/sid
Word size of FreeCAD: 64-bit
Version: 0.20.26800 (Git)
Build type: Unknown
Branch: (HEAD detached at fd7735d0)
Hash: fd7735d035425f6abaf5f84ba48be4fb8208188e
Python version: 3.9.9
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.6.0
Locale: Russian/Russia (ru_RU)
josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

vm4dim wrote: Thu Dec 30, 2021 5:50 pm This should work?
I wanted to create a static node from a simple cube (Part_Box) and get errors:

Code: Select all

File ".../structuralstaticnode.py", line 59, in __init__
    obj.addProperty("App::PropertyString","label","Structural static node","label",1).label = baseBody.label    

'PrimitivePy' object has no attribute 'label'
Current: = baseBody.label
https://gitlab.com/josegegas/freecad-mb ... ode.py#L59

Previously: = baseBody.Label
https://gitlab.com/josegegas/freecad-mb ... ode.py#L86

OS: Debian GNU/Linux bookworm/sid
Word size of FreeCAD: 64-bit
Version: 0.20.26800 (Git)
Build type: Unknown
Branch: (HEAD detached at fd7735d0)
Hash: fd7735d035425f6abaf5f84ba48be4fb8208188e
Python version: 3.9.9
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.6.0
Locale: Russian/Russia (ru_RU)
Hello. To create a static node you first have to create what I call a "static body". I know "static bodies" do not exist in the MBD model, but I created them simply as s way to visualize the motion of static nodes. A static body is simply a massless body that will move as its static node during the animation.

The process is as follows:

1.- Select any solid object, in this case your cube.
2.- Click on "static body", a "static body" will be created.
3.- Select the new static body in the tree view, hold control, and select any piece of geometry belonging to the same body or to any other static or rigid body. It can be an edge, arc or face. This piece of geometry can then be used to attach the node to it, changing the node's "attachment mode" property. Or you can simply leave the node at the center of mass of it's body.
4.- Click on "static node" to create the static node...

I have created a quick and simple tutorial to simulate a pendulum from scratch. Have a look at how to add the static body and node:

phpBB [video]


Hope this helps...

Let me know how it goes.
vm4dim
Posts: 129
Joined: Tue Nov 23, 2021 1:05 am

Re: FreeCAD as pre-post processor for MBDyn

Post by vm4dim »

josegegas wrote: Wed Jan 05, 2022 3:00 am I have created a quick and simple tutorial to simulate a pendulum from scratch. Have a look at how to add the static body and node:

Hope this helps...
Thanks

I get other error.

Code: Select all

 File ".../dummybody.py", line 56, in __init__
    obj.addProperty("App::PropertyDistance","absolute center of mass X","Absolute center of mass","absolute center of mass X",1).absolute_center_of_mass_X = cmx

Invalid property name 'absolute center of mass X'
This property name contains a space:
https://gitlab.com/josegegas/freecad-mb ... ody.py#L56


If any property name contains a space, I get error.

Code: Select all

>>> App.newDocument()
>>> obj = App.ActiveDocument.addObject("Part::Box","BoxTest")
>>> obj.addProperty("App::PropertyDistance","X Y Z")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
RuntimeError: Invalid property name 'X Y Z'

It seems to work for you.

This must be error since rev: 26446 https://github.com/FreeCAD/FreeCAD/comm ... 27332fe819
vm4dim
Posts: 129
Joined: Tue Nov 23, 2021 1:05 am

Re: FreeCAD as pre-post processor for MBDyn

Post by vm4dim »

I set config 'BaseApp/Preferences/Document/AutoNameDynamicProperty'.
Now Static Body are successfully created.
JamesLiu
Posts: 26
Joined: Sat Apr 28, 2018 6:23 am

Re: FreeCAD as pre-post processor for MBDyn

Post by JamesLiu »

vm4dim wrote: Wed Jan 05, 2022 2:35 pm I set config 'BaseApp/Preferences/Document/AutoNameDynamicProperty'.
Now Static Body are successfully created.
Thanks! It works properly now on 0.20 weekly build, but not on 0.19.x.
Post Reply