This script demonstrates a systematic approach on how to get the most out of challenging PGR tasks by systematic tuning of the most critical parameters. The microstructure explored in this example is lath martensite, for which especially the reconstruction of annealing twins in the parent austenite phase is a challenging task. This is the same dataset that is explored in the general documentation for martensite Parent Grain Reconstruction.

As the script is quite long and some sections take some time to execute, I highly recommend running this script section-by-section. You ideally want to follow my talk at the MTEX User Meeting 2024 before or alongside exploring this script.

## Data Import

Let us begin by loading the MTEX documentation dataset on martensite from Ref. T. Nyyssönen, P. Peura, V.-T. Kuokkala, Crystallography, Morphology, and Martensite Transformation of Prior Austenite in Intercritically Annealed High-Aluminum Steel, Metall Mater Trans A 49 (2018) 6426–6441.

## Plot the EBSD data of the child phase

Let us first take a look at the example EBSD data.

We can see that the dataset only consists of lath martensite, the child phase in this transformation system, and unindexed points. Our aim is to accurately reconstruct the prior austenite microstructure, the parent microstructure in this example.

## Explore different threshold angles for child grain reconstruction

Let us explore some different threshold angles to reconstruct the child grains at different levels of detail.

From the child grain reconstructions it is apparent that in this dataset threshold values of 1 to 1.5° lead to a significant loss of EBSD data associated with small grains. Therefore only the range of 2-6° is feasible as a starting point for grain reconstruction.

## Effect of child grain reconstruction on PGR results

We will now carry out the PGR on child grains reconstructed with the identified angular threshold values. We will otherwise assume reasonable and constant parameters for the PGR to enable comparability. We compare the PGR results as received from the variant graph approach before any post-processing to enable reasonable comparison

The effect of child grain reconstruction appears to be quite prominent - the smaller the reconstruction threshold angle the more of the parent grain microstructure is confidently reconstructed. In martensitic steels the misorientation between the different variants is oftentimes quite low which means that grain reconstruction with too large threshold values merges grains that belong to different variants and thereby complicate the PGR. For this example, 2° seems to be the optimum, so we will move forward with that parameter.

## Optimizing the orientation relationship (OR)

Next we will check the effect of fitting the OR using the `calcParent2Child`

function vs. assuming several rational ORs on PGR.

The histogram plot shows that OR refinement yields an OR that is far more representative of the actual OR present in the microstructure. The Greninger-Trojano (GT) OR is closest to the fitted OR. Plotting the fit of the OR onto the grain boundaries showed that the fitted OR nicely outlines the grain boundaries of the parent grains, which is an important prerequisite for successful PGR.

## Tune parameters for OR refinement

The OR refinement using `calcParent2Child`

can be fine-tuned with custom choices for the parameters `threshold`

and `quantile`

. The `threshold`

value is the maximum misfit between the OR and grain misorientations to be considered for the optimization of the OR. The `quantile`

value defines which quantile of the misfit distribution (see previous histogram) is considered for optimization of the OR. Whichever criterion cuts off more of the available data will be enforced. The parameters are used to make sure that the parent grain boundaries, which are not OR-related boundaries, can be excluded from the OR refinement procedure in a controlled manner.

We only look at the 0° - 10° misfit range to better discern the effect of the different parameter sets. The parameter choice of the `calcParent2Child`

command did not cause drastic changes in the fit of the optimal OR. Threshold values of 10° gave a better fit than 5°, and a quantile value of 0.9 may be slightly better than 0.8. The threshold angle of 10° and the `quantile`

of 0.9 are the default values of the `calcParent2Child`

command. For your dataset, the quantile value should reflect the ratio between prior parent boundaries and OR-related boundaries. In the present case, prior austenite grains are large and filled with a very fine OR-related boundary structure within, meaning that the quantile value does not play a big role. If you have small prior parent grains with little internal OR-related boundary structure you should explore smaller quantile values.

## Translating the OR misfit into a probability function

Next, we need to translate the misfit between the OR and the grain misorientations \(\omega\) into an OR probability function \(\Psi\):

\begin{equation} \Psi(\omega) = 1 - \tfrac{1}{2}\left(1 + \mathrm{erf}(2 \tfrac{\omega - \delta}{\sigma})\right). \end{equation}

