Skip to content

Commit

Permalink
grain3d docu
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfHielscher committed Oct 5, 2024
1 parent ca9ac0f commit 6b44c75
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 2,254 deletions.
Binary file modified images/Grains3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3DProperties_09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3D_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3D_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3D_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3D_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Grains3D_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/Grains3D_06.png
Binary file not shown.
Binary file removed images/Grains3D_07.png
Binary file not shown.
Binary file removed images/Grains3D_08.png
Binary file not shown.
Binary file removed images/Grains3D_09.png
Binary file not shown.
Binary file removed images/Grains3D_10.png
Binary file not shown.
Binary file modified images/SelectingGrains_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/SelectingGrains_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/SelectingGrains_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/SelectingGrains_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ShapeParameters_01.png
Binary file modified images/ShapeParameters_03.png
283 changes: 54 additions & 229 deletions pages/documentation_matlab/Grains3D.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,34 @@
<div>
<!--introduction-->
<!--/introduction-->
<p>grain3d is a structure to store 3D grain data. At the moment 3d data is usually obtained from <a href="NeperInterface.html">Neper tessellations</a> or triangulated Dream3d data sets.</p>
<p>Variables of type <a href="grain3d.grain3d.html">grain3d</a> store 3D grain data. At the moment 3d grains can be imported from &lt;NeperInterface.html Neper% &gt; or from Dream3d.</p>
<h2 id="2">Grain sets from Dream3d</h2>
{% highlight matlab %}
grains = grain3d.load(fullfile(mtexDataPath,'EBSD','SmallIN100_MeshStats.dream3d'));

% for triangulated data sets it may be useful to plot them without lines
plot(grains,grains.meanOrientation,'LineStyle','none')

how2plot = plottingConvention;
how2plot.outOfScreen = vector3d(-10,-5,2);
how2plot.east = vector3d(1,-2,0);
setCamera(how2plot)
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_01.png" %}
</center>
<h2 id="3">Plot the normal directions of one grain</h2>
<p>Similarly as with two dimensional grains we can select individual grains by arbitrary constraints. For instance we can find the largest grain by</p>
{% highlight matlab %}
grains = grains(1)
dir = grains.I_GF(1,:)' .* grains.boundary.N % flip according to I_GF
quiver(grains.boundary,dir)
plot(grains)
% index of the grain with the largest volume
[~,id] = max(grains.volume)

plot(grains(id),grains(id).meanOrientation)
setCamera(how2plot)
{% endhighlight %}

{% highlight plaintext %}
grains = grain3d

Phase Grains Volume Mineral Symmetry Crystal reference frame
2 1 16 unknown 622 X||a*, Y||b, Z||c*

boundary faces: 748

Id Phase Pixels meanRotation
1 2 1 (207°,35°,319°)


dir = vector3d
size: 748 x 1
id =
146
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_02.png" %}
Expand All @@ -67,16 +62,19 @@ <h2 id="4">Grain sets from Neper</h2>
% set up the communication with Neper
job = neperInstance

% define crystal symmetry
cs = loadCIF('Cu-Copper.cif');
% define a texture
cs = crystalSymmetry.load('quartz.cif','color','lightblue');
odf = fibreODF(cs.cAxis,vector3d(1,1,1));

% some odf in brass orientation
odf = unimodalODF(orientation.brass(cs));
numGrains=100;
grains = job.simulateGrains(odf,numGrains,'silent')

grains3 = job.simulateGrains(odf,numGrains)
% or you can load an existing tessellation file
%grains3 = grain3d.load('allgrains.tess','CS',cs)

% colorize by mean orientation
plot(grains,grains.meanOrientation,'micronbar','off')
setCamera(how2plot)
{% endhighlight %}

{% highlight plaintext %}
Expand All @@ -91,255 +89,82 @@ <h2 id="4">Grain sets from Neper</h2>
fileName2d: '2dslice'
fileName3d: 'allgrains'
filePath: '/tmp/neper/'

