Skip to content

Commit

Permalink
Cleaned code
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Nov 14, 2014
1 parent 3a39609 commit 7edd106
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 102 deletions.
3 changes: 2 additions & 1 deletion MTEX_functions/MTEX_getBX_misorientation.m
@@ -1,5 +1,6 @@
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function misorientation = MTEX_getBX_misorientation(ori_grainA, ori_grainB, varargin)
function misorientation = ...
MTEX_getBX_misorientation(ori_grainA, ori_grainB, varargin)
%% MTEX function used for the calculation of the misorientation between 2 grains in degrees
% Cho J.-H. et al., "Determination of a Mean Orientation in Electron
% Backscatter Diffraction Measurements", Met. & Mat. Trans. A, 2005, Vol.36A, pp. 3427.
Expand Down
3 changes: 2 additions & 1 deletion MTEX_functions/MTEX_setBX_orientation.m
@@ -1,5 +1,6 @@
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function ori_grain = MTEX_setBX_orientation(phase, ca_ratio, eulers_angle, varargin)
function ori_grain = ...
MTEX_setBX_orientation(phase, ca_ratio, eulers_angle, varargin)
%% Set orientation of a grain by using MTEX function
% phase = Crystal Structure (CS for MTEX)
% eulers_angle = Euler angles (Bunge) in degrees
Expand Down
12 changes: 8 additions & 4 deletions YAML_functions/load_YAML_BX_example_config_file.m
Expand Up @@ -95,7 +95,9 @@
end

%% Set specific slips for grains A and B
if (~isfield(GB_YAML, 'SlipA_norm') && ~isfield(GB_YAML, 'SlipA_dir')) && (~isfield(GB_YAML, 'SlipB_norm') && ~isfield(GB_YAML, 'SlipB_dir'))
if (~isfield(GB_YAML, 'SlipA_norm') && ~isfield(GB_YAML, 'SlipA_dir')) ...
&& (~isfield(GB_YAML, 'SlipB_norm') ...
&& ~isfield(GB_YAML, 'SlipB_dir'))
GB_YAML.SlipA_norm = {[0], [0], [0], [1]};
GB_YAML.SlipA_dir = {[2], [-1], [-1], [0]};
GB_YAML.SlipB_norm = {[0], [0], [0], [1]};
Expand All @@ -116,8 +118,10 @@

slipA_all_vect = slip_systems(GB_YAML.Phase_A, 9);
slipB_all_vect = slip_systems(GB_YAML.Phase_B, 9);
specific_slips_A = get_slip_indices(GB_YAML.slipA_str_dir, slipA_all_vect, 2);
specific_slips_B = get_slip_indices(GB_YAML.slipB_str_dir, slipB_all_vect, 2);
specific_slips_A = ...
get_slip_indices(GB_YAML.slipA_str_dir, slipA_all_vect, 2);
specific_slips_B = ...
get_slip_indices(GB_YAML.slipB_str_dir, slipB_all_vect, 2);

specific_slips_AB = [specific_slips_A, specific_slips_B];

Expand Down Expand Up @@ -151,4 +155,4 @@
end
clear Names;

end
end
5 changes: 3 additions & 2 deletions coordinate_system/coordinate_convention.m
@@ -1,5 +1,6 @@
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function coordinate_convention_matrix = coordinate_convention(coordinate_angle, varargin)
function coordinate_convention_matrix = ...
coordinate_convention(coordinate_angle, varargin)
% coordinate_angle: Angle to rotate coordinate system of EBSD system

% Z out of the plane
Expand Down Expand Up @@ -53,4 +54,4 @@
coordinate_convention_matrix;
end

end
end
11 changes: 7 additions & 4 deletions coordinate_system/coordinate_system_apply.m
@@ -1,11 +1,12 @@
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function eulers_out = coordinate_system_apply(eulers_in, CCM, testFlag, varargin)
function eulers_out = ...
coordinate_system_apply(eulers_in, CCM, testFlag, varargin)
%% Function used to apply the user selected coordinate system to the orientation
% eulers_in : Euler angles in degree before modification of the coordinates sytem
% ccm (coordinate convention matrix): Results from the function coordinate_convention_matrix.m
% testFlag: Flag to test the function (1 if the user want to test)

% author: c.zambaldi@mpie.de / d.mercier@mpie.de
% authors: c.zambaldi@mpie.de / d.mercier@mpie.de

if nargin < 3
testFlag = false;
Expand Down Expand Up @@ -33,8 +34,10 @@
eulers_out = g2eulers(g_out);

