EBSDPolygonizer: Enabling realistic microstructural modelling

EBSDPolygonizer has catalyzed advancements in microstructural magnetic modelling by enabling the intricate conversion of EBSD data into detailed microstructures with precise grain orientation and boundary data. This paper elucidates the software’s pivotal role in enhancing the prediction and correlation of magnetic anisotropy and permeability with material properties. Demonstrated through substantial research, including that from the University of Warwick, it showcases how EBSDPolygonizer significantly refines the analysis of magnetic anisotropy and its relation to mechanical properties in steels, aligning closely with traditional r-value methods. The tool’s integrative approach, which considers both crystallographic textures and stress effects, heralds a new era in multiphysics simulations that bridge micromechanical and magnetic models. EBSDPolygonizer stands as a potent enabler for future-focused, detailed microstructural modelling, marking a leap forward for material science research and application.


Motivation and significance
Microstructure holds a paramount significance in determining the multifaceted properties of materials, playing a crucial role in guiding the design, manufacturing, processing, and application of diverse materials.A comprehensive exploration of microstructural influences is essential, which has led to the evolution of computational models intricately linked to microstructures, illuminating pathways to predict and analyse material properties with enhanced precision and productivity.
An illustrious example in microstructural computational modelling is the homogenization technique for predicting effective material properties from microstructural characteristics.These models have been utilized across various material classes in mapping the landscape of mechanical and magnetic properties, elucidating the stress and strain distributions, elastic modulus, magnetic permeability and other in-E-mail address: liuj118@cardiff.ac.uk.trinsic mechanical behaviours grounded in microstructural features [1][2][3][4][5].
Another prevailing example is micromechanical models, which have been developed to encapsulate the complexity of mechanical behaviours based on their microstructural characteristics.Crystal plasticity models, for instance, stand out by leveraging microstructural and crystallographic orientation information to elucidate the plastic deformation mechanisms inherent within polycrystalline materials [6,7].These models act as bridges, connecting the microscale intricacies with the overarching material properties, thereby necessitating an accurate portrayal of microstructural features for authentic and reliable predictions.
The richness of these models lies in their ability to incorporate microstructural details, facilitating a more accurate and reliable prediction.However, the utilization of genuine microstructural data often https://doi.org/10.1016/j.softx.2023.101622Received 6 November 2023; Received in revised form 8 December 2023; Accepted 18 December 2023 encounters significant hurdles.A recurrent theme in these models is the utilization of synthetic or artificial microstructures, often digitally forged using, for example, Voronoi tessellation.Whilst these virtual constructs serve as instrumental substitutes, facilitating various computational explorations and predictions in the absence of comprehensive real microstructural data, they suffer intrinsic limitations associated with the idealized geometrical simplification, under-represented complexity of individual grain and indistinctive treatment of interfaces [1].Conventional practices using real microstructures procured through optical micrographs and scanning electron micrographs, such as segmentation and image processing, often stumble when confronted with the task of automated parametrization for each grain.Electron Backscatter Diffraction (EBSD), with its affluent repository of data, has surged as a potent modality for metallographic and crystallographic characterization.However, the utility of raw EBSD data as direct geometric inputs in computational models is hindered by practical impediments due to its inherent raster nature.
In an endeavour to overcome these challenges and enhance the fidelity of microstructural data utilization in computational models, I introduce EBSDPolygonizer.This innovative software converts raster EBSD data into polygons, primed for integration with finite element (FE) software packages.The capabilities of EBSDPolygonizer extend beyond mere data transformation, enabling the identification, tracking and processing of, and easy access to, grain boundaries and offering insight into grain boundary sharing and corresponding misorientations.
This paper delineates the conception, functionalities, and capabilities of EBSDPolygonizer, elucidating its transformative impact on microstructure-based computational models, positioning it as a convenient tool set to catalyze advancements in the computational material science landscape.

