Getting started with FEM

FEM is a high­ly spe­cial­ized work­bench used to sim­u­late var­i­ous phys­i­cal phe­nom­e­na with the finite ele­ment method. The work­bench is very active­ly devel­oped, and thus it’s rec­om­mend­ed to always use the newest avail­able FreeCAD ver­sion (pos­si­bly up-to-date week­ly builds).

The FEM work­bench sup­ports two main solvers:

  • Cal­culiX is the best choice for mechan­i­cal (strength) and ther­mo­me­chan­i­cal calculations.
  • Elmer is the best choice for elec­tro­mag­net­ic, flow, and ther­mal, as well as cou­pled (mul­ti­physics) simulations.

Cal­culiX is pro­vid­ed with the Win­dows ver­sion, oth­er solvers require instal­la­tion.

Geometry preparation

Before pro­ceed­ing to run FEM sim­u­la­tions on your design, you should pre­pare the geom­e­try as described on the FEM Geom­e­try Prepa­ra­tion and Mesh­ing wiki page. This main­ly involves:

  • Choos­ing the right type of geom­e­try (ful­ly sol­id or sim­pli­fied to surface/line if it’s thin/slender). Cur­rent­ly, it’s not pos­si­ble to mix those types,
  • Sim­pli­fy­ing the geom­e­try: remov­ing unnec­es­sary small details, uti­liz­ing symmetry.
  • Com­bin­ing all parts of an assem­bly into a sin­gle object using Part boolean oper­a­tions (usu­al­ly Boolean frag­ments with Comp­sol­id mode + Com­pound fil­ter) — cur­rent­ly, mul­ti­ple mesh­es are not sup­port­ed, and a sin­gle object to mesh is needed.

For the pur­pose of this tuto­r­i­al, go to the Part work­bench, add Cube (Part_Box), and only change the Length prop­er­ty to 100 mm. We will use this geom­e­try to sim­u­late bend­ing and tor­sion of a can­tilever beam with a square cross-section.

Analysis container, meshing, and material assignment

After open­ing the FEM work­bench, you have to add an Analy­sis con­tain­er to acti­vate the grayed-out tools. This will also add the default solver’s object if set in the Pref­er­ences. Oth­er­wise, add the solver’s object man­u­al­ly. Here we will use CalculiX.

Now it’s time to mesh the geometry—divide it into finite ele­ments of sim­ple shapes. Two mesh­ers are available—Gmsh and Net­gen. You can choose whichev­er you want, but the lat­ter may be trick­i­er to install. Gmsh is typ­i­cal­ly includ­ed with FreeCAD.

Select the sin­gle geom­e­try object (Cube in this case) and click on the prop­er mesh­er button:

Now you just have to spec­i­fy the max­i­mum ele­ment size (use 2 mm in this case) and click Apply, then OK.

You can local­ly refine mesh­es (the FEM_MeshRegion com­mand) when you need to increase the accu­ra­cy of the results in some crit­i­cal loca­tions, such as around holes.

It’s also nec­es­sary to assign material(s).

Select Sol­id Mate­r­i­al (yel­low but­ton next to New Analy­sis) and pick one from the list. Here, select “Cal­culiX-Steel”.

Option­al­ly, you can use the task pan­el to change the prop­er­ties used in analy­ses. Mechan­i­cal sim­u­la­tions need Young’s mod­u­lus, Poisson’s ratio, and den­si­ty (only for fre­quen­cy cal­cu­la­tions or gravity/centrifugal force loads). Leav­ing a mate­r­i­al with no geom­e­try ref­er­ence select­ed means that it will be applied to all geom­e­try regions with­out mate­r­i­al assignments.

To account for per­ma­nent (non-elas­tic) defor­ma­tion, you can add a Non-Lin­ear Mechan­i­cal Mate­r­i­al object to the exist­ing Mate­ri­al­Sol­id and define plas­tic­i­ty using points from the material’s stress-strain curve spec­i­fied accord­ing to CalculiX’s syntax.

Sim­u­la­tions with sur­face geome­tries (shell or 2D ele­ments) also require thick­ness def­i­n­i­tion (the FEM_ElementGeometry2D tool), while for line geome­tries (beam ele­ments), you need to define a pro­file (the FEM_ElementGeometry1D tool).