where \(\delta\) is a threshold value and \(\sigma\) is a tolerance value. The function tends to 1 for grain misorientations that agree well with the OR and to 0 for child grain misorientations that disagree strongly with the OR. The function therefore describes the probability with which two grains belong to the same parent grain. Let us plot this probability function on top of the OR misift distribution from before for few different combinations of the parameters `tolerance`

and `threshold`

.

It can be observed that the different parameter choices for `threshold`

and `tolerance`

give a different weighting to the misfit values. Let us now plot the function values directly onto the grain boundaries to decide which parameter set leads to the best separation of prior parent and OR-related boundaries.

We can see that a sharp tolerance of 1.5° and threshold value of 1.5° mark several boundaries as prior austenite boundaries, even though they are in the interior of what appears to be the prior austenite grains. Conversely, a very relaxed value pair of tolerance 2° and threshold 5° does not highlight boundaries that appear to be prior austenite boundaries. The value pair tolerance 2.5° and threshold 2.5° seems to deliver the best result. In the misfit distribution histogram, this parameter set nicely separates the mode of the distribution from the tail to the right. You will have to experiment with these parameters for your own microstructure to get the best possible PGR result.

## Evaluating effect of probability functions on PGR

Let us now explore the PGR results that are obtained using the different probability function values. The parameters defining the probability function are passed to the method `calcVariantGraph`

. This method sets up the variant graph, in which all possible parent variants of each grain are represented as nodes. The parent variants of neighboring grains are connected with edges that contain the computed OR probability values.

We can observe that in the case where the probability function did not lead to a good separation between prior-parent and OR-related boundaries fewer grains have been confidently reconstructed. The first two explored parameter sets give decent PGR result, with the first dataset (subjectively) looking slightly more complete. The difference here is however marginal. It is important to make this evaluation before any post-processing is applied to the reconstructed parent microstructure.

## The effect of clustering parameters on the PGR

Having identified an optimal probability function to translate the OR misfit into OR probabilities, the parameters during clustering can be explored. The variant graph relies on a Markovian clustering algorithm, which is originally reported in

and defined in the present application in

When iteratively applying the Markovian clustering algorithm to the variant graph, edges with high probability are further strengthened and edges with low probability are further weakened, leading to eventual cluster formation. With each iteration the probabilities are extended to an additional order of neighbors, leading to a gradual delocalization of the optimal parent grain orientation solution.

We will explore the two most critical parameters controlling the behavior of the Markovian Clustering algorithm, `numIter`

and `inflationPower`

. The parameter `numIter`

controls the number of iterations for which the clustering algorithm is run, which affects the order of neighbors taken into account and to which degree convergence is approached. The parameter `inflationPower`

, controls the degree of clustering in each iteration. In other words, it decides how rapidly clusters are formed.

It may not be entirely possible to judge the quality of the PGR with having access to a validation dataset (i.e. without knowing the actual parent microstructure), nevertheless some observations can be made: An inflation power of 1.2 seems to be too high, leading to large patches of material that have not been reconstructed. A good indicator for the present microstructure is to check in how far likely annealing twins have been resolved with a realistic morphology and how very small parent grains may become present that are unlikely to be associated with real parent grains. Based on this the choice of an inflation power of 1.05 and numIter of 10 seems to be a good choice, although it is hard to make an objective assessment. Note that an inflation power of 1 means that no clustering is enforced - with this setting the algorithm simply explores the local neighborhood up to the degree of neighbor defined by `numIter`

and bases the most likely parent orientation on the overall probabilities within this region.

## Final reconstruction

We can now do the final reconstruction using the optimized parameters and subsequently apply a growth-based PGR algorithm to reconstruct the remaining grains, as well as some post-processing steps to clean up the microstructure. You may also want to play with the parameter `minProb`

of the `calcParentFromVote`

method, which defines the minimum probability for a specific parent orientation required to conduct the PGR of a specific child grain. Lowering this parameter will lead to a more complete, but less confident PGR.

We are now finished with the PGR and can, as a last step, plot the child and reconstructed parent EBSD data overlayed with the outlines of the parent grains.