FreeCAD as pre-post processor for MBDyn

About the development of the FEM module/workbench.

Moderator: bernd

abghrnjd
Posts: 43
Joined: Tue Dec 22, 2020 12:02 pm

Re: FreeCAD as pre-post processor for MBDyn

Post by abghrnjd »

josegegas wrote: Sat Jan 23, 2021 4:42 am It does not work well on 0.18. All the examples were created and tested on 0.19. I have just tried on a fresh Ubuntu 20.04 installation with the FreeCAD 0.19 AppImage and it worked. Same on Windows (FreeCAD_0.19.23578-Win-Conda_vc14.x-x86_64). On Windows is easier because one does not need to install MBDyn. Just download FreeCAD 0.19 and paste the workbench into the Mod folder.

I am still curious what may be happening. Do you mind trying with 0.19 and letting me know?
Here I attached the error with 0.19, After clicking ok, workbench is not active and its menu doesn't show up.
Attachments
0.19.jpg
0.19.jpg (18.64 KiB) Viewed 2236 times
stanislau
Posts: 18
Joined: Wed Nov 05, 2014 5:13 am

Re: FreeCAD as pre-post processor for MBDyn

Post by stanislau »

First of all,thank you josegegas.
I'm using Linux Mint 20.1 and i had some errors because mbdyn is installed in /usr/local/mbdyn .
With a symlink like

Code: Select all

sudo ln -s /usr/local/mbdyn /usr/bin 
the errors are gone,in case anyone is worth.
And now,a petition.Jose,can you write something about the workflow?I can run the examples,but i don't know how are they made.
josegegas
Posts: 255
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

stanislau wrote: Sat Jan 23, 2021 5:36 pm First of all,thank you josegegas.
I'm using Linux Mint 20.1 and i had some errors because mbdyn is installed in /usr/local/mbdyn .
With a symlink like

Code: Select all

sudo ln -s /usr/local/mbdyn /usr/bin 
the errors are gone,in case anyone is worth.
And now,a petition.Jose,can you write something about the workflow?I can run the examples,but i don't know how are they made.
I´m glad you were able to run the examples. Yes, I am working on a quick tutorial on how to perform the "free-falling body" simulation first. I think it will be a video tutorial, because it is way easier than a written document and because I am sure the workflow will change quickly as the workbench evolves...
josegegas
Posts: 255
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

abghrnjd wrote: Sat Jan 23, 2021 4:50 pm
josegegas wrote: Sat Jan 23, 2021 4:42 am It does not work well on 0.18. All the examples were created and tested on 0.19. I have just tried on a fresh Ubuntu 20.04 installation with the FreeCAD 0.19 AppImage and it worked. Same on Windows (FreeCAD_0.19.23578-Win-Conda_vc14.x-x86_64). On Windows is easier because one does not need to install MBDyn. Just download FreeCAD 0.19 and paste the workbench into the Mod folder.

I am still curious what may be happening. Do you mind trying with 0.19 and letting me know?
Here I attached the error with 0.19, After clicking ok, workbench is not active and its menu doesn't show up.
Sorry, I am not sure what may be happening. After searching for that error, it seems it has something to do with Matplotlib. I use Matplitlib to plot the simulation results, so it must work well for the workbench to work too.
anirudhnehra
Posts: 2
Joined: Fri May 15, 2020 2:50 pm

Re: FreeCAD as pre-post processor for MBDyn

Post by anirudhnehra »

Hi,
I also installed mbdyn on Desktop under mbdyn folder. I did the same thing: sudo ln -s /usr/bin/mbdyn /home/anirudh/Desktop/mbdyn