Boundary conditions and loads

Sta­t­ic sim­u­la­tions require bound­ary con­di­tions (sup­ports) suf­fi­cient for sta­t­ic equi­lib­ri­um. In most cas­es, they are applied as a Fixed Bound­ary Con­di­tion or a Dis­place­ment Bound­ary Con­di­tion. The first one restrains move­ment in all direc­tions, while the sec­ond one lets you select the direc­tions (degrees of free­dom) and dis­place­ment val­ues (0 means fix, non-zero val­ues enforce motion). Keep in mind that rota­tions can be con­trolled only for shell and beam elements.

Some­times it’s nec­es­sary to spec­i­fy bound­ary con­di­tions (or force loads) in cylin­dri­cal coor­di­nates. After that, you can use the local coor­di­nate system.

In this case, you just have to fix one square face of the beam.

There are sev­er­al types of loads available:

  • Force: applies force in N in the spec­i­fied direction
  • Pres­sure: applies pres­sure in Pa in the nor­mal direction
  • Cen­trifu­gal force: applies cen­trifu­gal force to sim­u­late the load to which parts rotat­ing with a spec­i­fied fre­quen­cy are subjected
  • Grav­i­ty (self-weight): applies grav­i­ta­tion­al accel­er­a­tion to account for the weight of the mod­el (if it’s significant)

For this tuto­r­i­al, fol­low these steps:

  1. Add the Force load and set it to 200 N.
  2. Select the square face of the beam oppo­site to the one with the Fixed bound­ary condition.
  3. Select a ver­ti­cal edge, and click on Direc­tion to change the direc­tion in which the force acts to fol­low that edge.
  4. Invert it by check­ing the Reverse direc­tion box at the bottom.

In the case of assem­blies, you may have to define tie con­straints (per­fect­ly bond­ed sur­face pairs) or con­tact (sur­face pairs where sur­faces may press against or slide on each other).

There are also sev­er­al bound­ary con­di­tions and loads for ther­mal (ini­tial tem­per­a­ture, pre­scribed tem­per­a­ture, heat flux, and body heat source) and elec­tro­mag­net­ic analy­ses, but let’s skip those for now.

Running an analysis and post-processing the results

If you need to change the analy­sis type or some solver set­tings, select the Cal­culiX solver’s object in the tree and use the Prop­er­ty view to access the appro­pri­ate Data prop­er­ties. Many analy­sis fea­tures also have addi­tion­al options in their Prop­er­ty view.

When every­thing is defined, just dou­ble-click on the solver’s object in the tree and click Apply. Or Write .inp File and then Run Cal­culiX if you have an old­er Cal­culiX solver imple­men­ta­tion enabled (“Result object: Pipeline only” Cal­culiX pref­er­ence unchecked in FreeCAD 1.1). When it com­pletes, close the task pan­el and check the results.

Old­er Cal­culiX solver gen­er­ates CCX_Results objects that don’t have a leg­end and require dou­ble-click­ing on them to dis­play the results, but offer quick insight into min­i­mum and max­i­mum val­ues of the select­ed out­puts. Both solvers also gen­er­ate results pipeline objects. Those have a col­or leg­end and show the results all the time if visible. 

Note that the old­er ccx solver has dis­place­ments in meters and stress­es in Pas­cals in its pipelines, while the refac­tored one uses more con­ve­nient mm and MPa units, respectively.

Here, do the following:

  • If you have the old­er ccx solver enabled, dou­ble-click on CCX_Results, select Dis­place­ment Z, and notice the min­i­mum val­ue in the task panel.
  • If you have the refac­tored ccx solver enabled, dou­ble-click on the Solver­Cal­culiXRe­sult pipeline object, make sure Field is set to Dis­place­ment and Com­po­nent to Mag­ni­tude or Z, and notice the max­i­mum (for Mag­ni­tude) or min­i­mum (for Z) val­ue on the col­or legend.

The dis­place­ment should be around 0.381 mm, accord­ing to hand calculations.

You can also select the results pipeline and add the Warp fil­ter to visu­al­ize the defor­ma­tion with a giv­en scale fac­tor (or use the slid­er in CCX_Results). Oth­er fil­ter types (e.g., for sec­tion cuts or prob­ing results at the select­ed points) are also available.

