Periodic 2D Example

XML Input File

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

microstructpy --demo=periodic_2D.xml

The full text of the file is:

<?xml version="1.0" encoding="UTF-8"?>
<input>
    <material>
        <name> Grains </name>
        <fraction> 2 </fraction>
        <shape> circle </shape>
        <size>
            <dist_type> uniform </dist_type>
            <loc> 0.2 </loc>
            <scale> 0.2 </scale>
        </size>
    </material>

    <material>
        <name> Inclusions </name>
        <fraction> 1 </fraction>
        <shape> ellipse </shape>
        <size>
            <dist_type> uniform </dist_type>
            <loc> 0.25 </loc>
            <scale> 0.15 </scale>
        </size>
        <aspect_ratio> 2 </aspect_ratio>
        <angle_deg>
            <dist_type> uniform </dist_type>
            <loc> 0 </loc>
            <scale> 180 </scale>
        </angle_deg>
    </material>

    <domain>
        <shape> square </shape>
        <side_length> 2 </side_length>
        <corner> (0, 0) </corner>
        <!-- periodic in both directions: x, y, xy and True are accepted -->
        <periodic> True </periodic>
    </domain>

    <settings>
        <directory> periodic_2D </directory>
        <verbose> True </verbose>
        <rng_seeds>
            <size> 1 </size>
            <position> 1 </position>
        </rng_seeds>

        <!-- the seeds and the grains stay a margin away from the periodic
             faces, or cross them by more than the margin: auto is half the
             target edge length, at most an eighth of the smallest grain -->
        <periodic_margin> auto </periodic_margin>

        <!-- the edge optimization removes the shortest edges of the
             polygonal mesh and, with the margin, the thin pieces and the
             narrow corners of the grains at the periodic faces, which
             would force very small triangles -->
        <edge_opt> True </edge_opt>
        <edge_opt_n_iter> 25 </edge_opt_n_iter>

        <mesh_min_angle> 25 </mesh_min_angle>
        <mesh_max_volume> 0.004 </mesh_max_volume>

        <color_by> seed number </color_by>
        <colormap> tab20 </colormap>
        <tri_kwargs>
            <linewidth> 0.2 </linewidth>
        </tri_kwargs>
    </settings>
</input>

Materials

The first material makes up two thirds of the area, with circular grains whose diameters are uniformly distributed between 0.2 and 0.4.

The second material makes up the remaining third, with elliptical grains of aspect ratio 2 and random orientations.

Domain Geometry

The materials fill a square domain of side length 2, which is periodic in both directions: the <periodic> field of the domain is True. The periodicity can also be restricted to some of the axes, for example <periodic> x </periodic>.

Grains that cross a periodic face of the domain continue on the opposite face, and the meshes have matching nodes on opposite faces. The seeds are positioned without overlapping the grains on the other side, the polygonal mesh is periodic across the faces, and the triangular mesh has the same nodes on opposite faces, so that periodic boundary conditions can be applied to it directly. The pairs of periodic nodes are stored in the mesh (in its text file and, for Abaqus, in node sets named Set-N-Periodic-X-Low and Set-N-Periodic-X-High).

Settings

The random number generator seeds make the microstructure repeatable.

The mesh has a minimum angle of 25 degrees and a maximum element area of 0.004. The quality and size settings act on a periodic mesh as on a non-periodic one.

A grain that barely crosses a periodic face, or ends just inside it, leaves a thin piece of itself on the opposite face and very small elements there. periodic_margin rejects the positions where a seed ends within the margin of a periodic face or crosses it by less than the margin. The value auto sets the margin to half the target edge length of the mesh, or to an eighth of the smallest grain if that is smaller. The edge optimization removes the shortest edges of the polygonal mesh, for the same reason, and with the margin it also thickens or removes the pieces of the grains at the periodic faces that are thinner than the margin, which the placement of the seeds alone cannot prevent (a grain extends beyond its seed, and its corners can cross a face by a small amount), and opens the corners of the grains at the faces that are narrower than the minimum angle of the mesh.

The plots are colored by seed number, so that the pieces of a grain on opposite faces of the domain have the same color.

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. 20 - Fig. 22. The grains cut by the faces of the domain continue on the opposite faces.

Seed geometries.

Fig. 20 Periodic 2D example - seed geometries.

Polygonal mesh.

Fig. 21 Periodic 2D example - polygonal mesh.

Triangular mesh.

Fig. 22 Periodic 2D example - triangular mesh.