if testFlag
fprintf('Euler angles in : %.1f° %.1f° %.1f°\n',eulers_in(1),eulers_in(2),eulers_in(3));
fprintf('Euler angles out : %.1f° %.1f° %.1f°\n',eulers_out(1),eulers_out(2),eulers_out(3));
fprintf('Euler angles in : %.1f° %.1f° %.1f°\n', ...
eulers_in(1),eulers_in(2),eulers_in(3));
fprintf('Euler angles out : %.1f° %.1f° %.1f°\n', ...
eulers_out(1),eulers_out(2),eulers_out(3));
end

end
3 changes: 2 additions & 1 deletion gui_preCPFE/abaqus/abaqus_bias.m
Expand Up @@ -68,7 +68,8 @@

if testing
% for p = 2, num_elem = 10 and length = 10
dist0 = [1.380, 1.278, 1.183, 1.095, 1.014, 0.94, 0.87, 0.81, 0.75, 0.69];
dist0 = [1.380, 1.278, 1.183, 1.095, 1.014, ...
0.94, 0.87, 0.81, 0.75, 0.69];
if p == -2 || p == 0.5
dist0 = fliplr(dist0);
end
Expand Down
3 changes: 2 additions & 1 deletion gui_preCPFE/marc_mentat/mentat_bias.m
Expand Up @@ -41,7 +41,8 @@
biased_elem(1) = t_true(1);
for jj = 1:num_elements
ratio(jj) = (t_star(jj+1)-t_star(jj))/(t(jj+1)-t(jj));
biased_elem(jj+1) = ratio(jj) * (t_true(jj+1)-t_true(jj)) + biased_elem(jj);
biased_elem(jj+1) = ratio(jj) * ...
(t_true(jj+1)-t_true(jj)) + biased_elem(jj);
end

if testing
Expand Down
3 changes: 2 additions & 1 deletion gui_preCPFE/preCPFE_indentation_setting_BX.m
Expand Up @@ -288,7 +288,8 @@
gdata.variables_geom.top8121617_y(:) = gdata.variables.sample_coordy_rightface;

%% Clear axes
cla;shg
cla;
shg;

%% Plot the sample mesh

Expand Down
2 changes: 1 addition & 1 deletion gwyddion/read_gwyddion_ascii.m
Expand Up @@ -102,4 +102,4 @@
topo_plot(topo)
set(gcf,'name','original data');
end
return
return
17 changes: 10 additions & 7 deletions microstructure_generation/neighbooring_edge_of_2cells.m
Expand Up @@ -17,7 +17,8 @@
[v, reg] = voronoiDiagram(dt);
if length(reg) ~= size(dt.X,1)
% My 2012B might end up here, which I think is a bug (due to numerical errors)
disp('voronoiDiagram fails (bug)');
commandwindow;
error('voronoiDiagram fails (bug)');
random_2D_microstructure_data;
end
K = dt.convexHull;
Expand Down Expand Up @@ -60,19 +61,21 @@

