I’ve recently developed a Matlab code to generate the pore scale microstructure of different porous materials to artificially generate porous media found in natural and synthetic applications.
This code has been used to generate porous microstructures representing carbon paper gas diffusion layers used in fuel cells and is now being used to generate battery electrodes in a collaboration with researchers from NTNU in Norway. A graphical user interface has been developed which makes the code user friendly.

As shown by the interface, different parameters can be specified for each algorithm which uses different geometrical transformations. The output of the code creates:
- A 3D rendered surface of the generated microstructure
- A slice through the domain (showing all phases present)
- The phase fractions along the thickness of the material
In this code, it is possible to choose the resolution (number of voxels in the 3D grid) and the target porosity (phase fraction in n-phase materials). As an example, a film phase is generated around the fibres and can be combined with the fibre phase, creating a smoother surface.

Currently there are different algorithms implemented:
- Overlapping spherical particles
- Non-overlapping spherical particles
- Non-spherical overlapping particles
- Percolating solid clusters
- Fibrous systems
- Molten salt battery electrodes
- Discrete particle deposition
- Ordered lattice systems
The results can be output a surface in .stl format for simulation in CFD software such as OpenFOAM and Fluent, or saved as a .tiff image for later analysis.
If you are interested to use, develop or contribute to the code, please let me know. I’m likely going to develop this further and upload to the Matlab file exchange.