add new function to fem module

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

add new function to fem module

Post by Jee-Bee »

I want (finaly) add some functionality to FreeCAD FEM module.
To start not to difficult i want add a buckling function...

Most of what i need goes quite smooth till now. I have to add the new object properties for this function.
This is where the trouble comes in...

I have this example code from https://github.com/FreeCAD/FreeCAD/blob ... alculix.py

Code: Select all

        obj.addProperty("App::PropertyFloatConstraint", "EigenmodeLowLimit", "Fem", "Low frequency limit for eigenmode calculations")
        ell = ccx_prefs.GetFloat("EigenmodeLowLimit", 0.0)
        obj.EigenmodeLowLimit = (ell, 0.0, 1000000.0, 10000.0)
my question is ... what does this part of code does.

second question buckling modes uses also number of modes. but i don't think it is a good idea to reuse the modes of frequency...
  • Number of buckling factors desired (usually 1).
  • Accuracy desired (default: 0.01).
  • # Lanczos vectors calculated in each iteration (default: 4 * #eigenvalues).
  • Maximum # of iterations (default: 1000).
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Post by Jee-Bee »

where does dsb; sb and cb stand for in the FEM ccx preference pane?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: add new function to fem module

Post by bernd »

Jee-Bee wrote:I want (finaly) add some functionality to FreeCAD FEM module.
To start not to difficult i want add a buckling function...
very good idea :)
Jee-Bee wrote:I have this example code from https://github.com/FreeCAD/FreeCAD/blob ... alculix.py

Code: Select all

        obj.addProperty("App::PropertyFloatConstraint", "EigenmodeLowLimit", "Fem", "Low frequency limit for eigenmode calculations")
        ell = ccx_prefs.GetFloat("EigenmodeLowLimit", 0.0)
        obj.EigenmodeLowLimit = (ell, 0.0, 1000000.0, 10000.0)
my question is ... what does this part of code does.
just try it in python console ... ;) it adds a new property to the plain solver object and reads the CalculiX prefs for this property and sets the property with the read property

code

Code: Select all

obj = FreeCAD.ActiveDocument.addObject("Fem::FemSolverObjectPython", 'MyOwnSolverType')
obj.PropertiesList  # select new solver, check propery editor
obj.addProperty("App::PropertyFloatConstraint", "EigenmodeLowLimit", "Fem", "Low frequency limit for eigenmode calculations")
obj.PropertiesList  # select new solver, check propery editor
obj.EigenmodeLowLimit  # 0.0

ccx_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Ccx")
ell = ccx_prefs.GetFloat("EigenmodeLowLimit", 0.0)
obj.EigenmodeLowLimit = (ell, 0.0, 1000000.0, 10000.0)
obj.EigenmodeLowLimit  # depending on your Calculix FEM ccx_prefs
output

Code: Select all

>>> obj = FreeCAD.ActiveDocument.addObject("Fem::FemSolverObjectPython", 'MyOwnSolverType')
>>> obj.PropertiesList  # select new solver, check propery editor
['ExpressionEngine', 'Label', 'Proxy']
>>> obj.addProperty("App::PropertyFloatConstraint", "EigenmodeLowLimit", "Fem", "Low frequency limit for eigenmode calculations")
<Document object>
>>> obj.PropertiesList  # select new solver, check propery editor
['EigenmodeLowLimit', 'ExpressionEngine', 'Label', 'Proxy']
>>> obj.EigenmodeLowLimit  # 0.0
0.0
>>> 
>>> ccx_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Ccx")
>>> ell = ccx_prefs.GetFloat("EigenmodeLowLimit", 0.0)
>>> obj.EigenmodeLowLimit = (ell, 0.0, 1000000.0, 10000.0)
>>> obj.EigenmodeLowLimit  # depending on your Calculix FEM ccx_prefs
1.0
>>> 
Jee-Bee wrote:second question buckling modes uses also number of modes. but i don't think it is a good idea to reuse the modes of frequency...
Do they create the same parameter in the input file? If they do, I would use the once from frequency.
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Post by Jee-Bee »

bernd wrote:just try it in python console ... ;)
I shall remember that for next time!!
bernd wrote:
Jee-Bee wrote:second question buckling modes uses also number of modes. but i don't think it is a good idea to reuse the modes of frequency...
Do they create the same parameter in the input file? If they do, I would use the once from frequency.
Probably except that most of the time multiple eigen modus are required and just 1 ore maybe a few buckling factors/ modussen .
Edit buckling have also number of iterations.. i have to think about those...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: add new function to fem module

Post by bernd »

Jee-Bee wrote:Probably except that most of the time multiple eigen modus are required and just 1 ore maybe a few buckling factors/ modussen .
Edit buckling have also number of iterations..
If we have number of iterations I would reuse them same with eigen modes. One could add two solver, one for frequency and one for buckling both having different values for the same property.
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Post by Jee-Bee »

oke i didn't completly understand what you mean...
Screen Shot 2017-01-26 at 20.35.05.png
Screen Shot 2017-01-26 at 20.35.05.png (69.34 KiB) Viewed 5079 times
does this mean like in the figure that i have two preferences but stored in a single variable. or do you mean something else...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: add new function to fem module

Post by bernd »

How about another frame in the ui: frequency and buckling defaults:
Eigenmode number

BTW: the Sover property is called Eigenmode Count, we could adapt this name in preference dialog

Ahh the maximum number of iteration is twice too! From my point of view we should not use two FreeCAD properties for the same variable in ccx input file, just because it is another analysis type. Opinions of others are welcome in this regard!
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: add new function to fem module

Post by PrzemoF »

Maybe e need a "common section" to keep all common properties for different types of calculations?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: add new function to fem module

Post by bernd »

PrzemoF wrote:Maybe e need a "common section" to keep all common properties for different types of calculations?
good idea
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Post by Jee-Bee »

in this case should common exist out number of eigen modes and number of iterations
i think i can handle that...

but i think that for later (if more calculations are added) we should change the gui that it is more easy to show parameters and chanche them at creation...

Code: Select all

OS: macOS 10.15
Word size of FreeCAD: 64-bit
Version: 0.20.28647 (Git)
Build type: Release
Python 3.9.12, Qt 5.12.9, Coin 4.0.0, OCC 7.5.3
Locale: C/Default (C)
Last edited by Jee-Bee on Fri Apr 08, 2022 10:33 am, edited 1 time in total.
Post Reply