# Initial Microstructure¶

### Grain input¶

In this section, the microstructure at the beginning of the simulation needs to be specified. The input begins with determining the type of grain positioning.

The initial grain structure can either be specified explicitly grain by grain (deterministic), by stochastic means (random) or by reading in a file which represents the initial geometry of the grains (from_file). Both options will be described in detail further below.

Note: A fourth option of defining the initial microstructure is reading the result of an already performed MICRESS simulation from the restart (.rest) file. Using this option, several microstructures can be combined, using already existing grain regions as mask. Therefore, it requires an already defined grain structure and thus is available after the Grain Input section (see further below).

A general rule during grain input is that grain numbers are chosen automatically in a consecutive manner. Per default, if no grains are defined, the entire domain is filled with a grain of number 0. Grains with a higher number can erase those with lower number if they completely cover them. In case of a partial overlap, the overlapping region by default belongs to the grain with the higher number. Only if the voronoi option is chosen, the overlapping region is distributed between the grains by use of the Voronoi construction.

In order to merge individually defined grains, an optional group number can be specified behind the phase number (see below). Grains with identical group number and identical properties (i.e. phase, orientation and recrystallization energy) will then be combined to an effective grain with a common grain number.

If a grain radius is defined which is smaller than the grid resolution $\Delta x$, a grain consisting of only one interface cell is created which has a grain fraction corresponding to the 3D volume specified by the radius. Since for these small grains no reasonable curvature can be evaluated using the normal phase-field equation, an alternative initial curvature treatment has to be defined. The stabilisation model neglects the curvature as long as the grain is still small. In the analytical_curvature model, curvature is calculated from the phase fraction, assuming a spherical morphology. In this case an extra critical radius has to be defined, which determines the maximum value of the curvature for this grain.

If no grains are present at the beginning of the simulation, the user should specify deterministic and define the number of grains at the beginning as 0. In this case, no additional input is necessary in this section.

### deterministic¶

Choosing this option, first the number of grains at the beginning has to be specified. For each grain, the geometry (round, rectangular or elliptic) and the grain position is defined by Cartesian coordinates. Note that the origin is at the bottom left-hand corner, and that in 2D simulations only the $x$ and $z$ coordinate has to be given. Round grains are defined by their radius, rectangular and elliptic grains by the length along the $x$ and the $z$-axis. If round grain geometry has been chosen, a curvature model, which is to be used in case of small grains, has to be specified (see above).

Furthermore, the user has to specify whether in case of overlapping grains the Voronoi construction is to be used and specify the number of the phase associated with the grain. Depending on the properties of this phase, the recrystallisation energy and the orientation of the grain may further be required. Behind the phase number, an optional group number can be inserted to let grains with identical group number and properties be merged

###### Example 1¶

Grain input: Deterministic grain positioning of one round grain

...
# Initial Microstructure
# ======================
# Type of grain positioning?
# Options:  deterministic   random [deterministic_infile]   from_file
deterministic
# NB: the origin of coordinate system is the bottom left-hand corner,
#     all points within the simulation domain having positive coordinates.
# Number of grains at the beginning?
1
# Grain number 1
# --------------
# Geometry?
# Options:  round  rectangular  elliptic  round_inverse
round
# Center x,z coordinates [micrometers], grain number 1?
0.00000
0.00000
5.0000
...


### random¶

For random grain positioning, an integer for randomization is required as first input. Essentially, this random seed assures reproducibility of the initial grain structure in case other parameters of the input file are changed.

Afterwards, the number of different types of grains has to be specified. By the different types it is possible to e.g. define complex size distributions or to fill different zones of the simulation domain with grains of different size or geometry. For each grain type, the number of grains and the grain geometry must be specified. In analogy to deterministic grain positioning the user can define round, rectangular or elliptic grains. Furthermore, a minimum and a maximum value are required for each-space coordinate in order to define the region over which the grains of this type shall be randomly redistributed. Depending on the type of the geometry chosen, the user has to further specify a minimum and a maximum radius (round geometry) or a minimum and a maximum length size along each-axis (rectangular or elliptic geometry) in order to define the size distribution of the actual grain type.