% which edge is infinity
edgeinf = edges(:,1)==1;
[~, locinf]=ismember(sort(ridx(:,edgeinf))',sort([K(1:end-1) K(2:end)],2),'rows');
[~, locinf] = ismember(sort(ridx(:,edgeinf))', ...
sort([K(1:end-1) K(2:end)],2),'rows');
vx(1,edgeinf) = XInf(1,locinf);
vy(1,edgeinf) = XInf(2,locinf);

xr = x(ridx);
yr = y(ridx);

if flag
figure(1)
clf
plot(x,y,'r+',vx,vy,'b-o',xr,yr,'g')
axis equal
figure(1);
clf;
plot(x,y,'r+',vx,vy,'b-o',xr,yr,'g');
axis equal;
axis([-0.5 1.5 -0.5 1.5]);
disp (ridx)
disp (ridx);
end
end
end
30 changes: 21 additions & 9 deletions microstructure_generation/random_2D_microstructure_data.m
@@ -1,5 +1,6 @@
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function rdm_microstructure_dataset = random_2D_microstructure_data (number_of_grains, resolution, varargin)
function rdm_microstructure_dataset = ...
random_2D_microstructure_data(number_of_grains, resolution, varargin)
%% Function used to create random EBSD data based on TSL files (GF Type2 and RB file)
% number_of_grains : Number of grains for the Voronoi tesselation
% resolution : resolution along x and y axis for generation of seeds file
Expand Down Expand Up @@ -48,12 +49,19 @@
end

% GBs endpoints coordinates
[rdm_microstructure_dataset.GBvx, rdm_microstructure_dataset.GBvy, rdm_microstructure_dataset.GB2cells(:,:), rdm_microstructure_dataset.flag_VorFailed] = ...
neighbooring_edge_of_2cells(rdm_microstructure_dataset.x_positions', rdm_microstructure_dataset.y_positions');
[rdm_microstructure_dataset.GBvx, ...
rdm_microstructure_dataset.GBvy, ...
rdm_microstructure_dataset.GB2cells(:,:), ...
rdm_microstructure_dataset.flag_VorFailed] = ...
neighbooring_edge_of_2cells(...
rdm_microstructure_dataset.x_positions', ...
rdm_microstructure_dataset.y_positions');

% GBs coordinates
GB(1,:) = rdm_microstructure_dataset.GBvx(2,:) - rdm_microstructure_dataset.GBvx(1,:);
GB(2,:) = rdm_microstructure_dataset.GBvy(2,:) - rdm_microstructure_dataset.GBvy(1,:);
GB(1,:) = rdm_microstructure_dataset.GBvx(2,:) - ...
rdm_microstructure_dataset.GBvx(1,:);
GB(2,:) = rdm_microstructure_dataset.GBvy(2,:) - ...
rdm_microstructure_dataset.GBvy(1,:);
GB(3,:) = zeros;

% flag is to know if the voronoiDiagram fails (degenerated case?)
Expand All @@ -79,17 +87,21 @@
rdm_microstructure_dataset.gb_length(1,ii) = norm(GB(ii));

CosTheta = dot(GB(:,ii),[1,0,0])/(norm(GB(:,ii))*norm([1,0,0]));
rdm_microstructure_dataset.gb_trace_angle(1,ii) = acos(CosTheta)*180/pi;
rdm_microstructure_dataset.gb_trace_angle(1,ii) = ...
acos(CosTheta)*180/pi;
end

rdm_microstructure_dataset.GBvx = rdm_microstructure_dataset.GBvx';
rdm_microstructure_dataset.GBvy = rdm_microstructure_dataset.GBvy';
rdm_microstructure_dataset.GB2cells = rdm_microstructure_dataset.GB2cells';

rdm_microstructure_dataset.confidence_index = ones((resolution*resolution), 1);
rdm_microstructure_dataset.image_quality = ones((resolution*resolution), 1);
rdm_microstructure_dataset.confidence_index = ...
ones((resolution*resolution), 1);
rdm_microstructure_dataset.image_quality = ...
ones((resolution*resolution), 1);
rdm_microstructure_dataset.phase_ang = ones((resolution*resolution), 1);
rdm_microstructure_dataset.detector_intensity = ones((resolution*resolution), 1);
rdm_microstructure_dataset.detector_intensity = ...
ones((resolution*resolution), 1);
rdm_microstructure_dataset.fit = ones((resolution*resolution), 1);

rdm_microstructure_dataset.x_pixel_pos = 1:(resolution*resolution);
Expand Down
14 changes: 9 additions & 5 deletions preCPFE_mesh_plot_finalize.m
@@ -1,8 +1,12 @@
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function preCPFE_mesh_plot_finalize
% Axis setting
%% Axis setting

axis tight; % Axis tight to the sample
axis equal; % Axis aspect ratio
grid off
xyzlabel
rotate3d on
shg
grid off;
xyzlabel;
rotate3d on;
shg;

end
10 changes: 7 additions & 3 deletions tsl_oim/open_file_GF2.m
Expand Up @@ -15,7 +15,9 @@ function open_file_GF2(starting_folder, varargin)
% authors: c.zambaldi@mpie.de / d.mercier@mpie.de

if nargin == 0
starting_folder = fullfile(getenv('SLIP_TRANSFER_TBX_ROOT'), 'gui_ebsd_map', 'EBSD_data_Examples');
starting_folder = ...
fullfile(get_stabix_root, ...
'gui_ebsd_map', 'EBSD_data_Examples');
end

%% Get data from the GUI
Expand All @@ -24,7 +26,9 @@ function open_file_GF2(starting_folder, varargin)
cd(starting_folder);

%% FileGF2 loading
[filenameGF2, pathnameGF2] = uigetfile([gui.config_map.TSLOIM_data_path_GF2, '.txt'], 'Select the ''Grain File Type 2'' file');
[filenameGF2, pathnameGF2] = ...
uigetfile([gui.config_map.TSLOIM_data_path_GF2, '.txt'], ...
'Select the ''Grain File Type 2'' file');
% Handle canceled file selection
if filenameGF2 == 0
filenameGF2 = '';
Expand All @@ -51,6 +55,6 @@ function open_file_GF2(starting_folder, varargin)

guidata(gcf, gui);

cd(getenv('SLIP_TRANSFER_TBX_ROOT'));
cd(get_stabix_root);

end
9 changes: 6 additions & 3 deletions tsl_oim/open_file_RB.m
Expand Up @@ -16,7 +16,8 @@ function open_file_RB(starting_folder, varargin)
% authors: c.zambaldi@mpie.de / d.mercier@mpie.de

if nargin == 0
starting_folder = fullfile(getenv('SLIP_TRANSFER_TBX_ROOT'), 'gui_ebsd_map', 'EBSD_data_Examples');
starting_folder = fullfile(get_stabix_root, ...
'gui_ebsd_map', 'EBSD_data_Examples');
end

%% Get data from the GUI
Expand All @@ -25,7 +26,9 @@ function open_file_RB(starting_folder, varargin)
cd(starting_folder);

%% FileRB loading
[filenameRB, pathnameRB] = uigetfile([gui.config_map.TSLOIM_data_path_GF2, '.txt'], 'Select the ''Reconstructed Boundary'' file');
[filenameRB, pathnameRB] = ...
uigetfile([gui.config_map.TSLOIM_data_path_GF2, '.txt'], ...
'Select the ''Reconstructed Boundary'' file');
% Handle canceled file selection
if filenameRB == 0
filenameRB = '';
Expand All @@ -52,6 +55,6 @@ function open_file_RB(starting_folder, varargin)

guidata(gcf, gui);

cd(getenv('SLIP_TRANSFER_TBX_ROOT'));
cd(get_stabix_root);

end
6 changes: 4 additions & 2 deletions tsl_oim/read_oim_grain_file_type2.m
Expand Up @@ -66,12 +66,14 @@
DIAM_OK = true;
end
else
if ~(GRAIN_NUMBERS_OK && EULER_ANGLES_OK && AVG_POS_XY_OK && PHASE_OK)
if ~(GRAIN_NUMBERS_OK && EULER_ANGLES_OK && ...
AVG_POS_XY_OK && PHASE_OK)
fclose(fid);
error('Grain File Type 2 columns are wrong !')
end
if ~(EDGE_GRAIN_OK && DIAM_OK)
warning('Missing information if edge or interior grain, and diameter of grains !')
warning(['Missing information if edge or interior grain, ' ...
'and diameter of grains !'])
end
ii = ii + 1;
data(ii,:) = sscanf(ln,'%f');
Expand Down
15 changes: 9 additions & 6 deletions tsl_oim/read_oim_reconstructed_boundaries_file.m
@@ -1,5 +1,6 @@
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function RB = read_oim_reconstructed_boundaries_file(fname, fpath, varargin)
function RB = ...
read_oim_reconstructed_boundaries_file(fname, fpath, varargin)
%% Function to read TSL-OIM reconstructed boundaries file
% fname : Name of the reconstructed boundaries file
% fpath : Path to the reconstructed boundaries file
Expand Down Expand Up @@ -48,10 +49,12 @@
ln = fgetl(fid);
if ln(1) == '#';
header{end+1} = ln;
if strfind(ln, 'right hand average orientation (phi1, PHI, phi2 in radians)')
if strfind(ln, ['right hand average orientation ' ...
'(phi1, PHI, phi2 in radians)'])
RIGHT_ORI_OK = true;
end
if strfind(ln, 'left hand average orientation (phi1, PHI, phi2 in radians)')
if strfind(ln, ['left hand average orientation ' ...
'(phi1, PHI, phi2 in radians)'])
LEFT_ORI_OK = true;
end
if strfind(ln, 'length (in microns)')
Expand All @@ -67,7 +70,8 @@
ID_GRAINS_OK = true;
end
else
if ~(RIGHT_ORI_OK && LEFT_ORI_OK && GB_LENGTH_OK&& GB_TRACE_ANGLE_OK&& GB_ENDPOINTS_COORD_OK && ID_GRAINS_OK)
if ~(RIGHT_ORI_OK && LEFT_ORI_OK && GB_LENGTH_OK && ...
GB_TRACE_ANGLE_OK&& GB_ENDPOINTS_COORD_OK && ID_GRAINS_OK)
fclose(fid);
error('Reconstructed Boundaries File columns are wrong !')
end
Expand Down Expand Up @@ -123,5 +127,4 @@
col_idx.GRAIN_ID = idx;
end
end
end

end

0 comments on commit 7edd106

Please sign in to comment.