Software architecture
The software architecture is organized into a MATLAB application, complete with a Graphical User Interface (GUI), enhancing usability and user interaction.
The application can also operates as a MATLAB package, named +ebsd, through the command line or scripts within the MATLAB environment.The design philosophy emphasizes usability, with all of its functionalities being readily accessible and operational utilizing MATLAB's built-in functions and features, without external dependencies.
EBSDPolygonizer's architecture consists of a suite of handle classes, each embodying specific aspects of the microstructural data and computations: • ebsd.mapclass: Dedicated to representing the overarching microstructure.
• ebsd.grainclass: Specialized in representing individual grains within the microstructure.
• ebsd.gbclass: Focuses on the representation and handling of grain boundaries.
• ebsd.gbvc and ebsd.edgevcclasses: These classes are pivotal in representing vertices, including inner ones and those at the edge of the map, ensuring precision in geometric delineations.
Moreover, the software includes a supportive class, ebsd.pixcell,engineered to encapsulate and manage pixel-level data and corresponding EBSD information meticulously.

Implementation strategy
The core strategy employed by EBSDPolygonizer for polygonization is methodically structured and executed in several stages to ensure the accurate representation of microstructural grains.
Initial square formation.Initially, each pixel is represented as a square created by the ebsd.pixcel.buildcellsfunction.The locational reference for each square is placed at the pixel's bottom left corner, utilizing the pixel's actual coordinates.The length of each side of the square corresponds to the step size, ensuring a consistent and uniform representation.
Grain polygonization.Polygonization of a grain is accomplished by uniting all representative squares corresponding to pixels within the same grain using the function ebsd.grain.polygonize.This aggregate of squares forms a cohesive polygon, representing the grain in the microstructure map.
Microstructural map construction.A comprehensive map symbolizing the entire microstructure is constructed by assembling polygons representing each grain (by the ebsd.mapconstruction method.).This map forms the basis for subsequent operations and analyses.

Grain neighbour identification (ebsd.grain.findneighbours ).
An essential part of the strategy involves identifying neighbouring grains across the constructed map.This step is fundamental in discerning the relational aspects between different grains within the microstructure.

Grain boundary segmentation (ebsd.map.findgbs ).
For each identified pair of neighbouring grains, shared grain boundary segments are meticulously identified.This aids in creating a precise geometric representation resonant with actual microstructural characteristics.
Node identification:.Nodes are distinctly identified as the vertices situated at the extremities of each grain boundary segment in the ebsd.gbconstruction method.These nodes are considered immutable in the subsequent processing, signifying their unalterable position and role within the polygonal representation of grains.
This structured strategy ensures that each grain within the microstructure is accurately represented as a polygon, facilitating further processing, computational analysis and modelling with enhanced precision and reliability.

Software functionalities
EBSDPolygonizer is engineered to facilitate the transition of raster EBSD data into polygonal entities, each representing a grain.This core functionality encapsulates the complex geometry of grains within a mathematically defined framework, enabling more sophisticated analyses and simulations.
• Polygonization: At the heart of EBSDPolygonizer's capabilities is the simple yet robust algorithm to polygonize EBSD grains.This transformation process effectively converts raster data into polygon shapes, aligning each grain with its geometric and crystallographic attributes.The output is an assembly of grain objects, each embedding critical data such as vertices, polyshape constructs, orientation, and detailed parameters of the grains, e.g., grain size.• Data Organization: Each grain object is an organizational unit within the software's architecture.Collectively, these objects form a comprehensive map that catalogues the microstructure.Grain boundaries, along with the vertices of individual grain polygons and their segments, are readily accessible, providing a streamlined interface for data retrieval and manipulation.• Post-Processing Functions: The software is equipped with several post-processing tools aimed at refining the polygonal representation.The smooth function is employed to enhance grain boundary delineation, the downsize function reduces vertex count for simplified models, and the simplify function intelligently combines both smoothing and downsizing to maintain the integrity of the grain shape with a reduced computational footprint.EBSDPolygonizer currently demonstrates limitations that are important for users to note.Its processing capability is confined to singlephase EBSD data, and it is compatible only with regular grid scanning.The software does not yet support multiphase data tracking or non-regular, e.g., hexagonal, grid patterns.Acknowledging these constraints, we are committed to expanding its functionalities in future updates to accommodate a wider range of EBSD data and applications in materials science research.

