## add new function to fem module

About the development of the FEM module/workbench.

Moderator: bernd

bernd
Posts: 9862
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: add new function to fem module

makkemal wrote:The analysis works for me.
I see selection has not been added to preferences and result objects yet
my 10c worth
@michael Do you know what exact are the results of the ccx buckle analysis ? Are there any special results we should read in additionaly ?
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

### Re: add new function to fem module

So I updated the example to actually buckle
For extra outputs it is in the manual
"Buckling leads to an eigenvalue problem whose lowest eigenvalue is the scalar the load in the buckling step has to be multiplied with to get the buckling load. Thus, generally only the lowest eigenvalue is needed. This value is also called the buckling factor and it is always stored in the .dat file."
Calculating the buckling factors and buckling modes:
sigma=1.000000,d[0]=1.104418
no convergence; new iteration
Factoring the system of equations using the symmetric spooles solver
Using up to 5 cpu(s) for spooles.
Calculating the buckling factors and buckling modes:
sigma=0.002209,d[0]=0.002774
no convergence; new iteration
Factoring the system of equations using the symmetric spooles solver
Using up to 5 cpu(s) for spooles.
Calculating the buckling factors and buckling modes:
sigma=0.000006,d[0]=0.004817
Using up to 5 cpu(s) for the stress calculation.
Job finished
buckle.fcstd
Jee-Bee
Posts: 2012
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: add new function to fem module

Sorry i was busy last 2 days so didn't had time to give some comments...
including figure out the difference in the buckling modes.
the only result was that i figured out that FreeCAD don't import the values of the buckling modes(not the shapes but at which point) . As far as i could test FreeCAD doesn't import the eigenmodes from the frequency either (again only she stress displacement etc but not at which frequency)
Jee-Bee
Posts: 2012
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: add new function to fem module

I have broke something in Frequency analysis.

I had changed EignemodeCount to EigenmodeNumber. and everything went well from Buckling. but somehow somewhere i get an error while reading frequency values.

Changed script from buckling:

Code: Select all

``````# new document
doc = App.newDocument("CalculiX_Frequency_Example3D")
#
# part
import Part
beam_obj.Height = beam_obj.Width = 100
beam_obj.Length = 1200
#
# see how our part looks like
#
# analysis
import FemAnalysis
analysis_object = FemAnalysis.makeFemAnalysis('Analysis')
#
# solver
import FemSolverCalculix
solver_object = FemSolverCalculix.makeFemSolverCalculix('CalculiX')
solver_object.AnalysisType = 'frequency'
solver_object.GeometricalNonlinearity = 'linear'
#solver_object.Accuracy = 0.01
solver_object.EigenmodesNumber = 6
solver_object.MatrixSolverType = 'default'
solver_object.IterationsControlParameterTimeUse = False
doc.Analysis.Member = doc.Analysis.Member + [solver_object]
#
# material
import FemMaterial
#import MechanicalMaterial
material_object = FemMaterial.makeFemMaterial('MechanicalMaterial')
#material_object = MechanicalMaterial.makeMechanicalMaterial('MechanicalMaterial')
mat = material_object.Material
mat['Name'] = "Calculix-Steel"
mat['YoungsModulus'] = "210000 MPa"
mat['PoissonRatio'] = "0.30"
mat['Density'] = "7900 kg/m^3"
material_object.Material = mat
doc.Analysis.Member = doc.Analysis.Member + [material_object]
#
# fixed_constraint
fixed_constraint.References = [(doc.Beam, "Face1")]
doc.Analysis.Member = doc.Analysis.Member + [fixed_constraint]
#
# gmsh_mesh

## From here forum example
import FemMeshGmsh, FemGmshTools
# make an initial FEM mesh
femmesh_obj_gmsh = FemMeshGmsh.makeFemMeshGmsh('Beam_Mesh')
femmesh_obj_gmsh.Part = beam_obj
App.ActiveDocument.recompute()
gmsh_mesh = FemGmshTools.FemGmshTools(femmesh_obj_gmsh)
error = gmsh_mesh.create_mesh()
print error
## to here
doc.Analysis.Member = doc.Analysis.Member + [femmesh_obj_gmsh]
#
# recompute
doc.recompute()
#
# run the analysis
import FemGui
import FemToolsCcx
fea = FemToolsCcx.FemToolsCcx()
fea.update_objects()
message = fea.check_prerequisites()
if not message:
fea.reset_all()
fea.run()
else:
FreeCAD.Console.PrintError("Houston, we have a problem! {}\n".format(message))  # in report view
print("Houston, we have a problem! {}\n".format(message))  # in python console
#
# run the analysis
for m in analysis_object.Member:
if m.isDerivedFrom('Fem::FemResultObject'):
result_object = m
break
#
femmesh_obj.ViewObject.setNodeDisplacementByVectors(result_object.NodeNumbers, result_object.DisplacementVectors)
femmesh_obj.ViewObject.applyDisplacement(10)
#
``````
error:

Code: Select all

``````We gone start GMSH FEM mesh run!
Part to mesh: Name --> Beam,  Label --> Beam, ShapeType --> Solid
CharacteristicLengthMax: 1e+22
CharacteristicLengthMin: 0.0
ElementOrder: 2
ElementDimension: 3
/tmp/Beam_Geometry.brep
/tmp/Beam_Mesh_TmpGmsh.unv
/tmp/shape2mesh.geo
/usr/bin/gmsh
No mesh group objects.
No anlysis members for group meshing.
{}
No mesh regions.
{}
{}
The Part should have a pretty new FEM mesh!

