add new function to fem module

About the development of the FEM module/workbench.

Moderator: bernd

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

Re: add new function to fem module

Postby bernd » Wed Feb 08, 2017 11:59 am

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 ?
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: add new function to fem module

Postby makkemal » Wed Feb 08, 2017 1:24 pm

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
(154.28 KiB) Downloaded 16 times
Jee-Bee
Posts: 1940
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Postby Jee-Bee » Wed Feb 08, 2017 4:11 pm

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: 1940
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Postby Jee-Bee » Fri Feb 10, 2017 10:41 am

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 = doc.addObject('Part::Box', 'Beam')
beam_obj.Height = beam_obj.Width = 100
beam_obj.Length = 1200
#
# see how our part looks like
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
#
# 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.SteadyState = True
#solver_object.Accuracy = 0.01
solver_object.EigenmodesNumber = 6
solver_object.ThermoMechSteadyState = True
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 = doc.addObject("Fem::ConstraintFixed", "FemConstraintFixed")
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
FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.Analysis)
import FemToolsCcx
fea = FemToolsCcx.FemToolsCcx()
fea.update_objects()
message = fea.check_prerequisites()
if not message:
    fea.reset_all()
    fea.run()
    fea.load_results()
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?
User avatar
bernd
Posts: 8205
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: add new function to fem module

Postby bernd » Fri Feb 10, 2017 3:46 pm

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: 1940
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Postby Jee-Bee » Fri Feb 10, 2017 5:41 pm

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

Re: add new function to fem module

Postby Jee-Bee » Sat Feb 11, 2017 2:42 pm

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
Screen Shot 2017-02-11 at 14.55.41.png (41.26 KiB) Viewed 907 times
Screen Shot 2017-02-11 at 14.56.12.png
Screen Shot 2017-02-11 at 14.56.12.png (37.87 KiB) Viewed 907 times
Jee-Bee
Posts: 1940
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Postby Jee-Bee » Sun Feb 19, 2017 9:17 pm

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?
seehttps://github.com/Jee-Bee/FreeCAD/tree/bucklebranch for branch
Jee-Bee
Posts: 1940
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Postby Jee-Bee » Mon Feb 20, 2017 8:13 pm

more specific: https://github.com/Jee-Bee/FreeCAD/blob ... der.py#L50

(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: 1940
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: add new function to fem module

Postby Jee-Bee » Tue Feb 21, 2017 5:05 pm

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:    eigenmode = 0
ccxFrdReader.py:        # Check if we found new eigenmode
ccxFrdReader.py:            eigenmode = int(line[30:36])
ccxFrdReader.py:                mode_results['number'] = eigenmode
ccxFrdReader.py:                eigenmode = 0
ccxFrdReader.py:                mode_results['number'] = eigenmode
ccxFrdReader.py:                eigenmode = 0
ccxFrdReader.py:            eigenmode_number = result_set['number']
ccxFrdReader.py:            if eigenmode_number > 0:
ccxFrdReader.py:                results_name = result_name_prefix + 'mode_' + str(eigenmode_number) + '_results'
ccxFrdReader.py:            if eigenmode_number > 0:
ccxFrdReader.py:                if eigenmode_number > 0:
ccxFrdReader.py:                    results.Eigenmode = eigenmode_number
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();
ccxDatReader.py:                m['eigenmode'] = mode
ccxDatReader.py:                m['eigenmode'] = mode
_FemSolverCalculix.py:        obj.addProperty("App::PropertyFloatConstraint", "EigenmodeLowLimit", "Fem", "Low frequency limit for eigenmode calculations")
_FemSolverCalculix.py:        obj.addProperty("App::PropertyFloatConstraint", "EigenmodeHighLimit", "Fem", "High frequency limit for eigenmode calculations")