Skip to main content

Polycrystalline microstructure simulation package

Project description

polySim Version: 0.1.1 License: MIT License Author: Nikhil Chaurasia, Sandeep Sangal and Shikhar K. Jha Email: nikolspace@gmail.com

#Table of Contents

#Introduction

#Features

#Installation

#Usage Importing the Package Function: generate_structure Function Signature Parameters Returns Example

#Dependencies

#Contributing

#License

#Introduction

polySim is a Python package designed for simulating polycrystalline microstructures. It provides a high-performance implementation of grain growth simulations using a combination of Python and C++ for computational efficiency.

This package is particularly useful for researchers and engineers working in materials science, metallurgy, and related fields who need to simulate and analyze the evolution of grain structures in polycrystalline materials.

#Features

Simulate polycrystalline microstructures with customizable parameters. High-performance computation using a C++ backend. Easy-to-use Python interface. Outputs include the generated microstructure image, number of grains, and Avrami exponent. Supports visualization of the generated microstructure using matplotlib.

Installation

Before installing, ensure you have the following prerequisites:

Python 3.7 or higher

NumPy

Matplotlib (optional, for visualization)

Install via pip

You can install polySim directly from PyPI:

pip install polySim

If you prefer to build from source:

Clone the repository or download the source code.

Navigate to the root directory of the project.

Install the package using pip:

pip install .

Usage Importing the Package

import numpy as np

from polySim import generate_structure

Function: generate_structure

#Function Signature

generate_structure(img, nucleation_rate, growth_rate, height=300, randomize_gray_values=True) Parameters

img (numpy.ndarray of uint16):

A 2D NumPy array representing the initial image where the microstructure will be generated. Must be initialized (e.g., with zeros) and of type uint16. Shape: (height, width) nucleation_rate (int):

The number of nucleation sites introduced per iteration. Controls the rate at which new grains are formed. Expected Values: Positive integer (e.g., 10) growth_rate (float):

The growth rate of the grains per iteration. Determines how quickly grains expand over time. Expected Values: Positive float (e.g., 0.5, 1.0) height (int, optional, default=300):

generated_img (numpy.ndarray of uint16):

The resulting image array representing the generated polycrystalline microstructure. Shape: Same as the input img num_grains (int):

The total number of grains generated in the simulation. Description: Useful for quantitative analysis of the microstructure.

avrami_exponent (float):

The calculated Avrami exponent from the simulation. Description: A parameter related to the kinetics of grain growth.

#Example

import numpy as np

from polySim import generate_structure

from matplotlib import pyplot as plt

Define simulation parameters

img = np.zeros((500, 500), dtype=np.uint16)

nucleation_rate = 10

growth_rate = 1.0

height = 300

Run the simulation

generated_img, num_grains, avrami_exponent = generate_structure( img, nucleation_rate, growth_rate, height, )

Output the results

print("Number of Grains:", num_grains)

print("Avrami Exponent:", avrami_exponent)

Visualize the generated microstructure

plt.imshow(generated_img, cmap='gray')

plt.title('Generated Polycrystalline Microstructure')

plt.xlabel('X')

plt.ylabel('Y')

plt.colorbar(label='Grain ID')

plt.show()

#Explanation of the Example:

Initialization:

An empty image of size 500x500 pixels is created. The nucleation rate is set to 10 grains per iteration. The growth rate is set to 1.0 units per iteration. The simulation runs for 300 iterations (layers). Running the Simulation:

The generate_structure function is called with the specified parameters. It returns the generated image, number of grains, and Avrami exponent. Output and Visualization:

The number of grains and Avrami exponent are printed to the console. The generated microstructure is visualized using matplotlib.

#Dependencies

NumPy: For numerical computations and array manipulations.

Matplotlib (optional): For visualizing the generated microstructure.

C++ Compiler: Required if installing from source to compile the extension module.

Contributing

Contributions are welcome! If you have ideas for improvements or encounter any issues, please:

Fork the repository. Create a new branch for your feature or bug fix. Commit your changes with clear commit messages. Submit a pull request describing your changes. Please ensure that your contributions adhere to the project's coding standards and pass all tests.

License This project is licensed under the terms of the MIT License.

MIT License

MIT License

Copyright (c) 2023 Nikhil Chaurasia

Permission is hereby granted, free of charge, to any person obtaining a copy... For the full license text, see the LICENSE file included with this project.

Contact For questions, suggestions, or support, please contact:

Email: nikolspace@gmail.com GitHub: nikolspace Acknowledgments Special thanks to all contributors and the open-source community for their valuable work and support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polysim-0.1.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

polysim-0.1.2-cp312-cp312-win_amd64.whl (18.5 kB view details)

Uploaded CPython 3.12Windows x86-64

polysim-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

