Skip to content

Processing X ray diffraction data: grain centroids and volumes

Romain Quey edited this page Oct 2, 2021 · 8 revisions

Introduction

Methods such as far-field 3DXRD or Laue diffraction provides incomplete information on a grain structure, such as the grains centroids (centers of mass) and volumes. Neper can generate the optimal tessellation (made of convex cells) that corresponds to such a data set. The tessellation can be described as a raster tessellation (for FFT simulations) or can be meshed (for FEM simulations). This is described step by step in the following.

Input data

The input data are no more than what the user should know about the data set:

  • the number of grains
  • the grain centroids
  • the grain sizes (volumes in 3D, surface areas in 2D, or equivalent diameters)
  • the shape and position of the domain, i.e. of the actual specimen
  • optionally, the crystal orientations of the grains

⚠️ Neper does not "reposition" the grain centroids to properly fit in the domain; so, make sure your data are consistent.

📣 Neper "rescales" the grain sizes so that they sum out to the actual domain size. This works for all inputs (volumes in 3D, surface areas in 2D, or equivalent diameters).

📣 Providing crystal orientations is optional in the sense that they do not influence tessellation generation. However, when provided, they are copied to the tessellation (and then pushed to the mesh).

Tessellation generation

A tessellation can be generated using neper -T. The input listed above must be specified using the following options:

  • -n specifies the number of grains
  • -dim specifies the dimension
  • -morpho specifies the morphology (here, both the grain centroids and the grain surface areas / volumes)
  • -domain specifies the domain
  • -ori specifies the crystal orientations

Additional options may be useful:

  • -regularization (or -reg, for short) regularizes the tessellation (useful only if the tessellation will be meshed)

⚠️ Most options are assigned default values. -dim defaults to 3 and is therefore needed only if the actual dimension is 2.

Grain information

Grain centroids and sizes can be specified using -morpho "centroidsize:file(file_name)". file_name is typically formatted by providing the grain centroids (2 entries in 2D, 3 entries in 3D) and volumes of the grains on successive lines. An example for 10 grains in 3D is

0.100 0.119 0.557 0.013
0.259 0.142 0.201 0.060
0.139 0.375 0.321 0.040
0.386 0.411 0.587 0.009
0.133 0.369 0.777 0.030
0.379 0.259 0.860 0.035
0.130 0.109 0.850 0.018
0.385 0.407 0.125 0.012
0.418 0.382 0.375 0.008
0.363 0.146 0.576 0.025

📣 The data can be space or tab delimited.

⚠️ The values of -n and -dim must be consistent with the value of -morpho. Some bash magic can be used to define them automatically (e.g. wc -l file_name | awk '{print $1}' for -n).

Sample information

The domain must be convex and can be most commonly defined as either a cuboid (using cube(...)), a cylinder or any other prism (using cylinder(...)) (use square or circle in 2D). More complex domains can be defined through a series of "cutting planes" (using planes(...)).

⚠️ By default, a domain have minimal x, y and z coordinates of 0, but the domain can also be translated, by appending :translate(...). (It can also be rotated by appending :rotate(...) or scaled by appending :scale(...).)

⚠️ The value of -dim must be consistent with the value of -domain.

Visualizing the input data set

📣 This is entirely optional and only intended to validation.

Before the tessellation is generated, it can be safe to visualize the data set. This can be done as follows:

  • Generate a 1-grain tessellation that defines the domain using, for example,
$ neper -T -n 1 -domain "cube(0.5,0.5,1)" -o domain
  • Visualize both the domain (defined in domain.tess) and the grain centroids (written in file coo_file) using, for example
$ neper -V domain.tess,coo_file -datacelltrs 0.5 -datapointrad 0.1 -print img

image

This example case looks properly formatted as the grain centroids lie in the domain.

⚠️ The grain centroids must be written with 3 coordinates.

  • Visualize both the domain (defined in domain.tess) and the grain centroids (written in file coo_file) and radii (written in file rad_file) using, for example
$ neper -V domain.tess,coo_file -datacelltrs 0.5 -datapointrad file (`rad_file`) -print img

image

Again, this example case looks properly formatted as the grains (visualized as spheres) fit the domain.

Generating the tessellation

