%%                        MTEX Workshop 2020
%
%%                         Exercises Day 5
%
%% Exercise 5.1
% 
%% a) 
% Inspect the the MTEX Titanium sample data set.

mtexdata titanium

%% 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 5.2
%
%% 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



%% Exercise 5.3
%
%% a)
% Import and investigate the ellastic tensor of ollivine

% file name
fname = fullfile(mtexDataPath,'tensor','Olivine1997PC.GPa');

% crytsal symmetry
cs = crystalSymmetry('mmm',[4.7646 10.2296 5.9942],'mineral','Olivin');

% define the tensor
C = stiffnessTensor.load(fname,cs)

%% b) 
% Compute the linear compressibility of Olivine along the c-Axis without
% using the command "linearCompressibility".


%% c) 
% Visualize linear compressability. In which direction it is at maximum and
% minimum? What is the difference?


%% d)
% Compute the Voigt and Reuss bounds of the stiffness tensor for an
% isotropuc medium. From this derive Voigt and Reuss bounds of the linear
% compressability and compare them with the values dervided in c).

%% e)
% Derive the isotropic Poisson ratio and the isotropic Youngs modulus and
% verify that you can recover the stiffness tensor using theses values
% only.

%% f)
% Compute wave velocities and polarisation directions in Olivine. Verify
% that the polarization directions of the p-wave, the s1 wave and the s2
% wave are all orthogonal.

%% g)
% Compare the polarization directions of the p-wave for the isotropic case
% and the anisotropic case.

