microstructpy.verification¶
Verification
This module contains functions related to mesh verification.

microstructpy.verification.
error_stats
(fit_seeds, seeds, phases, poly_mesh=None, verif_mask=None)[source]¶ Error statistics for seeds
This function creates a dictionary of error statistics for each of the input distributions in the phases.
 Parameters
fit_seeds (SeedList) – List of seeds of best fit.
seeds (SeedList) – List of seeds.
phases (list) – List of input phase dictionaries.
poly_mesh (PolyMesh) – (optional) Polygonal/polyhedral mesh.
verif_mask (list or numpy.ndarray) – (optional) Mask for seeds to be included in the analysis. Defaults to all True.
 Returns
List with the same size and dictionary keywords as phases, but with error statistics dictionaries in each entry.
 Return type

microstructpy.verification.
mle_phases
(seeds, phases, poly_mesh=None, verif_mask=None)[source]¶ Get maximum likelihood estimators (MLEs) for phases
This function finds distributions in the list of phases and computes the MLE parameters for those distributions. The returned value is a list of phases with the same length and dictionary keywords, except the distributions are replaced with MLE distributions (based on the seeds). Constant values are replaced with the mean of the seed values.
Note that the directional statistics are not used  so the results for orientation angles and matrices are unreliable.
Also note that SciPy currently does not support MLEs for discrete random variables. Any discrete distributions will be given a histogram output.
Note
Directional statistics are not used and as such the results for orientation angles and matrices are unreliable. The only exception is normally distributed orientation angles.
 Parameters
seeds (SeedList) – List of seeds.
phases (list) – List of input phase dictionaries.
poly_mesh (PolyMesh) – (optional) Polygonal/polyhedral mesh.
verif_mask (list or numpy.ndarray) – (optional) Mask for which seeds to include in the MLE parameter calculation. Default is True for all seeds.

microstructpy.verification.
plot_distributions
(seeds, phases, dirname='.', ext='png', poly_mesh=None, verif_mask=None)[source]¶ Plot comparison between input and output distributions
This function takes seeds and compares them against the input phases. A polygon mesh can be included for cases where grains are given an area or volume distribution, rather than size/shape/etc.
This function creates both PDF and CDF plots.
 Parameters
seeds (SeedList) – List of seeds to compare.
phases (list) – List of phase dictionaries.
dirname (str) – (optional) Plot output directory. Defaults to
.
.ext (str or list) – (optional) File extension(s) of the output plots. Defaults to
'png'
.poly_mesh (PolyMesh) – (optional) Polygonal mesh, useful for phases with an area or volume distribution.
 Returns
none, creates plot files.

microstructpy.verification.
plot_volume_fractions
(vol_fracs, phases, filename='volume_fractions.png')[source]¶ Plot volume fraction verification
This function creates a bar chart comparing the input and output volume fractions. If the input volume fraction is distributed, the top of the bar will be a curve representing the CDF of the distribution.
 Parameters
vol_fracs (list or numpy.ndarray) – Output volume fractions.
phases (list) – List of phase dictionaries
filename (str or list) – (optional) Filename(s) to save the plot. Defaults to
volume_fractions.png
.
 Returns
none, writes plot to file.

microstructpy.verification.
seeds_of_best_fit
(seeds, phases, pmesh, tmesh)[source]¶ Calculate seed geometries of best fit
This function computes the seeds of best fit for the resultant polygonal and triangular meshes. It calls the the
best_fit
function of each seed’s geometry, then copies the other seed attributes to create a newSeedList
.The points on the faces of the grains are used to determine a fit geometry. Points on the exterior of the domain are not used since they would alter the shape of the best fit seed.
 Parameters
seeds (SeedList) – List of seed geometries.
phases (list) – List of material phases. See Phase Dictionaries for more information on formatting.
pmesh (PolyMesh) – Resultant polygonal/polyhedral mesh.
tmesh (TriMesh) – Resultant triangular/tetrahedral mesh.
 Returns
List of seeds of best fit.
 Return type

microstructpy.verification.
volume_fractions
(poly_mesh, n_phases)[source]¶ Verify volume fractions
This function computes the volume fractions of each phase in the output mesh. It does so by summing the volumes of the cells in the polygonal mesh.
 Parameters
 Returns
Volume fractions of each phase in the poly mesh.
 Return type

microstructpy.verification.
write_error_stats
(errs, phases, filename='error_stats.txt')[source]¶ Write error statistics to file
This function takes previously computed error statistics and writes them to a humanreadable text file.
 Parameters
errs (list) – List of error statistics for each input phase parameter. Organized the same as
phases
.phases (list) – List of input phases. See Phase Dictionaries for more details.
filename (str) – (optional) The name of the file to contain the error statistics. Defaults to
error_stats.txt
.

microstructpy.verification.
write_mle_phases
(inp_phases, out_phases, filename='mles.txt')[source]¶ Write MLE parameters in a table
This function writes out a text file containing the input parameters and maximum likelihood estimators (MLEs) for the outputs.

microstructpy.verification.
write_volume_fractions
(vol_fracs, phases, filename='volume_fractions.txt')[source]¶ Write volume fractions to a file
Write the volume fractions verification out to a file. The output columns are:
Phase number
Phase name
Input relative volume (average, if distributed)
Output relative volume
Input volume fraction (average, if distributed)
Output volume fraction
The first three lines of the output file are headings.
 Parameters
vol_fracs (list or numpy.ndarray) – Volume fractions of the output mesh.
phases (list) – List of phase dictionaries.
filename (str) – (optional) Name of file to write. Defaults to
volume_fractions.txt
.
 Returns
none, prints formatted volume fraction verification table to file