Skip to content

Commit

Permalink
Gradient Matrix. Big data boundary misorientation.
Browse files Browse the repository at this point in the history
Add gradient matrix calculation.
Add small function for progress display.
Add calcBoundaryMisorientation for Big sample, calc misorientation for
grains pairs.
  • Loading branch information
edwinofsakh committed May 26, 2015
1 parent 7742294 commit 11a3de6
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 11 deletions.
1 change: 1 addition & 0 deletions func/OR/close2KOG.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function [a, ind1, ind2, b] = close2KOG(mori, kog, epsilon)
% Find misorientation close to KOG

b = angle_outer(kog,mori);
[b,ind] = min(b,[],1);
Expand Down
23 changes: 23 additions & 0 deletions func/calcBoundaryMisorientationBig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function [ mori ] = calcBoundaryMisorientationBig( grains, varargin )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here

% Pairs of grains
[~, pairs] = neighbors(grains);

% One way for getting misorientations and lengths of boundary
for i = 1:length(pairs)
mori0 = calcBoundaryMisorientation(grains(pairs(i,1)),grains(pairs(i,2)), varargin{:});
if (i == 1)
mori = mori0;
else
mori = [mori; mori0]; %#ok<AGROW>
end
if (progressStatus(i,length(pairs),10))
fprintf(1,'.');
end
end
fprintf(1,' - done\n');

end

9 changes: 9 additions & 0 deletions func/dev/progressStatus.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function f = progressStatus( i, n, part )
%Return true if progress has reached a specified value.

if (mod(i,fix(n/part)) == 0)
f = true;
else
f = false;
end

5 changes: 5 additions & 0 deletions func/misc/gradM.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function L = gradM(R, U)

nabla = R.'/(R*(R.'));

L = (U*nabla).';
54 changes: 43 additions & 11 deletions tcode/test_FindClosePoints.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ebsd = ak06_load();
ebsd = cutEBSD(ebsd, 0,0, 100,100);
%% Load sample
ebsd = af03s_load();
ebsd = cutEBSD(ebsd, 50,30, 40,40);

%% Find pattern
patterns = [];
Expand All @@ -14,7 +15,7 @@
MY = max(Y);

i = randi(length(X),1);
a = 1;
a = 0.5;

while ((X(i) - mX) <= 2*a || (Y(i) - mY) <= 2*a) || ((MX - X(i)) <= 2*a || (MY - Y(i)) <= 2*a)
i = randi(length(X),1);
Expand All @@ -35,46 +36,77 @@
X2 = X(ind3);
Y2 = Y(ind3);

% scatter(X2,Y2);
% axis equal;
%ind1 - i
pt = (ind3 - i);
length(pt)
patterns(:,k) = pt;
end

%% Plot pattern
% scatter(X2,Y2,'fill'); box on;
% axis equal;

%% Borders
X1 = X-mX > 1.5*a;
X2 = MX-X > 1.5*a;
Y1 = Y-mY > 1.5*a;
Y2 = MY-Y > 1.5*a;

% Indices of orientation in region
in_ind = find(X1&X2&Y1&Y2);

% Indices of points and neighbours
iind2 = repmat(patterns',length(in_ind),1) + repmat(in_ind,1,length(patterns));

scatter(X,Y,5,'sb');
hold on;
scatter(X(iind2(:)),Y(iind2(:)),5,'sr');
% Plot
% scatter(X,Y,5,'sb');
% hold on;
% scatter(X(iind2(:)),Y(iind2(:)),5,'sr');

%% Process all orientation
% o = get(ebsd,'orientation');
% c = fix(length(patterns)/2)+1;
%
% for i = 1:length(in_ind)
% ind = iind2(i,:);
% j = ind(c);
% o0 = o(j);
% o1 = o(ind);
% mo1 = o1\o0;
%
% dX = X(ind)-X(j);
% dY = Y(ind)-Y(j);
% end

%% Make R and U
% Get orientations
o = get(ebsd,'orientation');
om = o(iind2);

% Center point offset
c = fix(length(patterns)/2)+1;

% Init matrix
Rs = zeros(3, length(patterns)*2, length(in_ind));
Us = zeros(3, length(patterns)*2, length(in_ind));

for i = 1:length(in_ind)
ind = iind2(i,:);
j = ind(c);

o0 = o(j);
o1 = o(ind);

mo1 = o1\o0;

dX = X(ind)-X(j);
dY = Y(ind)-Y(j);
U = (angle(mo1)/degree).*vector3d(normalize(axis(mo1)));

Rs(:,:,i) = [X(ind)' X(ind)'; Y(ind)' Y(ind)'; [-1*ones(1,length(ind)), ones(1,length(ind))];];
Us(:,:,i) = [getx(U)' getx(U)'; gety(U)' gety(U)'; getz(U)' getz(U)'];
end

%% Process all orientation


c = mat2cell(o(iind2), ones(1,length(in_ind)), length(pt));
om = repmat(Eori,length(in_ind),1);

Expand Down

0 comments on commit 11a3de6

Please sign in to comment.