======================== N e p e r =======================
Info : A software package for polycrystal generation and meshing.
Info : Version 4.9.1-4
Info : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info : Running on 12 threads.
Info : <https://neper.info>
Info : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info : No initialization file found (`/home/hielscher/.neperrc').
Info : ---------------------------------------------------------------
Info : MODULE -T loaded with arguments:
Info : [ini file] (none)
Info : [com line] -n 100 -id 1 -morpho graingrowth -domain cube(1,1,1)
-morphooptistop itermax=1000 -oricrysym m-3m -ori
file(/tmp/neper/ori_in.txt) -statpoly faceeqs -o
/tmp/neper/allgrains -oridescriptor rodrigues -oriformat plain
-format tess,ori
Info : ---------------------------------------------------------------
Info : Reading input data...
Warning: - Option `-oricrysym' will be removed in a future version. Use `-crysym` instead.
Info : Creating domain...
Info : Creating tessellation...
Info : - Setting seeds... 100%
Info : - Running tessellation...
Info : > Initial solution: f =2.806198409
Info : > Iteration 1000: fmin=0.566500872 f=0.566500872
Info : > Final solution: f =0.566500872
Info : > Final solution : f =0.566500872 (1001 iterations)
Info : > Reached `itermax' criterion.
Info : Generating crystal orientations...
Info : [i] Parsing file `/tmp/neper/ori_in.txt'...
Info : [i] Parsed file `/tmp/neper/ori_in.txt'.
Info : Writing results...
Info : [o] Writing file `/tmp/neper/allgrains.tess'...
Info : [o] Wrote file `/tmp/neper/allgrains.tess'.
Info : [o] Writing file `/tmp/neper/allgrains.ori'...
Info : [o] Wrote file `/tmp/neper/allgrains.ori'.
Info : Writing statistics...
Info : [o] Writing file `/tmp/neper/allgrains.stpoly'...
Info : [o] Wrote file `/tmp/neper/allgrains.stpoly'.
Info : Elapsed time: 2.958 secs.
========================================================================


======================== N e p e r =======================
Info : A software package for polycrystal generation and meshing.
Info : Version 4.9.1-4
Info : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info : Running on 12 threads.
Info : <https://neper.info>
Info : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info : No initialization file found (`/home/hielscher/.neperrc').
Info : ---------------------------------------------------------------
Info : MODULE -V loaded with arguments:
Info : [ini file] (none)
Info : [com line] /tmp/neper/allgrains.tess
Info : ---------------------------------------------------------------
Info : - Reading arguments...
Info : Elapsed time: 0.001 secs.
========================================================================


grains3 = grain3d
grains = grain3d

Phase Grains Volume Mineral Symmetry Crystal reference frame
2 100 1 Copper m-3m
2 100 1 Quartz 321 X||a*, Y||b, Z||c*

boundary faces: 650

<strong>Properties</strong>: meanRotation
{% endhighlight %}
<h2 id="5">Plotting Grains</h2>
{% highlight matlab %}
% set camera
how2plot = plottingConvention;
how2plot.outOfScreen = vector3d(-10,-5,2);
how2plot.east = vector3d(1,-2,0);

% colorize by mean orientation
plot(grains3,grains3.meanOrientation)
setCamera(how2plot)
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_03.png" %}
</center>
<h2 id="6">Rotation</h2>
<p>rotate 180 degrees about the x-axis</p>
{% highlight matlab %}
rot = rotation.byAxisAngle(xvector,180*degree);
grains3_rot = rot * grains3; % or rotate(grains3,rot)

% plotting
plot(grains3_rot,grains3_rot.meanOrientation)
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_04.png" %}
</center>
<p>colorize by volume</p>
{% highlight matlab %}
plot(grains3,grains3.volume)
setCamera(how2plot)
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_05.png" %}
</center>
<p>plot single grains, color by phase</p>
{% highlight matlab %}
figure
grains = grains3(1:5)
plot(grains)
{% endhighlight %}

{% highlight plaintext %}
grains = grain3d

Phase Grains Volume Mineral Symmetry Crystal reference frame
2 5 0.045 Copper m-3m

boundary faces: 56

Id Phase Pixels meanRotation
1 2 1 (34.7°,42.2°,355.5°)
2 2 1 (26.2°,40.1°,352.1°)
3 2 1 (192.7°,31.1°,202.9°)
4 2 1 (203.7°,32.5°,173.5°)
5 2 1 (216.3°,46.1°,172.4°)
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_06.png" %}
</center>
<h2 id="9">Triangulation</h2>
<p>Some functions are much faster on triangulated meshes. Therefore you can triangulate your grains with the following command.</p>
{% highlight matlab %}
grainsTri = grains3.triangulate
{% endhighlight %}

{% highlight plaintext %}
grainsTri = grain3d

Phase Grains Volume Mineral Symmetry Crystal reference frame
2 100 1 Copper m-3m

boundary faces: 2608

<strong>Properties</strong>: meanRotation
{% endhighlight %}
<h2 id="10">Slicing</h2>
<h2 id="5">Slicing</h2>
<p>To get the usually used 2d grain data, it is possible to slice 3d grains by different methods.</p>
{% highlight matlab %}
% make all slices passing through this point
% make all slices passing through the center point of the cube
P0 = vector3d(0.5,0.5,0.5);
% with normal (1,-1,1)
N = vector3d(1,-1,1);

% Slice by plane normal and point
N = vector3d(1,-1,0);
grains1_10 = grains3.slice(N,P0)
grains_2d = grains.slice(N,P0)

% plot the slice and adjust the plotting convention such that N points out
% of screen
plot(grains_2d,grains_2d.meanOrientation,'micronbar','off')
how2plot = plottingConvention;
how2plot.outOfScreen = N;
plot(grains1_10,grains1_10.meanOrientation)
setCamera(how2plot)
{% endhighlight %}

{% highlight plaintext %}
grains1_10 = grain2d
grains_2d = grain2d

Phase Grains Pixels Mineral Symmetry Crystal reference frame
2 39 39 Copper m-3m
2 41 41 Quartz 321 X||a*, Y||b, Z||c*

boundary segments: 118 (16 µm)
boundary segments: 126 (16 µm)
inner boundary segments: 0 (0 µm)
triple points: 59
triple points: 64

<strong>Properties</strong>: meanRotation
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_07.png" %}
{% include inline_image.html file="Grains3D_04.png" %}
</center>
<h2 id="6">Grains intersecting a slice</h2>
<p>Lets plot the grains intersecting the plane in 3d</p>
{% highlight matlab %}
% Slice by matgeom plane
N3 = vector3d(2,2,4);
plane = createPlane(P0.xyz, N3.xyz); % consider the different order
grains224 = grains3.slice(plane);

% Slice going through 3 points
A = vector3d(0,0,0.5);
B = vector3d(0,1,0.5);
grains001 = grains3.slice(P0,A,B);

% plot the slices
plot(grains001,grains001.meanOrientation);
isInter = grains.intersected(N,P0);
hold on
plot(grains1_10,grains1_10.meanOrientation);
hold on
plot(grains224,grains224.meanOrientation);

% set camera
how2plot = plottingConvention;
how2plot.outOfScreen = vector3d(-10,-5,2);
how2plot.east = vector3d(1,-2,0);
setCamera(how2plot)
{% endhighlight %}

{% highlight plaintext %}
Warning: still can not concatenate grains on different slices
Warning: still can not concatenate grains on different slices
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_08.png" %}
</center>
<p>Plot single 3D grains together with slices</p>
{% highlight matlab %}
grains = grains3(1:5)
plot(grains(isInter),grains(isInter).meanOrientation)
hold off

plot(grains,grains.meanOrientation)
how2plot.outOfScreen = vector3d(-10,-4,1);
how2plot.east = vector3d(2,-5,0);
how2plot.north = N;
how2plot.outOfScreen = vector3d(1,-1,-1)
setCamera(how2plot)
{% endhighlight %}

{% highlight plaintext %}
grains = grain3d

Phase Grains Volume Mineral Symmetry Crystal reference frame
2 5 0.045 Copper m-3m

boundary faces: 56
how2plot = plottingConvention

Id Phase Pixels meanRotation
1 2 1 (34.7°,42.2°,355.5°)
2 2 1 (26.2°,40.1°,352.1°)
3 2 1 (192.7°,31.1°,202.9°)
4 2 1 (203.7°,32.5°,173.5°)
5 2 1 (216.3°,46.1°,172.4°)
outOfScreen: (1,-1,-1)
north : (5,-3,8)
east : (6,7,-1)
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_09.png" %}
{% include inline_image.html file="Grains3D_05.png" %}
</center>
<h2 id="13">Slice Dream3d Grains</h2>
<p>still inefficient, expensive</p>
<h2 id="7">Plot the normal directions of one grain</h2>
{% highlight matlab %}
N = vector3d(1,1,1);
P0 = vector3d(0.5,0.5,0.5);

slice = grains.slice(N,P0);
plot(slice,slice.meanOrientation);
%grains = grains(1)
%dir = grains.I_GF(1,:)' .* grains.boundary.N % flip according to I_GF
%quiver(grains.boundary,dir)
%plot(grains)
{% endhighlight %}
<center>
{% include inline_image.html file="Grains3D_10.png" %}
</center>
</div>
</body>
</html>
Loading

0 comments on commit 6b44c75

Please sign in to comment.