Finite Element from Scratch in Python

License: MIT · Updated 2026-08-01

Introduction

The best way to learn FEM is to implement it yourself. This tutorial depends on no existing framework - starting from triangular elements, it builds a 2D linear-elastic solver in pure NumPy/SciPy, covering the full pipeline from meshing to post-processing. For engineers and students who want to deeply understand FEM internals.

Path

Chapter 1: Triangular elements & shape functions (2-3 days)

  • Understand FEM core: from weak form to element matrix
  • Implement shape functions and their Jacobians

Chapter 2: Stiffness assembly (2-3 days)

  • Global stiffness assembly logic
  • Gaussian integration; sparse COO assembly

Chapter 3: Boundary conditions & solve (1-2 days)

  • Dirichlet/Neumann handling
  • SciPy sparse solver; stress recovery

Chapter 4: Meshing & post-processing (1-2 days)

  • Delaunay triangulation; matplotlib contours

Who it's for

  • Mech/civil/aero students who know FEM formulas but want to verify by hand
  • Programmers wanting first-principles FEM, not just software operation
  • A foundation before learning FEniCS / Abaqus
Tags: FEMFinite ElementPythonSolid MechanicsNumerical Method