Skip to content

Repository files navigation

Microstructure_Generation

Small collection of Python tools to generate and analyse microstructures for electrochemical systems.

Contents

  • MicrostructureGeneratorPython/ — Python implementations and utilities for particle generation and coatings.
  • environment.yaml — Conda environment specification used to install dependencies.

Quickstart

Prerequisites:

  • Conda or Mamba installed on your system.

Create the environment (using mamba for faster installs):

mamba env create -n env_name -f environment.yaml

Activate the environment:

conda activate env_name

If you don't have mamba, you can fall back to:

conda env create -f environment.yaml

Running the code

Python scripts: with the environment activated, run scripts from the MicrostructureGeneratorPython folder. Example:

python MicrostructureGeneratorPython/FastGenerationWithOrWithoutoverlapping.py

Adjust inputs and parameters in the script or use provided example files in input_examples/ as needed.

Notes

  • The environment.yaml file 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.

License & Contact

This repository is provided as-is. For questions or contributions, open an issue or contact the maintainer.

Parameters & Reproducibility

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. true allows particles to overlap; false prevents overlapping.

  • initial_particles_only — Boolean. If true, only initial particles are generated (no bridging or coating steps are applied).

  • num_frac — Boolean. If true, 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 is ini_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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages