Structural
The Stiffness Matrix from First Principles
Where the element stiffness matrix comes from, in full: virtual work, shape functions, the strain-displacement matrix, and the 12×12 frame element, with every step derived rather than quoted.
On this page7 sections
Every finite element analysis — ETABS, SAP2000, ANSYS, a Python solver of your own — resolves to the same object: the element stiffness matrix.
It comes out of one principle and one assumption, and all of it fits inside a single integral. No black boxes.
The core idea
A structural element resists deformation. The stiffness matrix captures how much — it maps nodal displacements to nodal forces :
For a single element with degrees of freedom, is an matrix. For a full structure, we assemble all element matrices into a global .
Deriving the bar element
The 2-node axial bar is the smallest element that shows every step, and every step generalises. Four moves get from a principle to a matrix.
Virtual work
- Principle of virtual work
For a body in equilibrium, the virtual work done by external forces through any virtual displacement equals the virtual strain energy stored internally.
For a bar element under virtual nodal displacement :
This is the foundation. Now we need to connect strains to displacements.
Shape functions
A 2-node bar element has 2 DOF: and (axial displacements). We assume the displacement varies linearly along the element:
- Shape functionsN(x)
N₁ and N₂ define how the interior displacement field is interpolated from the nodal values.
In matrix form:
Strain from displacement
For a bar in axial loading, strain is:
where is the strain-displacement matrix, found by differentiating :
The integral
With linear elastic material, stress follows strain:
Substituting into the virtual work equation:
Since is arbitrary, we can factor it out:
For a bar with constant , :
That’s the 2×2 stiffness matrix for an axial bar element — derived entirely from first principles.
The beam element
A 2D Euler–Bernoulli beam element has 4 DOF: two transverse displacements , and two rotations , .
The shape functions are cubic (Hermite polynomials):
where:
Curvature is the bending analogue of strain, and it plays exactly the same role in the integral:
So the stiffness matrix follows the same form:
This is the Euler–Bernoulli beam stiffness matrix — you’ll find this exact matrix in every structural analysis textbook.
Putting numbers in it
The derivation stops at symbols, which is the right place for a derivation to stop and the wrong place to leave it. Two plots of what it already contains, then the same thing with a section in it.
Enter a section and a length below and both matrices are evaluated as you type.
Axial (bar) element
| u₁ per m | u₂ per m | |
|---|---|---|
| u₁ | 188,300 kN/m | -188,300 kN/m |
| u₂ | -188,300 kN/m | 188,300 kN/m |
Euler–Bernoulli beam element
| v₁ per m | θ₁ per rad | v₂ per m | θ₂ per rad | |
|---|---|---|---|---|
| v₁ | 975.3 kN/m | 2,926 kN/rad | -975.3 kN/m | 2,926 kN/rad |
| θ₁ | 2,926 kN·m/m | 11,700 kN·m/rad | -2,926 kN·m/m | 5,852 kN·m/rad |
| v₂ | -975.3 kN/m | -2,926 kN/rad | 975.3 kN/m | -2,926 kN/rad |
| θ₂ | 2,926 kN·m/m | 5,852 kN·m/rad | -2,926 kN·m/m | 11,700 kN·m/rad |
Values are shown to 4 significant figures. Rotations are in radians, which are dimensionless — so kN/rad is kN, and kN·m/rad is kN·m. Local element coordinates; no transformation to global axes.
Note
Length is the interesting input. Double and the translational term falls by a factor of eight, while the rotational term only halves — which is why a member’s resistance to end rotation survives a span increase far better than its resistance to sway does.
Warning
These are element matrices in local coordinates, not a structural analysis. They carry the same assumptions as the derivation above: a prismatic element with constant , and , linear elastic material, small displacements, and Euler–Bernoulli bending — shear deformation is neglected. Assembling them, applying boundary conditions and solving is the next step, not this one.
The 3D frame element
Combining axial, bending (two planes), torsion, and shear DOF gives the full 12×12 matrix used in ETABS, SAP2000, and every general-purpose FEM solver.
The assembly process is always the same:
- Define shape functions for each DOF
- Compute by differentiation
- Integrate
- Transform from local to global coordinates via
In code
import numpy as np
def bar_stiffness(E: float, A: float, L: float) -> np.ndarray:
"""2x2 stiffness matrix for an axial bar element."""
k = (E * A / L)
return k * np.array([[1, -1], [-1, 1]])
def beam_stiffness(E: float, I: float, L: float) -> np.ndarray:
"""4x4 Euler-Bernoulli beam element stiffness matrix.
DOF order: [v1, θ1, v2, θ2]
"""
k = E * I / L**3
return k * np.array([
[ 12, 6*L, -12, 6*L],
[6*L, 4*L**2, -6*L, 2*L**2],
[-12, -6*L, 12, -6*L],
[6*L, 2*L**2, -6*L, 4*L**2],
])
Both functions are the closed forms above, transcribed. Nothing in them is fitted or looked up — an error in either one is a typo, not a modelling decision.
What this tells you
Every result ETABS gives you flows from this integral. The “stiffness matrix” isn’t a magic number lookup — it’s a compact representation of how a physical element resists deformation, derived from strain energy and virtual work.
Understanding the derivation doesn’t change your day-to-day workflow. But when a model gives you a surprising result, it tells you where to look.