Pore Network Generation and Analysis

This MATLAB script simulates the generation of a 3D porous medium using a random seeding and growth algorithm.
2 Downloads
Updated 26 Jul 2024

View License

This MATLAB script simulates a 3D porous medium and performs various analyses on the generated pore structure. The script initializes a 3D domain, generates a pore network to achieve a target porosity, and analyzes the domain for various characteristics like the number of cells, faces, edges, and vertices. Additionally, it visualizes the pore structure, performs skeletonization, analyzes the pore size distribution, and exports the generated porous medium as an STL file.
How to Use the Code
Initialization:
  • The script starts by defining the size of the 3D grid (nx, ny, nz).
  • It initializes the 3D matrix domain to represent the porous medium.
Pore Network Generation:
  • The target porosity (targetPorosity) and average pore size (targetPoreSize) are defined.
  • A while loop iteratively generates the pore network until the target porosity is achieved.
Domain Analysis:
  • The analyzeDomain function extracts the isosurface from the binary domain and calculates the number of cells, faces, edges, and vertices.
Visualization:
  • The script visualizes the pore structure using isosurface and patch.
Skeletonization and Pore Size Distribution:
  • Skeletonization is performed using bwskel.
  • The pore size distribution is analyzed and visualized using a histogram.
Export to STL:
  • The stlwrite function exports the generated porous medium as an STL file for use in 3D modeling and printing.
Cylinder Representation:
  • The function takes the vertices of the pore network and visualizes them as cylinders.
  • Each segment between two consecutive vertices is represented as a cylinder.
  • The radius of the cylinders can be specified, allowing for flexibility in the visualization based on the scale and resolution of the pore network.
Interactive Visualization:
  • The generated cubes/cylinders are displayed in a 3D plot, providing an interactive way to explore the pore network structure.
  • The function utilizes MATLAB's surf function to plot the cubes/cylinders, enhancing the visual quality with lighting and camera adjustments.

Cite As

Jimmy X. Li (2024). Pore Network Generation and Analysis (https://www.mathworks.com/matlabcentral/fileexchange/170286-pore-network-generation-and-analysis), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2024a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.4

update images

1.0.3

update the figs.

1.0.2

upload the image

1.0.1

update the citation information

1.0.0