Small collection of Python tools to generate and analyse microstructures for electrochemical systems.
MicrostructureGeneratorPython/— Python implementations and utilities for particle generation and coatings.environment.yaml— Conda environment specification used to install dependencies.
Prerequisites:
- Conda or Mamba installed on your system.
Create the environment (using mamba for faster installs):
mamba env create -n env_name -f environment.yamlActivate the environment:
conda activate env_nameIf you don't have mamba, you can fall back to:
conda env create -f environment.yamlPython scripts: with the environment activated, run scripts from the MicrostructureGeneratorPython folder. Example:
python MicrostructureGeneratorPython/FastGenerationWithOrWithoutoverlapping.pyAdjust inputs and parameters in the script or use provided example files in input_examples/ as needed.
- The
environment.yamlfile at the repository root contains pinned dependencies used to reproduce the development environment. - If you run into package conflicts, try creating the environment with
mamba(recommended) or create a new minimal environment and pip-install specific packages as a fallback.
This repository is provided as-is. For questions or contributions, open an issue or contact the maintainer.
Below are common configurable parameters used by the Python generation scripts. Update these in the script or configuration file before running to suit your project.
-
np.random.default_rng(seed=42)- Enable reproducible results. You can change the seed value for different random microstructures, but using a fixed seed guarantees that the same input parameters will produce the same output every run. -
raw_data_file_name— Name of the file that contains particle size and fraction data (e.g., number or volume fractions). This file should include the particle size list and corresponding fraction values. -
allow_overlapping— Boolean.trueallows particles to overlap;falseprevents overlapping. -
initial_particles_only— Boolean. Iftrue, only initial particles are generated (no bridging or coating steps are applied). -
num_frac— Boolean. Iftrue, the code will use number-fraction data instead of volume-fraction data. -
voxel_size— Size of each voxel (units consistent with your input data). This sets the spatial resolution of the generated microstructure. -
ini_seeding_fraction— Fraction used to compute the seeding volume for the first half of the largest particle sizes. Example: if there are 10 particle sizes sorted from largest to smallest, the first 5 sizes are considered for seeding; the seeding volume for each of those sizes isini_seeding_fraction * (volume fraction of that particle size). -
criterion_of_num_particles— Integer threshold used for seeding decision: for sizes in the first half (largest sizes), if the particle count for that size is larger than this parameter, that size will be used as a seeding size. -
sz— Number of voxels in the x, y, and z directions (e.g.,[nx, ny, nz]). Defines the output array shape. -
vf_of_catalyst— Target total volume fraction for all initial particles (catalyst phase) in the generated microstructure. -
bridging_vf— Volume fraction reserved for bridging material. -
coating_vf— Volume fraction reserved for coating material. -
coating_thickness_voxels— Coating thickness specified in number of voxels. -
seed— Integer for reproducible random generation. Use the same value to get identical microstructures.