topoptlab: An Open and Modular Framework for Benchmarking and Research in Topology Optimization

topoptlab: An Open and Modular Framework for Benchmarking and Research in Topology Optimization - Published in JOSS (2026)

https://github.com/stefanhiemer/topoptlab

Science Score: 87.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: springer.com
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

finite-elements optimization topology-optimization
Last synced: 18 days ago · JSON representation

Repository

The project originates from a simple update of the python topology optimization code by Niels Aage and collaborators, but has since developed into a library for toplogy optimization going well beyond the features of the original code.

Basic Info
  • Host: GitHub
  • Owner: stefanhiemer
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 9.2 MB
Statistics
  • Stars: 4
  • Watchers: 4
  • Forks: 3
  • Open Issues: 1
  • Releases: 0
Topics
finite-elements optimization topology-optimization
Created over 2 years ago · Last pushed about 1 month ago
Metadata Files
Readme Contributing License Roadmap

README.md

topoptlab

Documentation Status PyPI CI

This project provides a collection of topology optimization techniques, many of which were originally published MATLAB scripts. The goal is to make these methods broadly accessible in Python, in a style similar to the well-known 88 line code by Andreassen and Sigmund. The package can be used in two ways:

  • As a library:
    Write your own scripts in the concise style of the 88 line MATLAB code. A simple re-write with extension to 3D, variable boundary conditions and changeable physics (lin. elasticity, heat conduction) can be found in TO_from_scratch.py

  • As a modular “black-box” routine:
    Use the main function in topology_optimization.py as a black box function that returns an optimal design once provided with a set of boundary conditions and parameters to run topology optimization directly. If the boundary conditions are already available, then running an optimization can be quite simple. E. g. if one wants to reproduce the famous MBB beam in 2D it amounts to: ``` from topoptlab.topologyoptimization import main from topoptlab.examplebc.linelast import mbb2d

main(nelx=60, nely=20, volfrac=0.5, rmin=2.4, optimizer="oc", bcs=mbb_2d) ``` For tutorials, explanations, and full documentation, see the online documentation.

Features

Here is an (incomplete) list of features:

  • Topology Optimization

    • Material interpolations
    • Modified SIMP
    • RAMP
    • (Hashin–Shtrikman) bound-based
    • Objectives
    • Compliance minimization (stiffness maximization) / control
    • Displacement maximization / control
    • Filters
    • Sensitivity
    • Density
    • Additive manufacturing filter (Langelaar, 2D)
    • Projections
      • Guest (2004)
      • Sigmund (2007)
      • Volume-conserving projection (Xu, 2010)
    • Constrained optimizers
    • MMA / GCMMA via mmapy by Arjen Deetman
    • Optimality criteria method
    • Unconstrained optimizers
    • Gradient descent
    • Barzilai–Borwein
    • Design analysis
    • Gray level indicator
    • Lengthscale violations
  • FEM

    • Linear elasticity
    • Heat conduction
    • Heat expansion
    • Cahn–Hilliard
    • analytic element integration via symfem by Matthew Scroggs
  • Example cases

    • MBB beam 2D / 3D
    • Cantilever 2D / 3D
    • Compliant mechansim (force inverter) 2D / 3D
    • Heat plate cooling 2D (stationary and transient)
  • Solver / preconditioner for linear systems (beyond scipy.sparse)

    • Sparse Cholesky decomposition of CHOLMOD via CVXOPT
    • Algebraic multigrid (via pyAMG and self-written)
    • Geometric multigrid
    • Block-sparse preconditioner

For a list of upcoming features, look at the ROADMAP.md.

Monolithic codes

In the monolithic_code directory, you can find codes that are self contained and do not use the topoptlab module written here. These codes are purely there to either test new frameworks (e. g. JAX or PETSC) or for teaching/demonstration purposes. If you are completely new to topology optimization, this is where you start and I suggest to start with the topopt88.py.

Installation, documentation and tests

Installation with pip from PyPI

Install everything needed for the basic installation, documentation and tests: pip install topoptlab[tests,docs]