Rerunning the simulation with torsion

Before fin­ish­ing this basic tuto­r­i­al, let’s go back to the avail­able analy­sis fea­tures and dis­cuss the Rigid body con­straint short­ly. It was added in FreeCAD 1.0 and can be very use­ful since it trans­fers the spec­i­fied force, moment, or displacement/rotation bound­ary con­di­tion from one ref­er­ence point to the select­ed region of the mod­el (usu­al­ly a face).

The ref­er­ence point’s coor­di­nates can be spec­i­fied. With this fea­ture, it’s pos­si­ble to apply remote loads or sim­u­late tor­sion of arbi­trar­i­ly shaped parts. We will use it for exact­ly this purpose.

Fol­low these steps:

  1. Hide or delete the results of the can­tilever beam analysis.
  2. Sup­press (right-click → Sup­pressed) and hide or just delete the Force object.
  3. Add Rigid Body Con­straint.
  4. Select the same face on which the force load was applied, and set the ref­er­ence point coor­di­nates to (100,5,5).
  5. In the Rota­tion­al Mode sec­tion, set X to Load.
  6. In the Moment sec­tion, spec­i­fy 10 Nm (or 10 J in FreeCAD 1.0 because it didn’t sup­port the Nm units) for X. This will apply torque around the X axis to twist the beam.

Rerun the analy­sis and:

  • If you have the old­er ccx solver enabled, dou­ble-click on Pipeline_CCX_Results and change the Field to Stress xy com­po­nent. Here the stress on the col­or leg­end will be in Pa, so you have to divide it by 106 to have it in MPa.
  • If you have the refac­tored ccx solver enabled, dou­ble-click on Solver­Cal­culiXRe­sult, change the Field to Stress and Com­po­nent to XY, and check the max­i­mum val­ue on the col­or legend.

The max­i­mum shear stress result should be around 48.08 MPa, accord­ing to hand calculations.

What’s next?

Now you are ready to con­tin­ue explor­ing the FEM work­bench on your own or with the help of wiki tuto­ri­als and built-in FEM Exam­ples. There is also a sim­i­lar beam analy­sis with­in the Start page exam­ple files. Just remem­ber that the wiki doc­u­men­ta­tion pages for this workbench’s fea­tures (list­ed on the main FEM Work­bench page) are the best up-to-date ref­er­ence. Prac­tic­ing is real­ly cru­cial for mas­ter­ing FEM sim­u­la­tions. If you get stuck and encounter some issues, reach out to us on the FEM forum.


Discover more from FreeCAD News

Subscribe to get the latest posts sent to your email.

2 responses to “Getting started with FEM

  1. Francisco Avatar
    Francisco

    I was fol­low­ing the tuto­r­i­al and found it per­fect, even for some­one with zero expe­ri­ence in FEM. But when I reached the sec­tion Run­ning an analy­sis and post-pro­cess­ing the results, I lost track a bit when it came to bet­ter visu­al­iz­ing my results. I’m not sure if it was because of the absence of images that high­light which but­tons or func­tions to use. Even so, I man­aged to move for­ward by fol­low­ing a dif­fer­ent path. Unfor­tu­nate­ly, I couldn’t find a way to con­vert the pipelines_CCX_results into a mesh that allows select­ing ver­tices and mak­ing a rough com­par­i­son of the results. (I did it with a sketch and by eye, but aside from those details, the tuto­r­i­al is per­fect as an intro­duc­tion to FEM).

    1. NewJoker Avatar
      NewJoker

      I’m glad you liked the tuto­r­i­al. Since FEM is real­ly com­plex and has many options, I inten­tion­al­ly reduced the con­tent of the tuto­r­i­al to just the fun­da­men­tal aspects (e.g. basic post­pro­cess­ing). Oth­er­wise, it would have to be real­ly long. If you want to do more (such as oth­er ways of post­pro­cess­ing the results), you should check the wiki. There are many use­ful post­pro­cess­ing fil­ters in FEM, for exam­ple to check the results at the select­ed points if that’s what you need.

Discover more from FreeCAD News

Subscribe now to keep reading and get access to the full archive.

Continue reading