However, when I try to use Dynamics module testcases, i get the following error:
Running the Python command 'MBdyn_Run' failed:
Traceback (most recent call last):
File "/home/anirudh/.FreeCAD/Mod/freecad-mbdyn-dynamics-workbench-master/MBdynGui.py", line 380, in Activated
dyn.Run()
File "/home/anirudh/.FreeCAD/Mod/freecad-mbdyn-dynamics-workbench-master/dynamics.py", line 389, in Run
process = subprocess.Popen(["mbdyn", "-f", __dir1__+"/MBDynCase.mbd"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/tmp/.mount_FreeCADRGnNt/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/tmp/.mount_FreeCADRGnNt/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)

[Errno 13] Permission denied: 'mbdyn'

I have done sudo chmod 777 /home/anirudh/Desktop/mbdyn
many times and also tried changing permission manually of mbdyn folder as well as /usr/bin/mbdyn shortcut as root but does not work and I always get the same error. Please can someone tell what I am missing or why python cant seem to get permission.
I even tried modifying Dynamics.py line 389 from mbdyn to manually specify path to install location of mbdyn( /home/anirudh/Desktop/mbdyn) but get same error of permission denied)in module folder of this workbench in /home/anirudh/.FreeCAD folder.
Please help.

Thanks and Regards
Anirudh
stanislau
Posts: 18
Joined: Wed Nov 05, 2014 5:13 am

Re: FreeCAD as pre-post processor for MBDyn

Post by stanislau »

anirudhnehra wrote: Sun Jan 24, 2021 3:23 pm I also installed mbdyn on Desktop under mbdyn folder. I did the same thing: sudo ln -s /usr/bin/mbdyn /home/anirudh/Desktop/mbdyn
I think the order is wrong.If you installed mbdyn in /home/anirudh/Desktop/mbdyn you should do something like :

Code: Select all

sudo ln -s /home/anirudh/Desktop/mbdyn /usr/bin 
abghrnjd
Posts: 43
Joined: Tue Dec 22, 2020 12:02 pm

Re: FreeCAD as pre-post processor for MBDyn

Post by abghrnjd »

Sorry, I am not sure what may be happening. After searching for that error, it seems it has something to do with Matplotlib. I use Matplitlib to plot the simulation results, so it must work well for the workbench to work too.
I guess It says just the version is not compatible! isn't it because I'm using 0.18 and 0.19 on the same computer?
I think this problem can be solved easily but it's not easy for me. I didn't know anything about matplotlib's backend before this!
User avatar
mfasano
Posts: 122
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post processor for MBDyn

Post by mfasano »

josegegas wrote: Sat Jan 23, 2021 11:20 pm
I´m glad you were able to run the examples. Yes, I am working on a quick tutorial on how to perform the "free-falling body" simulation first. I think it will be a video tutorial, because it is way easier than a written document and because I am sure the workflow will change quickly as the workbench evolves...
It may be easier to edit a written document than a video if things change.

I did not look at you code this weekend. I will look at it later this week.
josegegas
Posts: 255
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

You may want to skip the animation algorithm (animation.py). I programmed it using python lists for the position and orintation data, as well as for the animation of the force vectors and the reaction forces. This works, but is too complicated. I am now migrating the animation.py file to numpy ndarrays instead of lists, so that I can use numpy methods. The code will be much shorter after I finish this...
josegegas
Posts: 255
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post processor for MBDyn

Post by josegegas »

This is an idea I´ve had in mind for a while. I have seen people struggle to write an assembly workbench for FreeCAD for years. There is assembly 2, but it only works for assembies with few parts and it often cannot solve relatively complicated assembies. Assembly 4 is a nice tool, but the lack of a solver capable of telling you how your assembly will move is a limitation. I think the reason for FreeCAD lacking an assembly workbench with the capabilities of most commercial packages is that it is quite complex to program/solve the ODEs needed. MBDyn does exactly this, it solves the assembly before performing the dynamic simulation. I think it may be worth to explore the idea of using MBDyn, or parts of it, to program an assemby workbench for FreeCAD. This workbench would generate nodes for each bodies and apply some constraints, then pass an input file for MBDyn to solve the assemby and may be even return the kinematics, so that the user can see an animated assembly, not a full MBD simmulation, but just the motion of the bodies. What do you think?
Post Reply