awx

← Blog

Walk-through · 24 November 2026

How to do a finite element analysis for free with CalculiX

We’ll use an awx computer to solve a steel cantilever with 500 N at the tip. We’ll solve it four times, refining the mesh each time. The deflection comes within 1% of the hand calculation, and the bending stress matches beam theory exactly. One number keeps climbing however fine the mesh gets. We’ll see why.

Awi the cat agent in a graduation cap

The tools

All three tools are free and run in a terminal. That makes it easy to do the whole analysis on a cloud computer if you are away from a lab PC.

Step 1: a computer, CalculiX and Gmsh

Create a computer in awx. We used a Large computer called calculix-fea. This beam needs very little computing power, and Large leaves room for bigger parts. Open the computer’s Terminal tab and run these commands to install the tools.

sudo apt-get update
sudo apt-get install -y calculix-ccx gmsh
python3 -m venv ~/fea && ~/fea/bin/pip install numpy matplotlib

Installation took 20 seconds and gave us CalculiX 2.21 and Gmsh 4.12.1. The last line creates a small Python environment, ~/fea, which you’ll use to plot the results at the end. The solve only needs the Python already on the computer.

Step 2: the hand calculation

Start with a hand calculation so you know roughly what to expect before trusting the solver. Our steel beam (E = 210 GPa, ν = 0.3) is 100 mm long, 10 mm wide and 20 mm tall. It is clamped at one end, and 500 N pushes down at the other.

I = b h³ / 12 = 10 × 20³ / 12 = 6,667 mm⁴
bending stress at the clamp       σ = M c / I = (500 × 100) × 10 / 6,667 = 75 MPa
  30 mm from the clamp              σ = (500 × 70) × 10 / 6,667  = 52.5 MPa
tip deflection                    δ = P L³ / 3 E I = 0.119 mm
  plus shear (Timoshenko)           δ = 0.119 + P L / (κ G A) = 0.119 + 0.0037 = 0.123 mm
     with κ = 5/6 (rectangle), G = E / 2(1 + ν) = 80,800 MPa, A = 10 × 20 = 200 mm²

Include the shear term when you calculate tip deflection. It matters for this short, deep beam, whose length is only 5 times its height.

We compare the stresses 30 mm from the clamp because beam theory assumes the beam bends freely. The clamp also stops the material from shrinking sideways, which disturbs the stresses for about one beam depth (20 mm). By Saint-Venant’s principle, we compare the solver with beam theory outside that zone.

Step 3: the files

Keep the three small files together. These commands put them in one folder on the computer.

mkdir -p ~/cantilever && cd ~/cantilever
for f in beam.geo run.py plot.py; do curl -sO https://awanbox.com/blog/files/calculix-cantilever/$f; done
ls

You can also upload the files from your laptop using the computer’s Files tab. The file beam.geo defines the part, run.py creates the mesh, runs the solve and reads the results, and plot.py plots them. Run the commands that follow from this folder.

Step 4: the geometry and the mesh

The file beam.geo describes the part in Gmsh’s own language.

SetFactory("OpenCASCADE");
L = 100; B = 10; H = 20;
Box(1) = {0, 0, 0, L, B, H};
Physical Volume("BEAM") = {1};
Mesh.CharacteristicLengthMax = size;   // from the command line: -setnumber size 5
Mesh.ElementOrder = 2;                 // 10-node tetrahedra: far better than 4-node ones in bending

Here is the command Gmsh uses to turn the part into a mesh in a format CalculiX can read. You do not need to type it yourself because run.py runs it for each mesh size.

gmsh beam.geo -3 -setnumber size 5 -format inp -o mesh.inp

Gmsh’s element count is larger than run.py’s because Gmsh includes the triangles on the surface. The script counts only the 10-node tetrahedra that CalculiX solves.

Step 5: loads, supports and the solve

The CalculiX input file brings in the mesh and tells the solver what the beam is made of, where it is held and where the load acts. To write this file, run.py uses the coordinates to find the nodes on the two end faces.

*INCLUDE, INPUT=mesh.inp
*NSET, NSET=FIXED          ** every node on the face x = 0
*NSET, NSET=TIP            ** every node on the face x = 100
*MATERIAL, NAME=STEEL
*ELASTIC
210000, 0.3
*SOLID SECTION, ELSET=BEAM, MATERIAL=STEEL
*STEP
*STATIC
*BOUNDARY
FIXED, 1, 3                ** clamped: no movement in x, y or z
*CLOAD
...                        ** 500 N downwards, shared equally over the end face's nodes
*NODE PRINT, NSET=TIP
U
*NODE FILE
U
*EL FILE
S
*END STEP