Polygonization
Fig. 1 displays the efficacy of the EBSDpolygonizer in transforming the inverse pole figure (IPF) map into a polygonal representation.The precision with which the polygonal output mirrors the grain shape of the original EBSD data is evident, highlighting the high fidelity of the conversion process.Furthermore, Fig. 1(c) showcases the meshing process executed in COMSOL Multiphysics, a renowned commercial FE software package.This meshing underscores the practical application of the EBSDpolygonizer's output, proving its utility as a geometric framework that can seamlessly integrate into FE modelling.Furthermore, Fig. 1(d) presents a comparison with a synthetic microstructure generated using Neper [8], designed to match the original data in terms of grain count and average grain size.This comparison distinctly showcases the superior accuracy and realism of the EBSDPolygonizer's output, emphasizing its effectiveness over synthetic microstructure generation methods.

Processing functions
Fig. 2 illustrates the core processing functionalities available within the EBSDPolygonizer software.In Fig. 2(a), the initial polygonized microstructure is exhibited, delineating the distinct grains with jagged grain boundaries.This representation is the foundational stage of the polygonization process, capturing the raw essence of raster EBSD data.
Transitioning to Fig. 2(b), the effect of the smoothing function becomes apparent.The previously jagged boundaries are now refined, resulting in a more contiguous and polished depiction of the grains.This smoothed representation not only enhances the aesthetic quality of the visualization but also aids in more accurate representation of real grain boundaries.
Diving deeper into the nuances of the software's capabilities, Figs.2(c) and 2(d) provide a view of the vertices associated with the grain boundaries.Fig. 2(c) exhibits the vertices before the application of the simplifying function.The densely packed vertices trace the contour of the grains, representing the intricate shape and size variations.However, managing such granular vertex data can be computationally taxing.To address this, Fig. 2(d) showcases the resultant microstructure after the simplifying function has been applied.
Remarkably, despite a substantial reduction in the number of vertices, the core shape of the grains remains predominantly unchanged.This feature underscores the software's ability to optimize data representation without compromising the fundamental characteristics of the microstructure.
Overall, these visual representations underscore the potent capabilities of EBSDPolygonizer, highlighting its proficiency in transforming, refining, and optimizing EBSD data for both analytical precision and computational efficiency.

Visualization functions
The software's visualization capabilities, designed as utility functions, are depicted in Fig. 3. Fig. 3(a) showcases a comprehensive grain map, with each grain tracked and labelled.Moving on to Fig. 3(b), one can observe the highlighted grain boundary segments, which have been meticulously identified by the application.Fig. 3(c) present an individual grain, pinpointing and plotting their immediate neighbours.

