Animation of Mode Shapes after Frequency/vibration Analysis

About the development of the FEM module/workbench.

Moderator: bernd

mac_the_bike
Posts: 42
Joined: Sun Jun 30, 2019 12:56 pm

Animation of Mode Shapes after Frequency/vibration Analysis

Post by mac_the_bike »

I have been searching, amongst the FREECAD documentation, for a method to animate mode shapes after running CalculiX.

I couldn't find anything appropriate, although that doesn't mean there is nothing there.

The attached MACRO was written to animate mode shapes generated by CalculiX running within FREECAD.

Preliminary step is to download the 2 attachments, keeping the same names, "animate.py" and "animate.ui".

These are the steps used to generate the data to be animated, these are the usual steps:
  • click on "CalculiXccxTools"
  • select "Frequency"
  • select "Write .inp file"
  • select "Run CalculiX"
The figure shows the results of the analysis.

These are the steps to prepare for and perform the animation:
  • open "Macro" in the ToolBar(?).
  • select "Macros..." and choose "animate.py" and "execute". A widget "Animate" will be generated in a separate window.
  • click on a set of results "CalculiX_frequency_mode_7", for example. This panel must be visible for the animation to work, Note (1).
  • select "Abs displacement", for example.
  • click the radio button "Displacement/Show"
  • click on "Start Animation" in the widget.
The entries in the widget are:
  • "scale" - scale for the displacements, 1 to 999, this may be a problem if the displacements are very large/small before scaling.
  • "factor" - enter the value for the scale, this is linked to "scale"
  • "number of steps..." - the number of steps in 1 vibratory cycle, if this value is increased the apparent speed of the animation will slow down.
  • "steps/second" - the number of steps displayed per second, if this value is increased the animation will speed up.
  • "number of cycles" - the number of cycles in the animation.
  • "Start Animation" - starts the animation, this changes to "Stop Animation" during the animation.
Note(1) - if you click on "Results_mesh001", and start animation you may possibly be animating the wrong mode shape.
Note(2) - you can run this from the python console by entering:
from animate import mac
b = mac()
the last line will cause the window to be displayed. (Note that mac is not "Modal Assurance Criterion").

This set of steps is the only testing of the MACRO I have made.

By following these steps you should be able to animate the results from a static analysis, if you wish.

If this is the wrong place for this, will you move it to the correct one?

system:
ubuntu 18.04 LTS -- 64 bit
freecad: 0.18.3

Feel free to improve this code.
mac
Attachments
animate_results.png
animate_results.png (27.22 KiB) Viewed 4732 times
animate.py
(4.82 KiB) Downloaded 170 times
animate.ui
(5.32 KiB) Downloaded 149 times
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by galou_breizh »

mac_the_bike wrote:
Thanks a lot for this macro! Would it be actually possible that you publish it to the official FreeCAD macro repository, https://github.com/FreeCAD/FreeCAD-macros (according to the few criteria defined there)? There is no macro using a ui-file at runtime so far, you would be the first one, so that you macro will be used as an example!

Thanks a lot,
Gaël
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by Kunda1 »

galou_breizh wrote: Wed Sep 04, 2019 8:21 pm
mac_the_bike wrote:
Thanks a lot for this macro! Would it be actually possible that you publish it to the official FreeCAD macro repository, https://github.com/FreeCAD/FreeCAD-macros (according to the few criteria defined there)? There is no macro using a ui-file at runtime so far, you would be the first one, so that you macro will be used as an example!
:+1:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
mac_the_bike
Posts: 42
Joined: Sun Jun 30, 2019 12:56 pm

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by mac_the_bike »

Thanks. I will have a go at putting it on GITHUB.

Now the reason for this post:

I was modifying the code of the "UI" and I noticed that there is a bug in the python code, so I am reattaching the 2 files.
  • bug: the definition of "mesh_obj" was in the wrong place
  • The "factor" box will now take "real" numbers.
mac_the_bike
Attachments
animate.py
(5.79 KiB) Downloaded 161 times
animate.ui
(5.31 KiB) Downloaded 140 times
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by Kunda1 »

mac_the_bike wrote: Thu Sep 12, 2019 10:55 am
@mac_the_bike do you mind making a short screencast of this so it's easier for the devs and users to understand what you've done ?
bernd wrote:
@bernd have you seen this ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
mac_the_bike
Posts: 42
Joined: Sun Jun 30, 2019 12:56 pm

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by mac_the_bike »

Kunda1 wrote: Thu Sep 12, 2019 12:22 pm
mac_the_bike wrote: Thu Sep 12, 2019 10:55 am
@mac_the_bike do you mind making a short screencast of this so it's easier for the devs and users to understand what you've done ?
bernd wrote:
@bernd have you seen this ?
I have attached a screenshot of the UI.

All the input fields are integers apart from the "factor" which can be a "real" number less than 1.0; its maximum value is 999.
"scale" is an integer version of "factor" - you can use the scrollbar to set the scale but it will be an integer.

The animation calculations use the value of "factor".

mac_the_bike
Attachments
UI.png
UI.png (20.72 KiB) Viewed 4452 times
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by Kunda1 »

mac_the_bike wrote: Mon Sep 16, 2019 3:16 pm I have attached a screenshot of the UI.
Thanks for the screenshot.
galou_breizh wrote: Wed Sep 04, 2019 8:21 pm Thanks a lot for this macro! Would it be actually possible that you publish it to the official FreeCAD macro repository, https://github.com/FreeCAD/FreeCAD-macros (according to the few criteria defined there)? There is no macro using a ui-file at runtime so far, you would be the first one, so that you macro will be used as an example!

Thanks a lot,
Gaël
BTW, :point_up_2:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
EkaitzEsteban
Posts: 108
Joined: Wed Sep 12, 2018 1:31 pm

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by EkaitzEsteban »

Hello,

Thank you for sharing this macro.
I will test it...
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: Animation of Mode Shapes after Frequency/vibration Analysis

Post by galou_breizh »

The macro is now in the official repository under https://github.com/FreeCAD/FreeCAD-macr ... es.FCMacro.

Please submit any changes there from now on.

Thanks,
Gaël
Post Reply