Then ccx beam solves the model and writes the tip’s movement to beam.dat. It writes the stresses throughout the beam to beam.frd, which the script uses to work out the von Mises stress and the bending stress on the top face.

Sharing the force equally among the nodes is a shortcut that gives the right total force. By Saint-Venant’s principle, that gives the right results away from the tip. The shortcut differs from applying an even pressure. If you need stresses close to where the load is applied, use a pressure on the face (*DLOAD).

Step 6: four meshes

python3 run.py 10; python3 run.py 5; python3 run.py 2.5; python3 run.py 1.25
Mesh sizeNodesTip deflectionBending stress 30 mm from the clampHighest von Mises
10 mm5150.1211 mm52.5 MPa75.2 MPa
5 mm2,0240.1215 mm52.5 MPa75.7 MPa
2.5 mm11,3230.1216 mm52.5 MPa85.8 MPa
1.25 mm73,9930.1217 mm52.5 MPa109.8 MPa
Hand calculation0.123 mm52.5 MPano answer (see below)

The first three runs took under two seconds each, including meshing and solving. The finest mesh took 35 seconds. At 30 mm from the clamp, every mesh gives a bending stress of 52.5 MPa, exactly as beam theory predicts. The second-order elements capture bending even on a coarse mesh. For a consistent comparison, run.py finds the stress at the same point, x = 30 mm, by fitting a straight line through the nearby top-face nodes. The tip deflection settles at 0.1217 mm, 1% below the hand calculation that includes shear.

Why one number never settles

Look at the highest von Mises stress. It rises from 75 to 76, then 86 and finally 110 MPa, and would keep rising with every refinement. This peak occurs at the sharp corner where the beam meets the perfectly rigid clamp. In the mathematical model, the corner is a singularity. The stress there is infinite, so the peak rises as the mesh gets finer. Beam theory’s 75 MPa at the clamp comes from a different idealisation and cannot be used to check this peak.

Real parts have a fillet, and real clamps give a little. Read the stresses away from sharp corners and supports, then check that they stay the same as you refine the mesh. Treat any value that keeps changing without settling as a modelling artefact. Examiners like to see that you understand this.

The result

To draw the picture, use the Python environment from Step 1, which has matplotlib installed.

~/fea/bin/python plot.py

The script saves cantilever.png in the same folder. You can open the image from the Files tab.

Top: the side of the cantilever coloured by von Mises stress, highest (yellow) at the top and bottom corners of the clamped end and lowest (dark blue) along the middle and near the tip; the shape is bent down, exaggerated 50 times, over the dashed outline before loading. Bottom: the mesh study: the bending stress 30 mm from the clamp is a flat line at 52.5 MPa on all four meshes, on the beam theory line, while the highest von Mises rises from 75.2 to 109.8 MPa
Von Mises stress on the bent beam (shape exaggerated 50 times), and the mesh study: one line flat, the other climbing.

For your own assignment, you can change the beam, the load or the material at the top of run.py and beam.geo.

Common questions

Is CalculiX good enough for a final year project?

Yes. CalculiX is widely used for linear static, frequency, buckling and heat transfer work. Its input files follow the Abaqus format, so writing them also gives you practice for using industry tools.

Why 10-node tetrahedra instead of 4-node ones?

With 4-node tetrahedra, the stress is constant inside each element, and the model is far too stiff in bending unless the mesh is very fine. With 10-node elements, even a coarse mesh can capture bending properly. Here, the 515-node mesh gives the exact bending stress.

Why does the highest stress keep rising as I refine the mesh?

The highest stress occurs at a sharp corner against a perfectly rigid support, where the theoretical stress is infinite. Read the stresses away from such corners, or model the real fillet and support.

Can I use my own part from a CAD program?

Yes. Export your part as STEP, then load it in beam.geo by replacing the Box with Merge "part.step";. The script run.py currently uses x = 0 and x = 100 to find the supported and loaded nodes. For a real part, mark those faces as Physical Surfaces in Gmsh and change how the script finds the nodes.

Keep reading

Getting started

Sign in with your Google account and ask to join. Once you have approval, you can create a computer and work through the steps above.

Open awx

Awi the cat agent celebrates with confetti

Awi, signing off.

← All posts