Skip to main content

SynthetMic-CLI

About

SynthetMic-CLI is a command line interface for generating 2D and 3D synthetic polycrystalline microstructures using Laguerre tessellations. It uses the fast algorithms (developed in this paper) for generating grains of prescribed volumes using optimal transport theory. It is built on top of SynthetMic package which is the Python implementation of the fast algorithms.

Installation

To install the latest version of the CLI via pip, run

pip install synthetmic-cli

If you are using uv to manage your project, run the following command instead:

uv add synthetmic-cli

Usage

All the available commands in the CLI can be checked by running

sm --help

Each of these commands are explained as follows.

  1. sample-seeds samples random seeds in a box with dimension specfied by BOX_SPECS. For instance, to sample 1000 random seeds in a unit cube (this means seeds will be generated in the domain [0, 1] x [0, 1] x [0, 1]) and save the results in the path ./mydir/seeds.csv, run

    sm sample-seeds 1 1 1 --n-grains 1000 --save-path ./mydir/seeds.csv
    

    You can check all other options under this command by running

    sm sample-seeds --help

  2. sample-spvols samples single phase target volumes using box dimension given by BOX_SPECS. By default, this command generates constant target volumes, but users can choose from other distributions including uniform and log-normal distributions. For example, to generate constant target volumes for 1000 grains in a unit cube and save the results to ./mydir/vols.csv, one runs

    sm sample-spvols 1 1 1 --n-grains 1000 --save-path ./mydir/spvols.csv
    

    Other options under this command can be checked by running

    sm sample-vols --help

  3. sample-dpvols samples dual phase targe volumes in a box specified by BOX_SPECS. This command allows specifying different volume distribution for each phase of the microstructure. For instance, one can specify uniform distribution on phase 1 and log-normal for phase 2 in a unit cube of 1000 grains:

    sm sample-dpvols 1 1 1 --n-grains 1000 --dist-params1 uniform 1 2 --dist-params2 lognormal 1 0.35 --save-path ./mydir/dpvols.csv
    

    Note: --dist-params1 uniform 1 2 means sample from uniform distribution with parameters a = 1 and b = 2 for phase 1; --dist-params2 lognormal 1 0.35 means sample from lognormal distribution with parameters mean = 1 and std = 0.35 for phase 2.

    Other options under this command can be checked by running

    sm sample-dpvols --help

  4. describe prints out information about seeds or target volumes saved in PATH. For instance, to print out information about seeds saved in ./mydir/seeds.csv, run

    sm describe ./mydir/seeds.csv
    
  5. generate generates synthetic microstructure with box specs BOX_SPECS, seeds saved in SEEDS_PATH, and target volumes saved in TARGET_VOLS_PATH. For example, to generate microstructure in a unit cube with seeds in ./mydir/seeds.csv and target volumes in ./mydir/dpvols.csv; and save all results to ./mydir/results.zip, we run

    sm generate 1 1 1 ./mydir/seeds.csv ./mydir/dpvols.csv --save-path ./mydir/results.zip
    

    To see all options under this command, run

    sm generate --help

Build from source

If you would like to build this project from source either for development purposes or for any other reason, it is recommended to install uv. This is what is adopted in this project. To install uv, follow the instructions in this link.

If you don't want to use uv, you can use other alternatives like pip.

The following instructions use uv for set up.

  1. Clone the repository by running

    git clone https://github.com/synthetic-microstructures/synthetmic-cli
    
  2. Create a python virtual environment by running

     uv venv .venv --python PYTHON_VERSION
    

    Here, PYTHON_VERSION is the supported Python version. Note that this project requires version >=3.11

  3. Activate the virtual environment by running

    source .venv/bin/activate
    
  4. Prepare all modules and dependencies by running the following:

    uv sync --all-extras
    

Authors and maintainers

Metadata

Release files for synthetmic-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synthetmic-cli 0.1.0
File Size Uploaded
synthetmic_cli-0.1.0.tar.gz 156.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for synthetmic-cli 0.1.0
File Interpreter ABI Platform
synthetmic_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 170.2 kB

Release files / synthetmic_cli-0.1.0.tar.gz

Download URL synthetmic_cli-0.1.0.tar.gz
Size 156.7 kB
Tags Source
SHA-256 checksum
How to use checksums
edd5cd3e8ddd7945e7bc1f36c52c1652bf65b3110423bdc3d31abe8a86d7f3d1
BLAKE2b-256 checksum
How to use checksums
cf7e92e546b30a1344ef0f93a8d3769b69b1717094d088f2044d4c0ed2372d8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.15

Release files / synthetmic_cli-0.1.0-py3-none-any.whl

Download URL synthetmic_cli-0.1.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a166d55c57a5c30d573cd2e2f5f243af8891999fb63b44a8652df51bf2cd340c
BLAKE2b-256 checksum
How to use checksums
13d44f5e8c3e78044766c8de022b73b42f11d5554fccefe310f552750b1fac7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.15

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page