Periodic 3D Example¶
XML Input File¶
The basename for this file is periodic_3D.xml.
The file can be run using this command:
microstructpy --demo=periodic_3D.xml
The full text of the file is:
<?xml version="1.0" encoding="UTF-8"?>
<input>
<material>
<name> Phase 1 </name>
<fraction> 1 </fraction>
<shape> sphere </shape>
<size>
<dist_type> uniform </dist_type>
<loc> 0.8 </loc>
<scale> 0.6 </scale>
</size>
</material>
<material>
<name> Phase 2 </name>
<fraction> 1 </fraction>
<shape> sphere </shape>
<size> 1.2 </size>
</material>
<domain>
<shape> cube </shape>
<side_length> 4 </side_length>
<corner> (0, 0, 0) </corner>
<!-- periodic in all three directions (xz would leave y free) -->
<periodic> xyz </periodic>
</domain>
<settings>
<directory> periodic_3D </directory>
<verbose> True </verbose>
<rng_seeds>
<size> 2 </size>
<position> 2 </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>
<edge_opt> True </edge_opt>
<edge_opt_n_iter> 10 </edge_opt_n_iter>
<mesh_min_angle> 15 </mesh_min_angle>
<mesh_max_volume> 0.02 </mesh_max_volume>
<color_by> seed number </color_by>
<colormap> tab20 </colormap>
<seeds_kwargs>
<linewidths> 0.2 </linewidths>
</seeds_kwargs>
<poly_kwargs>
<linewidths> 0.2 </linewidths>
</poly_kwargs>
<tri_kwargs>
<linewidths> 0.1 </linewidths>
</tri_kwargs>
</settings>
</input>
Materials¶
The two materials make up half of the volume each. The first has spherical grains whose diameters are uniformly distributed between 0.8 and 1.4, the second has spherical grains of diameter 1.2.
Domain Geometry¶
The materials fill a cube of side length 4, which is periodic in the three
directions: the <periodic> field of the domain is xyz.
Any subset of the axes can be given, for example xz to leave the y
direction free.
The polyhedral mesh is periodic across the faces (a grain cut by a face continues on the opposite face) and the tetrahedral mesh has the same nodes on opposite faces, stored as pairs in the mesh.
Settings¶
The random number generator seeds make the microstructure repeatable.
The mesh has a minimum dihedral angle of 15 degrees and a maximum element volume of 0.02. In 3D, the domain is meshed once as usual, then the facets are triangulated with the points TetGen added on them, identically on opposite faces, and the mesh is built again with these facets. The quality and size settings act as on a non-periodic mesh.
The seeds are placed a margin away from the periodic faces (periodic_margin
set to auto: half the target edge length, or an eighth of the smallest
grain if that is smaller) and the edge optimization moves the seeds that
leave a thin piece of a grain on a face, a corner narrower than the minimum
angle of the mesh, or a very short edge, since any of these forces very
small tetrahedra.
The plots are colored by seed number and the line widths are reduced to make the grains visible.
Output Files¶
The three plots that this file generates are the seeding, the polyhedral mesh, and the tetrahedral mesh. These three plots are shown in Fig. 23 - Fig. 25.
Fig. 23 Periodic 3D example - seed geometries.¶
Fig. 24 Periodic 3D example - polyhedral mesh.¶
Fig. 25 Periodic 3D example - tetrahedral mesh.¶