microgen is a Python library designed to facilitate microstructure generation and meshing. Here are its core features:
- Triply Periodic Minimal Surfaces (TPMS): gyroid, Schwarz, Schoen, Neovius, Fischer-Koch… as sheets or skeletons, graded in density, cell size or cell type, in Cartesian, cylindrical or spherical frames, and as infill of any mesh.
- Spinodoids: random, anisotropic bicontinuous microstructures from Gaussian random fields.
- Lattices: octet-truss, honeycomb, preset and custom (e.g. auxetic) strut lattices.
- Virtual composites: periodic RVEs of spheres, short fibres, ellipsoids and other inclusions.
- 3D Voronoi tessellation: granular materials and polycrystalline metals, also combined with TPMS.
- Implicit workflow: shapes as implicit fields (F-rep), with boolean operations and blending.
- Meshing: regular and periodic meshing using Gmsh, level-set remeshing using Mmg.
Generation of 3D objects is achievable through functions that utilize Open CASCADE (via cadquery-ocp-novtk, the direct OCCT Python binding) or VTK (using PyVista). Neper offers tools for 3D tessellation, while Gmsh handles the generation of both regular and periodic meshes, with Mmg handling remeshing tasks.
The CAD path (.generate_cad() on shapes, Phase, fuse_shapes, periodic split, lattice CAD) is optional — install with pip install 'microgen[cad]'. The default pip install microgen gives you mesh + implicit-field (F-rep) workflows only, which is sufficient for many applications and has a much lighter dependency footprint (no OCCT, no VTK version pin).
from microgen import Phase, Tpms, surface_functions
gyroid = Tpms(surface_function=surface_functions.gyroid, offset=0.3)
phase = Phase.from_shape(gyroid, resolution=80)
phase.surface_mesh().save("gyroid.stl") # marching cubes from the SDF
print(f"COM = {phase.center_of_mass}, pieces = {len(phase.pieces)}")A Phase built via Phase.from_shape carries the implicit field directly —
marching cubes, connected components (phase.pieces), and grid-quadrature
moments all run from the SDF, no OCCT required. CAD (phase.cad, STEP export,
gmsh setPeriodic) is materialised lazily and only needs the [cad] extra.
| PyPI package | |
| Conda forge package | |
| Documentation | |
| Status | |
| Citation | |
| License | |
| Website |
Core (mesh + implicit-field / F-rep, no CAD kernel) — lighter, works with VTK 9.4+:
pip install microgenWith CAD capabilities (OCCT via cadquery-ocp-novtk, enables .generate_cad(), Phase, fuse_shapes, periodic split, lattice CAD):
pip install 'microgen[cad]'With the Meshers volume-mesh backend (generate_volume_mesh(backend="meshers"): tetrahedra meshed directly from the implicit field, with periodic node pairs; wheels for Linux x86-64, macOS and Windows):
pip install 'microgen[meshers]'Everything (CAD, Meshers and ray tracing; Meshers is skipped on Linux aarch64, where it has no wheel):
pip install 'microgen[all]'With conda:
conda install conda-forge::microgen # core
conda install conda-forge::microgen ocp # core + CADPython version notes: Python 3.11 to 3.14 is supported on Linux, macOS (Apple Silicon), and Windows, for both core and [cad], on both PyPI and conda-forge.
What you can do in each mode:
| Core install | [cad] install |
|
|---|---|---|
Shape.generate_surface_mesh() (viz) |
✅ | ✅ |
| Implicit fields, TPMS F-rep, booleans | ✅ | ✅ |
Shape.generate_cad() (OCCT BREP) |
❌ | ✅ |
Phase, fuse_shapes, cut_* |
❌ | ✅ |
| Periodic split, lattice CAD export | ❌ | ✅ |
| VTK 9.4+ | ✅ | ✅ |
To modify the sources, clone this repository and install microgen:
git clone https://github.com/3MAH/microgen.git
cd microgen
pip install -e '.[all,dev,docs]'
pre-commit installThe -e or --editable option allows to modify the sources without having to reinstall the package; [all] installs every optional feature (CAD, Meshers, ray tracing) and [dev,docs] the development and documentation tools.
Run tests with pytest:
pytest tests -n autoClick on an image to open the example in the gallery of microgen's documentation. The images are rendered by the documentation build, so they always show the current version of each example.
If you use microgen in academic work, please cite it using the concept DOI, which always resolves to the latest archived version on Zenodo:
A BibTeX entry suitable for the latest release:
@software{microgen,
author = {Marchais, Kevin and
Chemisky, Yves and
Legerstee, Yasmin and
Guevara Garban, Manuel Ricardo},
title = {{microgen: microstructure generation and meshing}},
publisher = {Zenodo},
doi = {10.5281/zenodo.6793573},
url = {https://doi.org/10.5281/zenodo.6793573}
}To cite a specific release instead of the concept, follow the concept DOI to its Zenodo page and pick the version DOI for the release you used. Machine-readable metadata is also available in CITATION.cff.
microgen is developed by the 3MAH group and external collaborators.
Authors
- Kevin Marchais
- Yves Chemisky
- Yasmin Legerstee
- Manuel Ricardo Guevara Garban
Contributors
- Louise Le Barbenchon
- Karim Haffar
- Romain d'Esparbès
- Sudeep Kumar Sahoo






