Impact
The inception of EBSDPolygonizer has catalyzed a transformative change in the field of microstructural magnetic modelling, for which the software was initially crafted.From its nascent versions, it has played a pivotal role in the modelling of magnetic anisotropy, delving into the interrelation between crystallographic texture and magnetic properties of steels [4,[9][10][11].This software's distinctive feature lies in its ability to construct realistic microstructures with precision and grain-specific orientation details.Such an innovation enables researchers to explore the direct impact of individual microstructural characteristics on the overall magnetic behaviour of materials.
With EBSDPolygonizer incorporating detailed microstructure and crystallographic textures into predictive models, the microstructural magnetic models have shown proficiency in forecasting effective permeability and magnetic anisotropy with commendable accuracy, findings that agree very well with empirical measurements.Its capability of mapping magnetic properties, like permeability, onto the microstructure has proved invaluable.These mappings create intuitive correlations with IPF maps -standard EBSD output -furnishing detailed insights into the nuances of texture effects on material properties, e.g., magnetic anisotropy.This advance opens up new area in microstructural analytics using magnetic methods, illustrating the software's capacity for addressing complex modelling challenges and enhancing the depth and precision of microstructural modelling.
At the University of Warwick, the software underpins research aiming to predict magnetic anisotropy and its relationship to mechanical properties [11].The integration of realistic microstructures with associated crystallographic texture data has enabled models to reflect the influence of texture on anisotropy accurately.The resulting trends demonstrate a robust correlation with the r-value, which traditionally gauges mechanical property anisotropy, underscoring the model's predictive power.
Moreover, EBSDPolygonizer unlocks new possibilities in modelling magnetic anisotropy by incorporating stress effects-another anisotropy source not previously accounted for.This novel approach has the potential to revolutionize micromechanical and magnetic modelling, integrating them with crystallographic texture considerations.The literature, e.g., [1,6], has already indicated the benefits of realistic microstructural inclusion in enhancing model robustness-a prospect that EBSDPolygonizer is uniquely positioned to fulfil.Its deployment could lead to a significant shift from the reliance on synthetic microstructures to more complex and realistic models, fuelling advances in multiphysics and microstructural modelling.
Released recently on GitHub and MATLAB File Exchange, EBSD-Polygonizer has demonstrated its appeal, evidenced by the swift uptake of 20 downloads in the first week on the latter platform.While GitHub does not track downloads, the interest from the academic and research community is promising.
The software's impact is further underscored by its compatibility with finite element software platforms, such as COMSOL Multiphysics and MATLAB PDE toolbox, thanks to its output of polygonal data.This compatibility simplifies the process of geometry construction for researchers and is indicative of the software's flexible and useroriented design.The meticulous tracking of grain boundary segments and the consequent ease in creating detailed geometries represent a significant leap forward, enabling more robust modelling and a richer understanding of material behaviour through microstructural modelling.
EBSDPolygonizer is not merely a tool for improving existing models-it is a gateway to pioneering methods and a cornerstone for the future landscape of realistic microstructural modelling.

Conclusions
The development and deployment of EBSDPolygonizer mark a significant milestone in the specialized niche of microstructural magnetic modelling.This innovative software has proven to be a powerful tool in the construction and analysis of realistic microstructures, providing a means to integrate grain-specific orientation details into the modelling process with commendable accuracy.The practical applications of EBSDPolygonizer, as demonstrated through the work at the University of Warwick, have not only enhanced our understanding of magnetic anisotropy but have also laid the groundwork for exploring the influence of stress alongside texture in magnetic properties.This opens up new avenues for research that were previously uncharted, pointing to the potential of this software to redefine the approaches to microstructural micromechanical, magnetic and multiphysics modelling.
The software's ability to shift the paradigm from synthetic to realistic microstructures embodies the evolution of modelling practices.It allows for a more nuanced and detailed simulation of material behaviours, which is crucial for both academic research and industrial applications.In essence, EBSDPolygonizer has potential to serve as a cornerstone for the next generation of microstructural modelling.Its impact extends beyond the immediate enhancements to modelling accuracy.As this software continues to be embraced and integrated into diverse modelling frameworks, it promises to catalyze further innovation and elevate our capacity to understand and manipulate the fundamental properties of materials at the microstructural level.

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Fig. 1 .
Fig. 1.A comparative display of the EBSDpolygonizer's polygonal representation.(a) The inverse pole figure (IPF) map serving as the primary reference.(b) High-fidelity polygonal transformation of the IPF map.(c) Integration of the polygonal output into COMSOL Multiphysics for FE meshing.(d) Synthetic microstructure generated using Neper, tailored to match the original data in terms of grain count and average grain diameter, highlighting the contrast with the EBSDPolygonizer's output..

Fig. 2 .
Fig. 2. Visualization of EBSDPolygonizer's core processing functionalities.(a) Initial polygonized microstructure with distinct grains delineated by jagged boundaries.(b) Microstructure after the application of the smoothing function, showcasing refined and contiguous grain boundaries.(c) Detailed view of grain boundary vertices prior to the application of the simplifying function, highlighting the densely packed vertices tracing the grain contours.(d) Resultant microstructure post simplifying function, demonstrating a significant reduction in vertex density while preserving the intrinsic grain shape.

Fig. 3 .
Fig. 3. (a) Comprehensive grain map with distinct labelled grains.(b) Grain boundary map demonstrating the identified grain boundary segments.(c) Zoomed-in view of individual grain 94, with its identified neighbouring grains highlighted.