Kanapy is a python package for generating complex synthetic polycrystalline microstructures. The general implementation is done in Python with the performance critical part implemented in C++. The Python bindings for the code written in C++ are generated using the lightweight header-only library pybind11. The C++ part of the implementation utilizes the Eigen library for efficient linear algebra calculations.
An accurate representation of the material microstructure is fundamental in understanding the relationship between microstructure and its corresponding mechanical behavior. In this regard, Kanapy is developed to be a robust and an efficient tool to generate synthetic microstructures within the micro mechanical framework for Finite Element Method (FEM) simulations. It is designed not only to provide an alternative to the existing Random Sequential Addition technique of microstructure generation, but also to model simple and complex grain morphologies, thus overcoming the limitations of spatial tessellation methods.
- User interfaces to kanapy through scripts are written in pure Python.
- Grains are approximated by ellipsoids (particles) and are packed into a pre-defined domain representing RVE.
- Efficient collision handling of particles through a two-layer collision detection method employing the Octree spatial data structure and the bounding sphere hierarchy.
- In-built hexahedral mesh generator for complex polycrystalline microstructures.
- Independent execution of individual modules through easy data storage and handling.
- Flexibility in the choice of the particle packing time step to be sent for voxelization (meshing).
- Option to generate spherical particle position- and radius files that can be read by the Voronoi tessellation software Neper.
- Option to generate input files for the commercial finite-element software Abaqus.
- High-performance for the critical part of the code using Python-C++ bindings.
CMake is used for building extensions; if it is not installed on your machine, follow this CMake documentation to install it.
The preferred method to install kanapy is through Anaconda or Miniconda Python distributions. If you do not have any, we suggest installing miniconda.
Once done, create a virtual environment for installing Python-specific packages required for kanapy and activate it.
$ conda create -n myenv python=3.6 pip git
$ conda activate myenv
Note
myenv
can be replaced with any name for your environment.- For older versions of anaconda/miniconda use:
source activate myenv
Tip
To learn more about managing environments see Anaconda documentation.
You can either clone the kanapy public repository by using git or download the kanapy source code from the Github repo to a desired location.
(myenv) $ git clone https://github.com/mrgprasad/kanapy.git <location to clone>/kanapy-master
(myenv) $ cd kanapy-master/
(myenv) $ conda install -y -c conda-forge --file requirements.txt
(myenv) $ pip install -e .
Kanapy is now installed along with all its dependencies.
Kanapy uses pytest
to perform all its unit testing. From the kanapy main directory (kanapy-master
), run the tests:
(myenv) $ pytest tests/ -v
Documentation for kanapy is generated using Sphinx
. The following command generates a HTML-based reference documentation;
for other formats, please refer to the Sphinx manual. From the kanapy main directory (kanapy-master
), do:
(myenv) $ cd docs/
(myenv) $ make clean && make html
The HTML documentation can be found at /kanapy-master/docs/index.html
.
Kanapy requires a working C/C++ compiler on your machine. On Linux/Mac OS,
the gcc toolchain will work well. The lightweight header-only library pybind11
is used to create Python bindings for the code written in C++.
The C++ function will be complied by linking the Eigen library
(present in the directory /kanapy-master/libs/
). CMake builds this extension.
Below are the listed dependencies for running kanapy:
- Matplotlib for plotting and visualizing.
- OVITO for visualizing simulation data.
The preferred way to cite Kanapy is:
Prasad et al., (2019). Kanapy: A Python package for generating complex synthetic polycrystalline microstructures. Journal of Open Source Software, 4(43), 1732, https://doi.org/10.21105/joss.01732
Kanapy is made available under the MIT license.
The name kanapy is derived from the sanskrit word káṇa meaning particle. Kanapy is primarily developed at the Interdisciplinary Center for Advanced Materials Simulation (ICAMS), Ruhr-University Bochum - Germany. Our goal is to build a complete synthetic microstructure generation tool for research and industry use.