%%                        MTEX Workshop 2020
%
%%                         Exercises Day 2
%
%% Exercise 1
%
%% a)
% Generate 1000 random orientations with symmetry 112. Compute the
% rotational angle of all these orientations and display the coresponding
% histogram.
%
% useful commands: histogram, orientation.rand


%% b)
% What is the maximum rotational angle? What is the corresponding axis?



%% c)
% Plot the position of the {111} planes with respect to the random
% orientations from a) without using the command plotPDF.



%% d)
% Visualize the random orientations from a) in the Z - inverse pole figure
% without using the command plotIPDF.
%
% usefull options: fundamentalSector


%% d)
% Redo a) - d) for the symmetries 222 and 432.


%% Exercise 2
%
% Consider orthorhombic crystal symmetry and inspect the following pole
% figures:

cs = crystalSymmetry('222');

ori = secret('2_5'); % some secret orientations

% plot pole figures
h = Miller({0,0,1},{0,1,0},{1,0,0},{1,1,0},{1,1,1},cs)
plotPDF(ori,h,'MarkerSize',4)

%% a)
% How many prefered orientations are displayed? Why the number of spots
% differes so much between the different pole figures?
%
% useful commands: Miller/multiplicity, calcCluster



%% b)
% Determine approximately the prefered orientation(s) and annotate them to
% the pole figure.


%% c)
% Replace the crystal symmetry by the corresponding Laue group? Plot the
% pole figures. How many poles do you expect and how many do you observe?


%% Exercise 3
% 
% Consider cubic crystal symmetry and inspect the following inverse pole
% figures:

cs = crystalSymmetry('m-3m')
ori = secret('2_6'); % some secret orientations

plotIPDF(ori,[vector3d.Z,vector3d.X],'MarkerSize',3)


%% a)
% Determine approximately the preferred orientation.



%% b)
% What is the percentage of orientations within a 5 degree ball around the
% preferrd orientation?




%% c)
% Visualize those orientations in 3d Euler angle space, in 3d axis angle
% space and in phi2 sections.



%% Exercise 4
%
%% a) 
% Consider hexagonal symmetry with two different setups x||a and x||a*.
% Define the orientatation (20,30,40) with respect to both setups and
% visualize them in the three dimensional Euler angle space and the 
% three dimensional axis angle space. What do you observe?



%% b)
% Visualize both orientations in a pole figure plot. Are those the same or
% different? Why?


%% c)
% Visualize both orientations in an inverse pole figure plot. Are those the
% same or different? Why?



%% d)
% Define the crystal direction (11-21) for both setups and compute the
% resulting specimen directions for any combination of setups, i.e., setup
% 1/2 for the orientation times setup 1/2 for the crystal direction. What
% does the resulting specimen direction depend on? Why?



%% e)
% Define the orientation (11-21)[1-100] with respect to both setups. Are
% they the same?
%
% useful commands: orientation.byMiller



%% Exercise 5
%
%% a)
% Consider cubic crystal symmetry and orthorhombic specimen symmetry and
% define the Brass, Goss, Cube and Copper standard orientations.

%% b)
% Determine the multiplicity of each of the standard orientations.

%% c)
% Visualize the orientatios in the different 3d and 2d orientation
% representations. How is the multiplicity related to the geometrical
% position within the orientation space?

%% Exercise 6
%
%% a) 
% Most fundamental sectors of crystal symmetries are triangles. The
% fundamental sector of which crystal symmetry is a quadrangle? Visualize
% it.



%% b)
% In fact the fundamental sector for this symmetry could by replaced by a
% triangle. Which one? Define and visualize it.


%% Exercise 7
% 
%% a) 
% Inspect the orientations of the MTEX Titanium sample data set.

mtexdata titanium

ori = ebsd.orientations

%% b)
% Compute an ODF and visualize it by a c-axis pole figure and sigma
% sections.
%
% useful commands: calcODF


%% c)
% Repeat (b) with differet kernel halfwidths. Which halfwidth would you
% think to be optimal?




%% d)
% Determine "optimal" kernel using the function calcKernel with different
% methods, i.e., ruleOfThumb, magicRule, default. Compare with your choice
% from (b).



%% e)
% You should have recogniczed that the halfwidth estimated in d) is much
% smaller than your choice from c). The reason is, that calcKernel assumes
% the orientations as spatialy independent - which they are clearly not in
% the case of grains. As a way out you may do the following:
%
% (i)  reconstruct grains
% (ii) Determine "optimal" kernel using the function calcKernel but from
% the grain meanorientations instead of the EBSD orientations.

%% f)
% Compute the textureindex of the reconstructed ODF. Make a plot that shows
% the dependency between the halfwidth used for ODF estimation and the
% texture index of the resulting ODF.


%% g)
% Compute a density function from the c-axis poles of the origial EBSD data
% and compare it with the pole density function computed from the ODF.


%% i)
% Compute a random sample of this c-axis pole density function and check
% how close they are to the original sampling.



%% Exercise 8
%
%% a)
% Import the Dubna Neutron test data and inspect them visually.

mtexdata dubna

plot(pf)

%% b)
% In each pole figure there are two theta angles for which the intensities
% do not fit very well to the other theta angles. Identify these circles
% and remove them from the data.
%
% useful commands: pf.r, pf.r.theta


%% c)
% Reconstruct an ODF from the neutron data and visualize compare its pole
% density functions with the measured data.
%
% useful commands: ODF/plotPDF


%% d)
% Plot the c-axis pole figure from the reconstructed ODF. Compute and mark
% the prefered direction of the c-axis.


%% e)
% Determine volume percentage of c-axes orientations within a 10 degree
% ball round the prefered c-axis direction. Compare the percentage with an
% untextured ODF.

%% f)
% Visualize the ODF in sigma sections and compare these with the c-axis
% pole figure. 


%% g)
% Find two prefered orientations within the ODF.
%
% useful commands: ODF/max


%% h)
% Try to approximate the reconstructed ODF by an model ODF consisting of 3
% components only. 
%
% useful commands: unimodalODF, uniformODF, fibreODF, binghamODF, 


%% i)
% Determine the error between the ODF computed from the neutron data and
% your approximation in h).
%
% useful commands: ODF/calcError

