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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polysim-0.1.1.tar.gz.
File metadata
- Download URL: polysim-0.1.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13aa9ab46c49bc70fd424ffe83bf49053bf2d92e477615dc9bafe110be76a4cc
|
|
| MD5 |
7ecbade31c41d7ed6a57739d23f54500
|
|
| BLAKE2b-256 |
43f9e0673b1536d51b3daf543b15c2cec48b10f2810b17753c4e1f5899c85181
|
File details
Details for the file polySim-0.1.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: polySim-0.1.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 19.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d88927bcf7447ef52192b85aeae8e83781822cd869dbc1723e29f5351c6702ac
|
|
| MD5 |
a562d86735b930d4e653eccb87abff47
|
|
| BLAKE2b-256 |
d6fececb600497c9a017d0c3e8f986cf7b22a1b60a3a4a98927ea7b24dbef7e5
|
File details
Details for the file polySim-0.1.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: polySim-0.1.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 19.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91f0d728fb0614b4b57d64afed7996f4ae931d65c98c4635f58333eba821079b
|
|
| MD5 |
b4ae810b1acb6bb7158629168c835ddf
|
|
| BLAKE2b-256 |
accd472a491ff48192a813abc531aa39336d0be922a9d216980ce1d38830a236
|
File details
Details for the file polySim-0.1.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: polySim-0.1.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 19.3 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2371a87227f94a2f76e6987d96817cc4be6a8078dd633bb121a46325c42c0c1a
|
|
| MD5 |
e1f6ee7bb9fc8bac06a1b4571e2e1d3e
|
|
| BLAKE2b-256 |
b6bd154355287f9d1308eafe7607405bde66e535c9581a34684b8550fcd19adc
|
File details
Details for the file polySim-0.1.1-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: polySim-0.1.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 19.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59ebcc5855c54161a014c0f5965a33af2eb44a1be2581624cbc878683429cad6
|
|
| MD5 |
93e566c8b19ac67ee0e4fd814f9fc632
|
|
| BLAKE2b-256 |
52011c2ce6029f9e4638a0a9c6bd98591f33ae384786c97c365b2e86561496c8
|
File details
Details for the file polySim-0.1.1-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: polySim-0.1.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 19.3 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8ed0857053480210dd37c21f56bde7cb192d253c7e81371f42bbbbbfdcdf3e7
|
|
| MD5 |
817413660a0beef6c85e6b65f6600fb1
|
|
| BLAKE2b-256 |
352b5664f1c8dff75e0152eac6b6551e4d19767758d747e9a061026a6dc06138
|
File details
Details for the file polySim-0.1.1-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: polySim-0.1.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 19.2 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
327636554b32dae6a753da9fcd5f1467081b76a38ca4b266abca65a95002c024
|
|
| MD5 |
a0475e302bf8add799a57b292ffc30c1
|
|
| BLAKE2b-256 |
f37d61a7c3c982e6141a25a56e8e8cbbeb6213283e0d4313c2739037eb61e118
|