Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 47 · Indeterminate Structures

The matrix stiffness method and a beam solver

Learn the direct stiffness method: beam element stiffness matrix, assembly, boundary conditions and equivalent loads, then build and verify a working beam solver in Python.

The force method and moment distribution are hand methods, clever ways to avoid solving many equations at once. A computer has no such problem, so structural software uses a method that is systematic and never needs a clever choice of redundants: the matrix stiffness method. You describe the structure as elements joined at nodes, build a stiffness matrix for each element, assemble them into one system K u = F and solve. Everything, determinate or indeterminate, beams or skyscrapers, goes through the same procedure.

A beam element with two nodes, deflection and rotation at each, and its four by four stiffness matrix
One beam element has four unknowns (a deflection and a rotation at each end) and a 4 × 4 stiffness matrix that links them to the end forces.

What you will learn

  • What a degree of freedom is and how a beam element is described.
  • How the element stiffness matrix is built and what its entries mean.
  • How to assemble elements, apply supports and loads, and solve K u = F.
  • How to recover reactions and internal moments, and how to verify the solver.

Key terms

Node: a point where elements join; also where supports and loads are applied. Degree of freedom (DOF): a possible displacement at a node. A beam node has two: vertical deflection v and rotation θ. Stiffness matrix K: the matrix that gives nodal forces from nodal displacements, F = K u. Equivalent nodal loads: concentrated forces and moments at nodes that act like a distributed load along an element. Assembly: adding every element matrix into the right rows and columns of the global matrix.

The element stiffness matrix

Take a prismatic beam element of length L and stiffness EI. Its four DOFs are [v₁, θ₁, v₂, θ₂] and the four end actions are [F₁, M₁, F₂, M₂] (forces up positive, moments counter-clockwise positive). From the slope-deflection relations, they are linked by

Text
              | 12     6L     −12     6L  |
 (EI / L³) ×  | 6L    4L²     −6L    2L²  |
              | −12   −6L      12    −6L  |
              | 6L    2L²     −6L    4L²  |

Each column is a recipe: column 2, for example, lists the end forces needed to rotate node 1 by one radian while holding the other three DOFs at zero: a moment 4EI/L at that node, 2EI/L at the far end, and a shear 6EI/L² as a couple. The 4EI/L and 2EI/L are the stiffness and carry-over factor of moment distribution; the matrix method contains it all.

The procedure

  1. Number the DOFs. For n nodes, 2n DOFs: node i has v at 2i and θ at 2i + 1.
  2. Build each element matrix from its L and EI, and add it into the global matrix at the rows and columns of its four DOFs (assembly).
  3. Convert loads to nodal loads. Point loads and moments at nodes go straight into F. For a uniform load w over an element, the fixed-end reactions are [wL/2, wL²/12, wL/2, −wL²/12]; the equivalent nodal loads are the negatives of those.
  4. Apply the supports. Remove the rows and columns of fixed DOFs (or keep them and give the displacement a value for settlement).
  5. Solve K_ff u_f = F_f − K_fp u_p for the free displacements.
  6. Recover the reactions from R = K u − F at the fixed DOFs, and the element end forces from k u_e + (fixed-end reactions).
Python A beam solver in 40 lines

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The solver reproduces both hand methods: the propped cantilever's 45 kN prop reaction and 90 kN·m fixed-end moment, and the continuous beam's reactions and 65 kN·m hogging moment, with no choice of redundants and no iteration. Because uniform load is exactly equivalent at the nodes for this element, the nodal deflections are exact too.

Plotting the whole beam and trying a settlement

Python Deflected shape and moments, with an optional settlement

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The settlement case changes the answer with no change of load: support B carries less, A and C carry more, and the hogging moment over B shrinks. The same solver handles it because the matrix method treats a support displacement just like any other known quantity.

From beams to whole structures

A plane frame element adds an axial DOF at each end (six DOFs per element) and a rotation of the matrix to account for the member's orientation. Trusses use a 2 × 2 axial stiffness EA/L, again rotated. Space frames have twelve DOFs per element. In every case the pipeline is the same, which is why this one method drives software such as SAP2000, ETABS, RISA, STAAD and open-source tools. Finite-element analysis of plates and solids is the same idea with more elaborate elements.

The method also lets a computer give results you cannot easily get by hand: moving loads, many load combinations, dynamic response and nonlinear effects. But the matrix solution is only as good as the model, and the sanity checks you learned in the earlier chapters (reactions sum to the loads, moments near the hand estimate wL²/8 or wL²/12) are how you catch a mistake in the model.

Common misconceptions

"The computer's answer is automatically right." It solves exactly the model you gave it. A missing support, a wrong EI or a unit mix-up gives a precise wrong answer.

"Fixed DOFs are just deleted." Removing them is one way, but you must recover the reactions afterwards, and a support settlement needs the prescribed value included in the right-hand side.

"A finer mesh is always better." For a uniform load on a prismatic beam, two nodes are already exact. Meshes need to be fine only where the response changes quickly, such as near point loads and stiffness changes.

Check your understanding

Quick check · 5 questions

of 5 answered You scored / 5 · perfect!

  1. 1. How many degrees of freedom does a 2D beam element with two nodes have?

    A deflection and a rotation at each of the two nodes.
  2. 2. What are equivalent nodal loads for a uniform load on an element?

    They are the concentrated forces and moments at the nodes that produce the same effect as the distributed load.
  3. 3. What is assembly?

    Each element contributes its stiffness to the DOFs it connects.
  4. 4. How are support reactions found after solving for the displacements?

    The global equation at a fixed DOF contains the unknown reaction, which equals K u − F.
  5. 5. Why does the matrix method make support settlement easy?

    A settling support is a displacement boundary condition, and the solver moves it to the right-hand side.

Summary

  • The matrix stiffness method assembles element matrices into K u = F and solves; the same steps work for any structure.
  • A beam element has four DOFs and a 4 × 4 matrix whose entries are 12, 6L, 4L² and 2L² times EI/L³.
  • Distributed loads become equivalent nodal loads; reactions are R = K u − F at fixed DOFs.
  • The solver agrees with the force method and moment distribution on the propped cantilever and the two-span beam.
  • Always verify a model against hand checks and simple limiting cases.

Next: Chapter 4 review