In the same way as for deterministic input, the curvature model for small grains has to be specified (only for round grains,) and the user can decide whether the Voronoi construction is to be used. Afterwards the phase number is given. If the associated phase is anisotropic, the grain orientation has to be defined either by a randomly, by a fix orientation or randomly within a given orientation range. To enable merging of grains with identical properties, a group number can be specified after the phase number and random orientations can be set with distinct steps instead of continuously. If recrystallization has been chosen, minimal and maximal energy values are to be specified. Finally, a minimum distance between the grain centres (in $\mu m$) is required. This parameter can be used to avoid overlapping of grains which are set randomly into a matrix phase, but also to obtain equal size distributions in Voronoi construction. Note that in a Voronoi construction, the effective grain radii are determined by the distances between the grain centres, while the specified radius is used as a weighting factor, see section Microstructure - Voronoi Construction.

###### Example 2¶

Random positioning of grains

...
# Initial Microstructure
# ======================
# Type of grain positioning?
# Options:  deterministic   random [deterministic_infile]   from_file
random
# Integer for randomization?
77777
# Number of different types of grains?
1
# Number of grains of type 1?
160
# Input for grain type 1
# ----------------------
# Geometry of grain type 1
# Options:  round  rectangular  elliptic  round_inverse
round
# Minimal value of x-coordinates?  [micrometers]
0.00000
# Maximal value of x-coordinates?  [micrometers]
300.00
# Minimal value of z-coordinates?  [micrometers]
0.0000
# Maximal value of z-coordinates?  [micrometers]
300.00
40.000
45.000
# Shall grain type 1 be stabilized or shall
# an analytical curvature description be applied?
# Options:    stabilisation   analytical_curvature
stabilisation
# Should the Voronoi criterion for grains of type 1 be applied?
# Options:    voronoi     no_voronoi
voronoi
# Phase number for grain type 1? (int)
1
# Determination of grain orientations?
# Options:   fix   random    random_z    range
#           [step between random values in degrees]
random
# Minimal distance between grains (real) [micrometers]?
10.000
...


### from_file¶

In case of reading the initial grain structure from file, first its name (and path) needs to be specified. For defining the initial grain structure, an image file in ASCII format is required. The geometry of this file has to be given as CellsX and CellsZ (for 2D simulations). These dimensions have not necessarily to be the same as the dimensions of the simulation domain specified at the top of the input file.

The number of grains at the beginning can be either specified explicitly or be determined on basis of the input file. In the same way, properties of each of the grains can be defined either one by one (input) or read from_file. In the latter case, its name and path have to be given. Otherwise, the grain properties are read in directly from the command line. Optionally, they can also be set identical, i.e. all grains have the same properties, or they can be read as blocks. The latter would be done e.g. by grain $1$ to $3$ and grain $4$ to $6$ if the number of grains was set to $6$.

A 2D or 3D initial grain microstructure, specified in the VTK format, can also be read in as shown in Example 2.20. As different solution types can exist in a VTK file coming from a previous analysis like crystal plasticity FEM, the grain definition must be selected via the optional parameter VTK_identifier. Per default, the identifier for the grain structure is korn.

If a local RX model is used, the user must specify the name of the VTK file from which the local dislocation density field is read. If the identifier rhoD is used to characterize the dislocation field, no specific VTK_identifier has to be introduced. If the keyword of the scalar VTK field differs from rhoD, the used keyword name must be provided via the VTK_identifier.

###### Example 3¶

Reading initial microstructure from file with no data treatment and 2 grains in the beginning

...
# Initial Microstructure
# ======================
# Type of grain positioning?
# Options:  deterministic   random [deterministic_infile]   from_file
from_file
# Filename of initial grain/phase structure [VTK_identifier  (default=korn)] ?
[VTK_identifier  (default=korn)]
Grain_Growth_Microstructure.txt
# Treatment of data?
# (n: none, 1: 1D, f: flip (bottom<->top), t: transpose,
#  or p: 'phase to grains transformation')
none
# CellsX for initial microstructure?
100
# CellsZ for initial microstructure?
100
# Number of grains at the beginning?
# (Set to less than 1 for the number of grain to be read from the input data,
#  with optionally a minimal size, in cells)
2
# Read grain properties from a file?
# Options:    input      from_file    identical    blocks
input
# Input data for grain number 1:
# Phase number?   (integer)      [group number]
1
...


