Stiffness Matrix Calculator
Element stiffness matrices for the direct-stiffness (matrix) method: axial bar (2x2), Euler-Bernoulli beam (4x4), 2D truss with angle transformation, plus a two-element assembly solver with boundary conditions. Metric and imperial units.
Calculator
2-DOF axial bar element: nodal forces relate to axial displacements by k = (A·E/L) · [[1,-1],[-1,1]].
4-DOF Euler-Bernoulli beam element, DOFs [v1, θ1, v2, θ2]. k = (E·I/L³) · M with M = [[12,6L,-12,6L],[6L,4L²,-6L,2L²],[-12,-6L,12,-6L],[6L,2L²,-6L,4L²]].
2D truss element, DOFs [u1x, u1y, u2x, u2y]. Local axial matrix transformed to global axes by angle θ (degrees, counter-clockwise from the x-axis): k = Tᵒ · k_local · T.
Two bar elements in series (nodes 1-2-3). Global K (3x3) is assembled, one node is fixed (boundary condition), nodal forces are applied, and displacements are solved by Gaussian elimination.
Element 1 (nodes 1-2)
Element 2 (nodes 2-3)
Boundary condition & loads
Worked example
Factor EI/L³ = 1000/8 = 125 N/m. Then k₁₁ = 12 × 125 = 1500 N/m, k₁₂ = 6L × 125 = 12 × 125 = 1500 N, k₂₂ = 4L² × 125 = 16 × 125 = 2000 N·m. Enter E = 1 GPa and I = 1e-6 m⁴ (so EI = 1000 N·m²) in the Beam tab to reproduce these entries exactly.
Global K = [[1000,-1000,0],[-1000,3000,-2000],[0,-2000,2000]] N/m. Solving the free DOFs gives u2 = 5 m, u3 = 7.5 m, reaction at node 1 R1 = -5000 N (equilibrium: -5000 + 5000 = 0).
Formulas used
Axial bar (DOFs u1, u2): k = (A*E/L) * [[1,-1],[-1,1]]
Euler-Bernoulli beam (DOFs v1, th1, v2, th2): k = (E*I/L^3) * [[12,6L,-12,6L],[6L,4L^2,-6L,2L^2],[-12,-6L,12,-6L],[6L,2L^2,-6L,4L^2]]
2D truss (DOFs u1x,u1y,u2x,u2y, angle th): k = (A*E/L) * [[c^2,cs,-c^2,-cs],[cs,s^2,-cs,-s^2],[-c^2,-cs,c^2,cs],[-cs,-s^2,cs,s^2]], c = cos(th), s = sin(th)
Assembly (two bars in series, nodes 1-2-3): K = [[k1,-k1,0],[-k1,k1+k2,-k2],[0,-k2,k2]], then the fixed node's row/column is removed, K_free * u_free = F is solved by Gaussian elimination with partial pivoting, and the reaction is R = (K*u)[fixed] - F[fixed].
Frequently asked questions
What is a stiffness matrix?
A stiffness matrix k relates the forces at an element's nodes to the displacements of those nodes through the equation F = k * u. Each entry k(i,j) is the force needed at degree of freedom i to produce a unit displacement at degree of freedom j while all other displacements are held at zero. It is the core building block of the direct-stiffness (matrix) method in finite element analysis.
What is the stiffness matrix of an axial bar element?
For a 2-DOF axial bar with cross-section area A, Young's modulus E and length L, the element stiffness is k = (A*E/L) * [[1, -1], [-1, 1]]. The scalar AE/L is the axial stiffness: for example A = 0.01 m2, E = 200 GPa, L = 2 m gives AE/L = 1e9 N/m, so the matrix is [[1e9, -1e9], [-1e9, 1e9]] N/m.
What is the stiffness matrix of an Euler-Bernoulli beam element?
For a beam element with DOFs [v1, theta1, v2, theta2] (transverse displacement and rotation at each end), k = (E*I/L^3) * M where M = [[12, 6L, -12, 6L], [6L, 4L^2, -6L, 2L^2], [-12, -6L, 12, -6L], [6L, 2L^2, -6L, 4L^2]]. Hand check: with L = 2 m and EI = 1000 N m2, the factor EI/L^3 = 125, so k11 = 12*125 = 1500 N/m, k12 = 6L*125 = 1500 N, and k22 = 4L^2*125 = 2000 N m.
What do the DOFs v1, theta1, v2, theta2 mean?
They are the degrees of freedom of a beam element: v1 and v2 are the transverse displacements at the left and right nodes, theta1 and theta2 are the rotations (slopes) at the left and right nodes. The matrix is 4x4 because each of the 4 DOFs can carry a force or moment and can displace or rotate.
How does the 2D truss element handle an angled member?
The truss element is first written in local coordinates (axial only), then rotated into the global x-y system with the transformation k_global = T' * k_local * T, where T is built from cos and sin of the member angle theta measured counter-clockwise from the x-axis. The closed form is k = (A*E/L) * [[c^2, c*s, -c^2, -c*s], [c*s, s^2, -c*s, -s^2], [-c^2, -c*s, c^2, c*s], [-c*s, -s^2, c*s, s^2]] with DOFs [u1x, u1y, u2x, u2y]. For theta = 30 degrees and AE/L = 1e6 N/m, k11 = 750000 N/m and k22 = 250000 N/m.
How is the global stiffness matrix assembled from elements?
Each element matrix is added ("assembled") into the global matrix at the rows and columns of its nodes, so shared nodes accumulate stiffness from every connected element. For two bars in series (nodes 1-2-3) with element stiffnesses k1 and k2, the global 3x3 matrix is K = [[k1, -k1, 0], [-k1, k1+k2, -k2], [0, -k2, k2]].
How are boundary conditions applied in the assembly solver?
A boundary condition fixes a displacement, for example u1 = 0 at a clamped node. The solver deletes the fixed node's row and column from the global matrix, solves the smaller system K_free * u_free = F with Gaussian elimination, then back-substitutes to get the reaction force at the fixed node: R = (K*u)[fixed] - F[fixed]. Example: k1 = 1000 N/m, k2 = 2000 N/m, node 1 fixed, 5000 N at node 3 gives u2 = 5 m, u3 = 7.5 m and reaction -5000 N, which balances the applied load.
Is the stiffness matrix always symmetric?
Yes for linear elastic elements, by Maxwell-Betti reciprocity: k(i,j) = k(j,i). You can see it in every matrix this calculator produces, for instance the beam matrix has k12 = k21 = 6L*EI/L^3. Symmetry also means only the upper triangle needs to be stored in large solvers.
What is the difference between a stiffness matrix and rotational stiffness?
A stiffness matrix is a full matrix coupling all degrees of freedom of an element (for a beam, 4x4 linking transverse forces, moments, displacements and rotations). Rotational stiffness is a single scalar: moment per unit rotation at one point, like a torsional spring. They are different concepts; a rotational spring cannot represent bending coupling between the two ends of a beam.
Does this calculator use Euler-Bernoulli or Timoshenko beam theory?
Euler-Bernoulli: the element assumes plane sections stay plane and perpendicular to the neutral axis, so shear deformation is neglected. That is accurate for slender beams (length to depth ratio above about 10). For short deep beams where shear matters, a Timoshenko element would be needed.
Which units can I use?
E in GPa, MPa, ksi or psi; I in m^4, cm^4, mm^4 or in^4; L in m, cm, mm or in; area in m^2, cm^2, mm^2 or in^2. Stiffness results display in N/m, kN/m, N/mm or lbf/in, and assembly displacements in m, mm or in. All conversions use exact factors, for example 1 psi = 6894.757293168 Pa and 1 lbf/in = 175.1268352465 N/m.
Can I copy the matrix into a spreadsheet or MATLAB?
Yes. The Copy matrix button copies the displayed matrix as tab-separated plain text, which pastes directly into Excel, Google Sheets, or MATLAB/Octave (in MATLAB, wrap it in brackets). Displayed values are rounded to 6 significant digits; the copied values keep full precision.