MicroStructPy A Statistical Microstructure Mesh Ge
MicroStructPy A Statistical Microstructure Mesh Ge
SoftwareX
journal homepage: www.elsevier.com/locate/softx
article info a b s t r a c t
Article history: MicroStructPy is a statistical microstructure mesh generator written in Python. This software package
Received 8 July 2020 includes classes and methods to generate a mesh by (i) creating a list of grain seed geometries,
Received in revised form 25 August 2020 (ii) packing them into a domain, (iii) performing a Laguerre tessellation of the seed geometries,
Accepted 10 September 2020
and (iv) performing quality unstructured meshing. Results can be visualized and compared with the
Keywords: specified microstructural properties. MicroStructPy accurately reproduces 2D and 3D polycrystalline
Microstructure microstructures with arbitrary number of phases, volume fractions and distributions, each including
Mesh generation the possibility of elongated grains. It can also generate meshes for amorphous phases and porous
Polycrystal materials. Meshes are suitable for direct numerical simulation, a prevalent technique in computational
Laguerre tessellation mechanics of materials and geomechanics. The package contains extensive documentation, including
guides and demonstrations to facilitate adoption for new users.
© 2020 The Author(s). Published by Elsevier B.V. This is an open access article under the CC BY license
(http://creativecommons.org/licenses/by/4.0/).
Code metadata
1. Motivation and significance thermal conductivity of materials [3,4]. Finally, additive man-
ufacturing can create anisotropic bulk material properties from
The response of a material is significantly influenced by the an isotropic build material [5]. Precise and reliable prediction of
properties and composition of its constituents, hereafter referred macroscale material properties from the microscale constituents
to as the microstructure of the material. Observations of steel is currently an active area of research. Modern prediction tech-
indicate that specimen with smaller grains have higher ultimate niques often rely on direct numerical simulation (DNS), whereby
relevant properties and boundary conditions are applied to a
strength [1,2]. Grain size and aspect ratio also influence the
representative volume element (RVE) mesh.
There are several techniques to characterize the microstruc-
∗ Corresponding author. ture of a material. Each of these characterizations is associ-
E-mail address: [email protected] (J.J. Rimoli). ated with several more techniques to virtually reconstruct the
1 Ph.D. Candidate, Daniel Guggenheim School of Aerospace Engineering. microstructure. Modern scanning techniques include 3-D X-ray
2 Associate Professor, Daniel Guggenheim School of Aerospace Engineering. diffraction (3D-XRD) and X-ray tomography, which generate a
https://doi.org/10.1016/j.softx.2020.100595
2352-7110/© 2020 The Author(s). Published by Elsevier B.V. This is an open access article under the CC BY license (http://creativecommons.org/licenses/by/4.0/).
K.A. Hart and J.J. Rimoli SoftwareX 12 (2020) 100595
Fig. 1. The microstructure mesh generation process. A textual description of the microstructure is converted, through steps described below, into an unstructured
triangular or tetrahedral mesh. Statistics of the mesh can be compared against those prescribed, to ensure microstructure fidelity.
voxel raster of the microstructure [6,7]. These rasters can be 2. Software description
directly converted into a microstructural mesh for high-fidelity
DNS [8]. The raster can also be converted into n-point correlation 2.1. Software architecture
functions, which compress the microstructure data into several
functions [9]. Correlation functions can be inverted to generate MicroStructPy follows four principal steps to generate the
multiple realizations of the same microstructure using global mesh of a microstructure, as shown in Fig. 1: (i) packing seed
optimization and phase recovery [10]. The raster can also be geometries into the domain, (ii) converting seeds into multi-
converted into statistical distributions, such as volume fractions circle/multi-sphere approximations, (iii) tessellating the domain
and grain volume distributions [11]. These distributions can be to create a polygonal/polyhedral mesh, and (iv) quality unstruc-
used to reconstruct the microstructure by packing seed geome- tured meshing to create a triangular/tetrahedral mesh. For veri-
tries together, then creating a dual such as the Laguerre–Voronoi fication, the statistics of the output mesh are compared against
diagram [12,13] or the barycentric dual [14]. The work presented the desired statistics for the microstructure, which are specified
in the input file. The methods associated with each of these steps
follows this paradigm due to the prevalence and availability
are described in the following subsections.
of volume fractions and grain size distributions for multiple
materials.
2.1.1. Seed geometries
In this paper we introduce MicroStructPy, a statistical mi-
Generating seed geometries and packing them into a domain
crostructure mesh generator written in Python [15]. MicroStructPy
are the first steps in creating a microstructure. In MicroStructPy,
is part of a growing ecosystem of open source microstructure
the information about the microstructure is included in an input
mesh generators which cover different needs through varying file, which contains specifications for each constituent phase, as
functionalities. Neper, for instance, produces statistically repre- well as a definition of the geometry of the domain. This informa-
sentative microstructures by optimizing the location and weight tion is used to create an initial list of un-positioned seeds. The
of tessellation points [13,16]. The Dream.3D software produces volume fraction, Vf , and average grain volume, E [V ], are used to
microstructural meshes using a general system of pipelines [17]. determine the population density, n, of each phase according to
Finally, PuMA is a microstructure software that is specialized Eq. (1), where the subscript i indicates the population density of
for porous materials, such as fiber-reinforced composites and the ith phase. Since ni is the number of grains of phase i per unit
foams [18]. MicroStructPy is unique in that it reproduces sta- volume, the probability that a given grain belongs to this phase
tistical microstructure distributions without the need for opti- is given by Eq. (2).
mization and it can create elongated grains, using a multi-sphere Vf , i
approach [19]. ni = (1)
E [Vi ]
The reminder of this paper is organized as follows. Section 2 ni
describes the software architecture and functionality, including pi = ∑ (2)
j nj
a snippet of the most important methods. Section 3 contains
an illustrative example. Finally, Section 4 discusses the impact The list of un-positioned grains is therefore created by sam-
that MicroStructPy has on the research community and Section 5 pling a categorical distribution with weights pi to determine the
concludes the work. phase of a seed, sampling the distributions associated with that
2
K.A. Hart and J.J. Rimoli SoftwareX 12 (2020) 100595
N
1 ∑ 2
r = √x2c + y2c + (xi + y2i ) (7)
N
i=1
microstructure into a mesh suitable for DNS. The code presented 8 ’area ’: scipy.stats. lognorm (s=0.5 , scale =0.5) ,
can produce microstructure meshes with any number of material 9 ’fraction ’: 0.7,
phases. These phases can be crystalline, amorphous, or voids in 10 }
11 phase_1 = {
the material. The size, shape, orientation, and position of these 12 ’color ’: ’#43 CEA2 ’,
constituents can be directly controlled using any distribution in 13 ’shape ’: ’ellipse ’,
the SciPy statistical module. . Other microstructure codes in- 14 ’area ’: scipy.stats. uniform (loc =0.5 , scale =2) ,
dividually possess a subset of these capabilities. This positions 15 ’aspect_ratio ’: 2,
16 ’angle ’: ’random ’,
MicroStructPy very well in the scientific community. We believe
17 ’fraction ’: 0.3,
its capabilities will enable the research of phenomena not studied 18 }
before, e.g., the influence of combined microstructural statistics 19 p = [phase_0 , phase_1 ]
such as grain size, elongation, and orientation simultaneously, on 20 # Inputs - Domain
the effective response of advanced materials. 21 d = msp. geometry . Rectangle ( limits =[(0 , 20) , (0,
35) ])
MicroStructPy is unique not only because it provides all of 22 # Inputs - Settings
these capabilities but also because it is written in the Python 23 min_ang = 15 # degrees
language. The Python implementation of the code enables rapid 24
5
K.A. Hart and J.J. Rimoli SoftwareX 12 (2020) 100595
[12] Fan Z, Wu Y, Zhao X, Lu Y. Simulation of polycrystalline structure with [20] Ilin DN, Bernacki M. Advancing layer algorithm of dense ellipse packing
Voronoi diagram in Laguerre geometry based on random closed packing for generating statistically equivalent polygonal structures. Granul Matter
of spheres. Comput Mater Sci 2004;29(3):301–8. http://dx.doi.org/10.1016/ 2016;18(3):43. http://dx.doi.org/10.1007/s10035-016-0646-9.
j.commatsci.2003.10.006. [21] Aurenhammer F. Power diagrams: Properties, algorithms and applications.
[13] Quey R, Renversade L. Optimal polyhedral description of 3D polycrystals: SIAM J Comput 1987;16(1):78–96. http://dx.doi.org/10.1137/0216006.
Method and application to statistical and synchrotron X-ray diffraction [22] Rycroft CH. VORO++: A three-dimensional Voronoi cell library in c++. Chaos
data. Comput Methods Appl Mech Engrg 2018;330:308–33. http://dx.doi. 2009;19(4):041111. http://dx.doi.org/10.1063/1.3215722, arXiv:0402209.
org/10.1016/j.cma.2017.10.029. [23] Shewchuk JR. Triangle: Engineering a 2D quality mesh generator and
[14] Rimoli JJ, Ortiz M. A duality-based method for generating geomet- delaunay triangulator. In: Lin MC, Manocha D, editors. Applied compu-
ric representations of polycrystals. Internat J Numer Methods Engrg tational geometry towards geometric engineering. Berlin: Springer; 1996,
2011;86(9):1069–81. http://dx.doi.org/10.1002/nme.3090. p. 203–22. http://dx.doi.org/10.1007/BFb0014497.
[15] Hart KA, Rimoli JJ. Microstructpy (version 1.3.2). 2020, http://dx.doi.org/ [24] Si H. Tetgen, a delaunay-based quality tetrahedral mesh generator. ACM
10.5281/zenodo.3940607. Trans Math Software 2015;41(2):11. http://dx.doi.org/10.1145/2629697.
[16] Quey R, Dawson PR, Barbe F. Large-scale 3D random polycrystals for [25] Halır R, Flusser J. Numerically stable direct least squares fitting of ellipses.
the finite element method: Generation, meshing and remeshing. Comput In: Proc. 6th international conference in central europe on computer
Methods Appl Mech Engrg 2011;200(17–20):1729–45. http://dx.doi.org/10. graphics and visualization. Plzen, Czech Republic. 1998. p. 125–32.
1016/j.cma.2011.01.002. [26] Hammel B, Sullivan-Molina N. Bdhammel/least-squares-ellipse-fitting:
[17] Groeber MA, Jackson MA. DREAM.3D: A digital representation environment v2.0.0. 2020, http://dx.doi.org/10.5281/zenodo.3723294.
for the analysis of microstructure in 3D. Integrating Mater Manuf Innov [27] Turner D, Anderson I, Mason J, Cox M. An algorithm for fitting an
2014;3(1):5. http://dx.doi.org/10.1186/2193-9772-3-5. ellipsoid to data. Tech. rep., Teddington, United Kingdom: National Physical
[18] Ferguson JC, Panerai F, Borner A, Mansour NN. Puma: the porous mi- Laboratory; 1999.
crostructure analysis software. SoftwareX 2018;7:81–7. http://dx.doi.org/ [28] Kolmogorov A. Sulla determinazione empirica di una legge di distribuzione.
10.1016/j.softx.2018.03.001. Istituto Italiano degli Attuari, Giornale 1933;4:83–91.
[19] Hart KA, Rimoli JJ. Generation of statistically representative microstruc- [29] Smirnov NV. Estimate of deviation between empirical distribution
tures with direct grain geomety control. Comput Methods Appl Mech Engrg functions in two independent samples. Bull Moscow Univ 1939;2(2):3–16.
2020;370:113242. http://dx.doi.org/10.1016/j.cma.2020.113242. [30] Székely GJ. E-statistics: The energy of statistical samples. Tech. rep.,
Bowling Green, Ohio: Bowling Green State University, Department of
Mathematics and Statistics; 2003.