The tessellation can be generated by neper -T, using all necessary options. An example is

$ neper -T -n 10 -domain "cube(0.5,0.5,1)" -morpho "centroidsize:file(file_name)" -o px

The terminal output is

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.0.1
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 8 threads.
Info   : <http://neper.info>
Info   : Copyright (C) 2003-2020, and GNU GPL'd, by Romain Quey.
Info   : Ignoring initialization file.
Info   : ---------------------------------------------------------------
Info   : MODULE  -T loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] -n 10 -domain cube(0.5,0.5,1) -morpho
         centroidsize:file(file_name) -o px
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   : Creating domain...
Info   : Creating tessellation...
Info   :     [i] Parsing file `file_name'...
Info   :     [i] Parsed file `file_name'.
Info   :   - Setting seeds... 100%
Info   :   - Generating crystal orientations...
Info   :   - Running tessellation...
Info   :     > Initial solution: f   =0.030354647
Info   :     > Iteration  23733: fmin=0.001822992 f=0.001822992
Info   :     > Reached `eps' criterion.
Info   : Writing results...
Info   :     [o] Writing file `px.tess'...
Info   :     [o] Wrote file `px.tess'.
Info   : Elapsed time: 9.758 secs.
========================================================================

⚠️ The initial value of f should typically be smaller than 1, or the value of f should rapidly become smaller than 1. Values higher than 1 indicate erroneous inputs. Values can be temporarily higher than 1 if empty cells are present (due to penalization).

For large numbers of grains, the optimization can be quite CPU-intensive (the centroids/sizes is actually the type of inputs that is the slowest to converge). You can, however, use -morphooptistop to shorten the tessellation using a more liberal termination criterion. An example is

$ neper -T -n 10 -domain "cube(0.5,0.5,1)" -morpho "centroidsize:file(file_name)" -morphooptistop "eps=1e-4" -o px

The terminal output is

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.0.1
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 8 threads.
Info   : <http://neper.info>
Info   : Copyright (C) 2003-2020, and GNU GPL'd, by Romain Quey.
Info   : Ignoring initialization file.
Info   : ---------------------------------------------------------------
Info   : MODULE  -T loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] -n 10 -domain cube(0.5,0.5,1) -morpho
         centroidsize:file(file_name) -morphooptistop eps=1e-4 -o px
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   : Creating domain...
Info   : Creating tessellation...
Info   :     [i] Parsing file `file_name'...
Info   :     [i] Parsed file `file_name'.
Info   :   - Setting seeds... 100%
Info   :   - Generating crystal orientations...
Info   :   - Running tessellation...
Info   :     > Initial solution: f   =0.030354647
Info   :     > Iteration   1675: fmin=0.007056908 f=0.007059917
Info   :     > Reached `eps' criterion.
Info   : Writing results...
Info   :     [o] Writing file `px.tess'...
Info   :     [o] Wrote file `px.tess'.
Info   : Elapsed time: 0.619 secs.
========================================================================

The doubtful user can output the actual grain centroids and volumes using

$ neper -T -loadtess px.tess -statcell x,y,z,size

which generates a file px.stcell with the data, to be compared to the input.

The tessellation can be visualized using

$ neper -V px.tess -datacelltrs 0.5 -datacellcol id -print img

image

As pointed out before, the tessellation can actually be described as a raster or a scalar tessellation. For a raster tessellation, use -format tesr:

$ neper -T -n 10 -domain "cube(0.5,0.5,1)" -morpho "centroidsize:file(file_name)" -format tesr -o px

For a scalar tessellation (to be meshed), it is useful to apply regularization:

$ neper -T -n 10 -domain "cube(0.5,0.5,1)" -morpho "centroidsize:file(file_name)" -reg 1 -o px

Meshing

A tessellation can be meshed into finite elements using neper -M. The meshing parameters are typically the following:

  • -rcl (or cl) specifies the relative (or absolute) element characteristic length
  • -order specifies the order of the elements

📣 Many other options are available.

An example is

$ neper -M px.tess -rcl 0.5 -order 2

The mesh can be visualized using

$ neper -V px.tess,px.msh -dataelsetcol id -dataelt1drad 0.002 -dataelt3dedgerad 0.001 -print img

image