FemTools.setup_working_dir()  -->  self.working_dir = /home/jee-bee/Documents/FC_work/
Houston, we have a problem! Frequency analysis: Solver has no EigenmodesCount.

Houston, we have a problem! Frequency analysis: Solver has no EigenmodesCount.
``````
I can figure out where EigenmodeCount is used more... At least not in ccxDatReader.py
anybody an idea?
bernd
Posts: 9862
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: add new function to fem module

Code: Select all

``````\$
\$ git checkout remotes/jee-bee/bucklebranch
Note: checking out 'remotes/jee-bee/bucklebranch'.
...
HEAD ist jetzt bei ed9e707... few bug fixes and typos
\$
\$ grep -r EigenmodesCount
src/Mod/Fem/FemTools.py:                elif not hasattr(self.solver, "EigenmodesCount"):
src/Mod/Fem/FemTools.py:                    message += "Frequency analysis: Solver has no EigenmodesCount.\n"
src/Mod/Fem/Gui/DlgSettingsFemCcx.ui:             <cstring>EigenmodesCount</cstring>
src/Mod/Fem/TestFem.py:        self.solver_object.EigenmodesCount = 10
src/Mod/Fem/TestFem.py:    fea.solver.EigenmodesCount = 1  # we should only have one result object
\$
``````
Does this helps ? There are still a few in your bucklebranch. I assume the one which produces the error is in the "def check_prerequisites(self):" of FemTools but I did not have a closer look.
Jee-Bee
Posts: 2012
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: add new function to fem module

I definitely need to learn the grep function it looks quite handy!!
Thanks
Jee-Bee
Posts: 2012
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: add new function to fem module

I was compare the results between Buckle and Frequency calculations.
I saw that for the frequency calculations the eigenmodes are given for each mode. For buckle this is empty. Can i replcae the eigenmode with the buckling factor? Since the buckling factor is not in Hz but a relation between the given force and and the force when buckling occured?
Screen Shot 2017-02-11 at 14.55.41.png (41.26 KiB) Viewed 1000 times
Screen Shot 2017-02-11 at 14.56.12.png (37.87 KiB) Viewed 1000 times
Jee-Bee
Posts: 2012
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: add new function to fem module

I have tried to edit the ccx result read so it reads the buckling factor as Frequency... But the eigenvalues stays all zeros... so there is something wrong. but can't figure out what. can somebody check?
Jee-Bee
Posts: 2012
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: add new function to fem module

(I see the name in current version is changed... that means that i have to rebase and some way it don't give the result i want... i have to find out later...)
Jee-Bee
Posts: 2012
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: add new function to fem module

I have searched for eigenmode for checking where it could be used more and what do i need change to get my addition work...
I hope that i don't need to change the FemResultObject.cpp... I don't have experience with c++

Code: Select all

``````USER@Picasso:~/FCdev/FreeCAD/src/Mod/Fem\$ grep -r eigenmode
FemToolsCcx.py:                        if m.Eigenmode == mf['eigenmode']:
App/FemResultObject.cpp:    ADD_PROPERTY_TYPE(Eigenmode,(0), "Fem",Prop_None,"Number of the eigenmode");
App/FemResultObject.cpp:    ADD_PROPERTY_TYPE(EigenmodeFrequency,(0), "Fem",Prop_None,"Frequency of the eigenmode");
ccxFrdReader.py:        # Check if we found new eigenmode
ccxFrdReader.py:                results_name = result_name_prefix + 'mode_' + str(eigenmode_number) + '_results'
TestFem.py:    stats_frequency = []  # since we set eigenmodeno. we only have one result object so we are fine
Gui/DlgSettingsFemCcx.ui:           <widget class="Gui::PrefSpinBox" name="sb_eigenmode_number">
Gui/DlgSettingsFemCcx.ui:           <widget class="QLabel" name="l_eigenmode_number">
Gui/DlgSettingsFemCcx.ui:           <widget class="QLabel" name="l_eigenmode_high_limit">
Gui/DlgSettingsFemCcx.ui:           <widget class="Gui::PrefDoubleSpinBox" name="dsb_eigenmode_high_limit">
Gui/DlgSettingsFemCcx.ui:           <widget class="QLabel" name="l_eigenmode_low_limit">
Gui/DlgSettingsFemCcx.ui:           <widget class="Gui::PrefDoubleSpinBox" name="dsb_eigenmode_low_limit">
Gui/DlgSettingsFemCcxImp.cpp:    sb_eigenmode_number->onSave();
Gui/DlgSettingsFemCcxImp.cpp:    dsb_eigenmode_high_limit->onSave();
Gui/DlgSettingsFemCcxImp.cpp:    dsb_eigenmode_low_limit->onSave();
Gui/DlgSettingsFemCcxImp.cpp:    sb_eigenmode_number->onRestore();
Gui/DlgSettingsFemCcxImp.cpp:    dsb_eigenmode_high_limit->onRestore();
Gui/DlgSettingsFemCcxImp.cpp:    dsb_eigenmode_low_limit->onRestore();