FreeCAD as pre-post processor for MBDyn

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
mfasano
Posts: 88
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby mfasano » Wed Apr 15, 2020 11:49 pm

I added a new branch for my MBDyn pre-processor. It is called asm4. It creates an MBDyn input file from a FreeCAD model created with assembly4. I thought it would make it easier to set up the MBDyn elements with it. I am not sure I am calculating the orientation matraces right. They work for my test case, but I'm not sure it will work in the general case. I will need to make more tests. My concern is the the euler angles for FreeCAD are in ZY'X'' order and I make the MBDyn input file orientation matraces in the XY'Z'' order. I am afraid you can't switch the order in general.

Here is the code.
https://github.com/mfasano727/MBDynFCwb/tree/asm4

There are a lot less input fields with this version. I was thinking Assembly 4 would be good because there is no constraint solver. The contraints are alignments of local coordinate systems(LCS). I use the LCS to calculate the position and orientation matraces of the MBDyn elements. I will try to write instructions for this soon.

For my next trick I would like to add FeaturePython App::PropertyLink to the FreeCAD object associated with the MBDyn elements. Then, as the FreeCAD model changes, the MBDyn scripted objects can change with it. This may be a little ambitious.

I really need to get post processing done. I will make that a priority.
User avatar
mfasano
Posts: 88
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby mfasano » Sun May 03, 2020 1:50 pm

I added post processing to the ASM4 branch to my code. There would not be too many changes to add the post processing to the branch that does not use Assembly4, but I like Assembly4. I fixed the problem I had with orientation matraces of the joints by switching to 2 vector instead of Euler angles description. I will be writing instructions for the ASM4 branch very soon.

Here are some videos of pendulums I made. They seem to be in slow motion; I will need to look in to that.

phpBB [video]


phpBB [video]
HoWil
Posts: 1191
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: FreeCAD as pre-post procesor for MBDyn

Postby HoWil » Sun May 03, 2020 7:29 pm

Looks very nice.
How difficult is this to achieve? Is this hardcoded an to what extend?
Thanks in advance.
User avatar
mfasano
Posts: 88
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby mfasano » Mon May 04, 2020 9:33 am

It is simple once you have an assembly4 model. There are few input fields you need to type. I only have code for revolute joints so it is very limited, but FreeCAD and MBDyn are comprehensive. I may try a 4-bar linkage as an example next. I should have instructions soon.
T-Garnier
Posts: 2
Joined: Sat Jun 27, 2020 5:30 am

Re: FreeCAD as pre-post procesor for MBDyn

Postby T-Garnier » Sat Jun 27, 2020 6:27 am

Hello mfasano,

I am interested to help in the development of the pre/post procesor mbdyn/freeCAD if the project is still ongoing. Did you get in contact with the mbdyn developer team? if yes, is the project "validated"? Who could I help you on the project?

Regards,
Thomas
User avatar
mfasano
Posts: 88
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby mfasano » Sun Jun 28, 2020 7:34 pm

T-Garnier wrote:
Sat Jun 27, 2020 6:27 am
I am interested to help in the development of the pre/post procesor mbdyn/freeCAD if the project is still ongoing. Did you get in contact with the mbdyn developer team? if yes, is the project "validated"? Who could I help you on the project?
I am still working on it. I have created code to add the total joint and the total pin joint. the total joint is like a joint for all seasons. you should be able to simulate any mechanism with rigid bodies. I tried to model a slide crank mechanism but couldn't get it to work. I did get the pendulums to work with the total joints. I am now trying to do the slide crank with the more traditional inline and prismatic joints.

I have been in contact with Andrea Zanoni. He is working on a library of python code for preprocessing as well as FreeCAD . I started using some of that, but find it easier to write from scratch. I was hoping he would get a Google summer of code student to work on the FreeCad preprocessor, but it did not pan out. I have signed up for the MBDyn email list; asked them about the slide crank. They pointed out my model was over constrained and gave a couple of hints. I did not follow up with them.

