Skip to main content

Microstructure modeling, mesh generation, analysis, and visualization.

Project description

Continuous Integration License


GitHub Repository ReadTheDocs Documentation PyPI PyPI

MicroStructPy is a microstructure mesh generator written in Python. Features of MicroStructPy include:

  • 2D and 3D microstructures
  • Grain size, shape, orientation, and position control
  • Polycrystals, amorphous phases, and voids
  • Mesh verification
  • Visualizations
  • Output to common file formats
  • Customizable workflow
Banner image showing the three steps for creating microstructure.

The three steps to creating a microstructure are: 1) seed the domain with particles, 2) create a Voronoi power diagram, and 3) convert the diagram into an unstructured mesh.

Download & Installation

To install MicroStructPy, download it from PyPI using:

pip install microstructpy

If there is an error with the install, try pip install pybind11 first, then install MicroStructPy.

MicroStructPy can also be installed from source:

git clone
pip install -e MicroStructPy/

Installing MicroStructPy creates the command line program microstructpy and the Python package microstructpy. The command line program executes a standard workflow on XML input files, while the package exposes classes and functions for a customized workflow.

Run a Demo

MicroStructPy includes several demo and example files to help new users get started with the program. A full list of examples is available online at

Here is minimal example input file:

<?xml version="1.0" encoding="UTF-8"?>
        <shape> circle </shape>
        <size> 0.15 </size>

        <shape> square </shape>

This example can be run from the command line by excuting:

microstructpy --demo=minimal.xml

Alternatively, you can copy the text to a file such as my_input.xml and run microstructpy my_input.xml.

The same output can be obtained from using the package in a script:

import matplotlib.pyplot as plt
import microstructpy as msp

phase = {'shape': 'circle', 'size': 0.15}
domain = msp.geometry.Square()

# Unpositioned list of seeds
seeds = msp.seeding.SeedList.from_info(phase, domain.area)

# Position seeds in domain

# Create polygonal mesh
polygon_mesh = msp.meshing.PolyMesh.from_seeds(seeds, domain)

# Create triangular mesh
triangle_mesh = msp.meshing.TriMesh.from_polymesh(polygon_mesh)

# Plot outputs
for output in [seeds, polygon_mesh, triangle_mesh]:
    plt.axis([-0.5, 0.5, -0.5, 0.5])


MicroStructPy documentation is available online at

To build a local copy of the documentation, execute the following from the top-level directory of the MicroStructPy repository:

pip install tox
tox -e docs

Once built, the documentation will be in docs/build/.


If you use MicroStructPy in you work, please consider including these citations in your bibliography:

K. A. Hart and J. J. Rimoli, Generation of statistically representative microstructures with direct grain geomety control, Computer Methods in Applied Mechanics and Engineering, 370 (2020), 113242. (BibTeX) (DOI)

K. A. Hart and J. J. Rimoli, MicroStructPy: A statistical microstructure mesh generator in Python, SoftwareX, 12 (2020), 100595. (BibTeX) (DOI)

The news article AE Doctoral Student Kenneth A. Hart Presents MicroStructPy to the World, written by the School of Aerospace Engineering at Georgia Tech, describes MicroStructPy for a general audience.


Contributions to the project are welcome. Please use the GitHub pull request and issue submission features. See the Contributing Guidelines for more details.

License and Attributions

MicroStructPy is open source and freely available. Copyright for MicroStructPy is held by Georgia Tech Research Corporation. MicroStructPy is a major part of Kenneth (Kip) Hart’s doctoral thesis, advised by Prof. Julian Rimoli.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for microstructpy, version 1.4.3
Filename, size File type Python version Upload date Hashes
Filename, size microstructpy-1.4.3-py2.py3-none-any.whl (124.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size microstructpy-1.4.3.tar.gz (1.2 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page