###### Example 4¶

Reading initial microstructure from file with no data treatment, grain properties (Euler angle) and file name of local dislocation density field.

...
# Initial Microstructure
# ======================
# Type of grain positioning?
# Options:  deterministic   random [deterministic_infile]   from_file
from_file
# Filename of initial grain/phase structure
#         [VTK_identifier  (default=korn)]
ReX_korn.vtk    korn
# Treatment of data?
# (n: none, 1: 1D, f: flip (bottom<->top), t: transpose,
#  or p: 'phase to grains transformation')
none
# Number of grains at the beginning?
# (Set less to 1 then read from input data,
#  with optionally a minimal size, in cells)
-1
# Read grain properties from a file?
# Options:    input      from_file    identical    blocks
from_file
#Filename of properties of initial grain structure
Gr_Euler_T950.txt
# Filename of local dislocation densities
#   [VTK_identifier (default=rhoD)
rho_T950.vtk     rhoD
#
...


### Structure from Restart File¶

Grains which have been created by the procedures above can be used as containers for structures read from one or more MICRESS® restart files. Only the pure microstructure data without numerical or status variables will be read. This option not only permits the user to change nearly all numerical parameters, but also allows to alter geometry and resolution, and even to combine several microstructures from different restart files in one single simulation! For high flexibility in locating the individual microstructures, the content of the .rest files are positioned inside existing grains (with a specific grain number), which may have been created using the initial grain input, reading in initial microstructures from file, or even by preceding input from a restart file. The size of the geometry which was used in the simulation creating the .rest file to be used here is required to exceed the size of the grain to be filled, if no mirroring or periodic continuation applies (see below). If no grains have been set before, reading in a restart file is possible by using default grain 0.

A shift in the $x$, $y$, and $z$ direction (relative to the lower left corner) can be specified optionally. In case of symmetric or periodic microstructures (i.e. depending on the symmetry which was used in the simulation which created the .rest file), mirroring or periodic continuation is applied automatically.

Furthermore, a zooming into the microstructure is possible to some extend (factor $2$ or $3$). For each coordinate, a zoom factor can be chosen which in a first step multiplies the grid cells in the corresponding directions. With help of the initialization procedure (Number of steps to adjust profiles of initially sharp interfaces, see section Numerical Parameters) , the interface thickness can be reduced to the new scale. This procedure also requires an iterative redistribution of solute, therefore a relatively high number of initialization steps (ca. $100$ to $200$) is typically needed to get satisfactory results. As any kind of noise is amplified, the use of too high factors could lead to erratic microstructures.

Finally, a string for rotation by $\pm 90°$ and $180°$ can be specified by selecting a string (see Example 2.7). Please note that specifying a string for rotation requires that all other optional parameters have been specified.

The order in which the different operations are executed corresponds to the fixed order of parameter input (first shift, then zoom, then rotation). If the operations lead to a situation where part of the grain region to be filled is empty and cannot be filled by symmetry operations, an undefined behaviour must be expected.

###### Example 5¶

Combining different microstructures using the 'restart_file' option

...
# Structure from restart file
# ---------------------------
# Shall grain(s) be replaced by initial structure(s) from a restart file(s) ?
# Options: restart_file | no_restart_file
restart_file
# How many restart files shall be read?
2
# For each restart file a grain number and (optionally)
# shift (in grid cells) and zoom factor for all 3 dimensions
# as well as a character for rotation options must be specified:
# grain number [shift X (int)  shift Y (int)  shift Z (int)
#              zoom X (int)  zoom Y (int)  zoom Z (int) rot(string)] ?
# Rotation options: "xz+90" "xz-90" "xz180" "xy+90" ... "yz180"
1 0 0 0 1 1 1 xz+90
# Name of restart file?
A247_Initial
# For each restart file a grain number and (optionally)
# shift (in grid cells) and zoom factor for all 3 dimensions
# as well as a character for rotation options must be specified:
# grain number [shift X (int)  shift Y (int)  shift Z (int)
#              zoom X (int)  zoom Y (int)  zoom Z (int) rot(string)] ?
# Rotation options: "xz+90" "xz-90" "xz180" "xy+90" ... "yz180"
2 0 0 -50 1 1 1 xz-90
# Name of restart file?
A247_Initial
...