I will put what I have on the ASM4 branch of my Github repo soon, even though I can't get the new stuff working. I will post here when have done that. I of course welcome any help given.
User avatar
mfasano
Posts: 88
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby mfasano » Sat Jul 04, 2020 1:50 pm

I put what I have on the asm4 branch
https://github.com/mfasano727/MBDynFCwb/tree/asm4

I added the total joint and the total pin joint. I will add instructions for those soon. The commands for the axial rotation and the ramp drive caller do not work. I am working on an inline joint and a prismatic joint.

There are many ways other than add more MBDyn elements to improve the workbench.
Here is a list, not in order of importance.

make the workbench compatible with the new namespace workbench.
add idiot proof er uh exception handling (am I dating myself?) like making line editors in pyside only accept numbers where applicable.
make it so you can run MBDyn directly from FreeCAD. This was discussed on page 4 of this thread, so it shouldn't be hard.
include more in the post processing, like force and torque indicators. code for graphing velocity, acceleration etc.
add names to the MBDyn scripted objects and use them as variables in the input file to make it more readable
write/film a tutorial to show how to use the workbench.
use Propertylink in the MBDyn objects so they can change with the FreeCAD model.
test, test, test
User avatar
mfasano
Posts: 88
Joined: Wed Apr 11, 2018 12:31 pm

Re: FreeCAD as pre-post processor for MBDyn

Postby mfasano » Wed Jul 15, 2020 11:12 am

I added instructions for the total joint and total pin joint in the wiki page for the asm4 branch. I will be writing a step by step instucyoins soon.

I am including a pendulum with revolute hinge joints FreeCAD file and MBDyn input file generated. I am also including a pendulum with total joints FreeCAD file and MBDyn input file generated.

I hope to have a slide crank model with inline and prismatic joints soon.
Attachments
pend_part_as4_tot.FCStd
(16.52 KiB) Downloaded 17 times
pend_part_as4.FCStd
(15.81 KiB) Downloaded 19 times
input_tot1.txt
(3.09 KiB) Downloaded 20 times
input_AS4_9.txt
(2.19 KiB) Downloaded 18 times
T-Garnier
Posts: 2
Joined: Sat Jun 27, 2020 5:30 am

Re: FreeCAD as pre-post processor for MBDyn

Postby T-Garnier » Mon Jul 27, 2020 2:48 am

Hi everyone,

You have now the possibility to run mbdyn directly in Freecad.
Note:
- Windows + binary: test
- Windowes + windows subsystem for linux: does not work ATM
- Linux: to be tested
- Mac: to be tested

To run an analysis you have to follow the next steps:

- (To Be done Once) Setup the solver:
* go to the preferences tool (tools / preferences... / mbdyn)
* in the solver tab, select a name for the solver (must be ASCII, without space name) select the binary you want to associate with it and add the solver (+ button)
* select the default solver
* apply changes or click ok

note: I let the possibility to have multiple mbdyn binaries in case you have different version / configuration of mbdyn.
note: preferences in the general tab are not used ATM except the editor binary (used for editing the input file and review the log file).

- Run the analysis:
* click on the "write" command
* Fill all the necessary field.
* (Mandatory) write + edit the file before the run
* run the simulation.

Actually no information is sent back when the simulation is finished.

The implementation is quite straightforward an use the subprocess.Popen. I will maybe switch to Qt.QProcess has it send signal to the ui and gives information on the calculation status (end of process, real time log information). (From what I saw on the FEM workbench, it could be done with subprocess and thread, but it seems more complex)
louisgag
Posts: 37
Joined: Fri Jan 17, 2020 9:59 am

Re: FreeCAD as pre-post processor for MBDyn

Postby louisgag » Tue Jul 28, 2020 7:55 pm

@mfasano and @T-Garnier
I've tried the addon quickly, it's a nice start.
I would recommend you provide a step-by-step example.
This will allow more people to try it and give feedback or code... perhaps you'll get some important tips.
I for myself find it somewhat difficult to understand even the simplest task of creating a body.
I don't have much experience with assembly4, but probably many users don't since it's still only in the development version.