Installation with pip from the Github Repository

Clone the repository git clone https://github.com/stefanhiemer/topoptlab and execute pip install .[tests,docs] in top directory. Editable installation (recommended if you want to edit something in the code) pip install -e .[tests,docs]

Run tests

Run fast tests (finish in under one minute) pytest Run slow tests (take a few minutes) pytest -m slow

Make documentation

The documentation can be build via Sphinx

cd docs/ sphinx-apidoc -o source/ ../topoptlab/ ../topoptlab/legacy --force --no-toc --separate make html and displayed in your browser by drag and drop or if you are on Linux xdg-open build/html/index.html

Build package and release on PyPI (only for maintainers and developers)

Make sure the necessary packages have been installed: pip install -e .[pypi] Build the package python -m build and upload via twine python -m twine upload dist/* For testing reasons it may be smarter to first upload on TestPyPI python -m twine upload --repository testpypi dist/* and then install the package via pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \ topoptlab

Getting report bugs, and suggest enhancements

If you found a bug or you want to suggest a new feature/enhancement, submit it on the issue tracker.

How to contribute

Contact the maintainers via an enhancement suggestion in the issue tracker and look at the ROADMAP.md for a list of upcoming features. If you decide to contribute, fork the repository and open a pull request. For detailed instructions check out CONTRIBUTING.md.

Acknowledgments

We acknowledge the support by the Humboldt foundation through the Feodor-Lynen fellowship. We acknowledge partial support from the ARCHIBIOFOAM project which received funding from the European Union’s Horizon Europe research and innovation programme under grant agreement No 101161052. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or European Innovation Council and SMEs Executive Agency (EISMEA). Neither the European Union nor the granting authority can be held responsible for them.

Special thanks are extended to Christof Schulze for his valuable suggestions on code improvements, to Stefano Zapperi for hosting at the University of Milan and for his continuous support, and to Peter Råback for sharing his vast knowledge on FEM related implementation details.

Owner

  • Login: stefanhiemer
  • Kind: user

JOSS Publication

topoptlab: An Open and Modular Framework for Benchmarking and Research in Topology Optimization
Published
February 02, 2026
Volume 11, Issue 118, Page 9105
Authors
Stefan Hiemer ORCID
Center for Complexity and Biosystems, Department of Physics "Aldo Pontremoli", University of Milan, Via Celoria 16, 20133 Milano, Italy, CNR – Consiglio Nazionale delle Ricerche, Istituto di Chimica della Materia Condensata e di Tecnologie per l’Energia, Via R. Cozzi 53, 20125 Milano, Italy
Editor
George K. Thiruvathukal ORCID
Tags
topology optimization finite element method materials science

GitHub Events

Total
  • Release event: 1
  • Issues event: 2
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 69
  • Create event: 1
Last Year
  • Release event: 1
  • Issues event: 2
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 69
  • Create event: 1

Committers

Last synced: 4 months ago

All Time
  • Total Commits: 285
  • Total Committers: 2
  • Avg Commits per committer: 142.5
  • Development Distribution Score (DDS): 0.042
Past Year
  • Commits: 270
  • Committers: 2
  • Avg Commits per committer: 135.0
  • Development Distribution Score (DDS): 0.044
Top Committers
Name Email Commits
stefanhiemer S****r@w****e 273
shiemer s****r@f****e 12
Committer Domains (Top 20 + Academic)
fau.de: 1

Issues and Pull Requests

Last synced: 3 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 10 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
pypi.org: topoptlab

topology optimization for testing and demonstration uses.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 10 Last month
Rankings
Dependent packages count: 8.6%
Downloads: 17.5%
Average: 29.1%
Forks count: 30.7%
Stargazers count: 40.7%
Dependent repos count: 48.2%
Maintainers (1)
Last synced: about 2 months ago

Dependencies

pyproject.toml pypi
  • cvxopt *
  • gmsh *
  • matplotlib *
  • meshio *
  • mmapy *
  • numpy *
  • scipy *
  • symfem *