4. Oriented Grains

4.1. XML Input File

The basename for this file is intro_4_oriented.xml. The file can be run using this command:

microstructpy --demo=intro_4_oriented.xml

The full text of the file is:

<?xml version="1.0" encoding="UTF-8"?>
        <name> Matrix </name>
        <material_type> matrix </material_type>
        <fraction> 2 </fraction>

        <shape> circle </shape>
            <dist_type> uniform </dist_type>
            <loc> 0 </loc>
            <scale> 1.5 </scale>

        <name> Inclusions </name>
        <fraction> 1 </fraction>
        <shape> ellipse </shape>
            <dist_type> triang </dist_type>
            <loc> 0 </loc>
            <scale> 2 </scale>
            <c> 1 </c>
            <dist_type> uniform </dist_type>
            <loc> 1 </loc>
            <scale> 2 </scale>
            <dist_type> uniform </dist_type>
            <loc> -10 </loc>
            <scale> 20 </scale>

        <shape> square </shape>
        <side_length> 20 </side_length>
        <corner> (0, 0) </corner>

        <directory> intro_4_oriented </directory>
        <verbose> True </verbose>

4.2. Materials

There are two materials, in a 2:1 ratio based on volume. The first is a matrix, which is represented with small circles.

The second material consists of elliptical inclusions with size ranging from 0 to 2 and aspect ratio ranging from 1 to 3. Note that the size is defined as the diameter of a circle with equivalent area. The orientation angle of the inclusions are uniformly distributed between -10 and +10 degrees, relative to the +x axis.

4.3. Domain Geometry

These two materials fill a square domain. The bottom-left corner of the rectangle is the origin, which puts the rectangle in the first quadrant. The side length is 20, which is 10x the size of the inclusions to ensure that the microstructure is statistically representative.

4.4. Settings

Many settings have been left to their defaults, with the exceptions being the verbose mode and output directory.

By default, MicroStructPy does not print status updates to the command line. Switching the verbose mode on will regularly print the status of the code.

The output directory is a filepath for writing text and image files. By default, MicroStructPy outputs texts files containing data on the seeds, polygon mesh, and triangular mesh as well as the corresponding image files, saved in PNG format.


The <directory> field can be an absolute or relative filepath. If it is relative, outputs are written relative to the input file, not the current working directory.

4.5. Output Files

The three plots that this file generates are the seeding, the polygon mesh, and the triangular mesh. These three plots are shown in Fig. 4.1 - Fig. 4.3.

Seed geometries.

Fig. 4.1 Introduction 4 - seed geometries.

Polygonal mesh.

Fig. 4.2 Introduction 4 - polygonal mesh.

Triangular mesh.

Fig. 4.3 Introduction 4 - triangular mesh.