polysim-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (18.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polysim-0.1.2-cp311-cp311-win_amd64.whl (18.5 kB view details)

Uploaded CPython 3.11Windows x86-64

polysim-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

polysim-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (18.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polysim-0.1.2-cp310-cp310-win_amd64.whl (18.5 kB view details)

Uploaded CPython 3.10Windows x86-64

polysim-0.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

polysim-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (18.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polysim-0.1.2-cp39-cp39-win_amd64.whl (18.5 kB view details)

Uploaded CPython 3.9Windows x86-64

polysim-0.1.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (39.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

polysim-0.1.2-cp39-cp39-macosx_11_0_arm64.whl (18.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file polysim-0.1.2.tar.gz.

File metadata

  • Download URL: polysim-0.1.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polysim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 67c24f6da3cb26b890c368e70039ebde75602e023ce0eef5b89b6ff7917ec74b
MD5 ccdf0fa33fd94e63127efecaef5e9788
BLAKE2b-256 9b712126a9651be55401d868e3922f3ef207b854419bcf31d6aafa05d0e5dc82

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2.tar.gz:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: polysim-0.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polysim-0.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 533c084e994deeb4cbc5fc60d865ae3ece8769d8aa98e32b19d054facd9ab87a
MD5 3eb26649f00efc8c8c1d97f2dbce49e4
BLAKE2b-256 99f8b38d47885188bd28b4c523f63625c692af51c3e78e12eb6ed8bfb269e7d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 44f9e6ddeb43550edbd159416e2dcd3a553fccc1863dc521ea7d1e120d365ee8
MD5 e84e51fd3880c47c83a0397dc1066924
BLAKE2b-256 730300b0bafbdf056c547c9d47ca245f943161a4aad7de28128147342ad293cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f2302d2461efa9be909cd10ff5d732399c8f12b4ba84d52dadb264e534af4a7
MD5 a0c99e80e1c61b3b2d4d4f1a2759f2b8
BLAKE2b-256 0d919d09ddc7552628ab6cfa9c335c4a53091f29eeb79ffff5327857a046d9ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: polysim-0.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polysim-0.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 694e331d6c61112017db3af22fa1802d50de51a849673b17c866d360fd5ae0e5
MD5 3b4ac33d62a3c1c5db7fb20263b2214c
BLAKE2b-256 af44a5069e7a26ddac6d98215b119dbd5e1ad38c0b74110c8ae7ac376ff89949

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b263d15d78e1654b41eea5a3c5962ed8765cb123517182d8dfe690ee8bc42c47
MD5 610034848f4e1f2be7587d546733c3b1
BLAKE2b-256 708eab46b1539ee28fd9290d493eca4ac8c68308bad51ff37d9a30f3e8f21395

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 751956c92efbaa002c8b6a8efa3c9b06a9f065663b45571342391effaa24d2d4
MD5 1310f75ebc306da0158b127e76c375be
BLAKE2b-256 e9c1e051eedcccaf99c9712f6b3c6f493bf8955616c9cf6554422d4d6cc6307f

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: polysim-0.1.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polysim-0.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 12423c4fa5d3eb69287128ed9c28e03a8dee128950a84486cf1f3badeef3378e
MD5 13a6ed77063ff05c6763a6d9e48f2047
BLAKE2b-256 ff9adea8dbde0d18636dfb27bd01e5251ce70319a1df26215e08dd4c57997e2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 317026d5c9439b978997e5db8694fe65597fc9eebd8cbee706bc8f8ed642b43b
MD5 7d568cb44ee61ee4df53d19f9ee3c8a9
BLAKE2b-256 ee1d9c0211cd63ae7f5218569fce5ac0e78a4846b082da327c59339436aaaa1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f6af545f26d89431a11a5c1d32b083e292c57c6041c2ba27bead7ecb1a7b3c8
MD5 214bee508c4a7ac802c6e46c55024bea
BLAKE2b-256 6b429527fea66c38a61752c74a2ff17876bd19dcdd9e0a7dce972a2fbd3f7a73

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: polysim-0.1.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polysim-0.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 607d2da1612b0031305902dc20d5582dd635abaa8b24faf45aed32d102c30a9a
MD5 04d09a5d41a58c67678398c46555a8fe
BLAKE2b-256 d6c08004605eb35bd42f9c2cd986eae6f91ddf0f3719c174fde620830773afac

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp39-cp39-win_amd64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 111239093341fed3701fddd7a8d8751b91127965e2c7d0fe07789e45e56b2fef
MD5 3f770578fbbd6b4a2d7148241c672094
BLAKE2b-256 aa4eb85df62cf5c795deeb5855103c6fbe3490c32b4b7dff80cf55dd96c784fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polysim-0.1.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polysim-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7593ecca32dbfe4272b1fe734f9d777c01bd1dea9264d01a8b9fc1cb11b2672f
MD5 6b93aa89739044cced36acd0aea3d225
BLAKE2b-256 838b2c45922928610fe1da8eb62e9d059ad1fb912de154f5af7d7320630941ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for polysim-0.1.2-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: wheels.yml on nikolspace/polySim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page