mtex-toolbox / mtex

MTEX is a free Matlab toolbox for quantitative texture analysis. Homepage:
http://mtex-toolbox.github.io/
GNU General Public License v2.0
278 stars 183 forks source link

Calculation of schmid factor and Taylor factor, Symmetrise issue #1907

Closed chitturiveerendra closed 1 year ago

chitturiveerendra commented 1 year ago

What do you want to do? I want to calculate Schmid factor and Taylor factor and plot the same for Magnesium alloy What data do you have?

What code do you use? Please provide minimalist code with code in the following form


function [SFMax, TFMax] = ComputeSFTF(CS, file, ebsd, grains)
%
% modified by cho for SF and TF
%
% Stress conditions for Schmid Factors
%
% uniaxial compression along the Z, vector3d.Z
% uniaxial tension along the Z, vector3d.Z
%
sigma = stressTensor.uniaxial(vector3d.Z);
%sigma = stressTensor.uniaxial(vector3d.Y);
%sigma = stressTensor.uniaxial(vector3d.X);
sigma = -sigma

%
% Strain conditions for Taylor Factors
%
%
eps = strainTensor(diag([0.5,0.5,-1]))
%eps = strainTensor(diag([0.5,-1,0.5]))
%eps = strainTensor(diag([-1, 0.5,0.5]))

%
% Analysis of Schmid and Taylor factors
%
for i=1:6
%__________________________________________________________________________
% SF
%
if i==1
sS = slipSystem.basal(CS)
PF_graphic   =strcat(file,'_SF_Basal');
elseif i==2
sS = slipSystem.prismaticA(CS, 5)
PF_graphic   =strcat(file,'_SF_PrsA');
elseif i==3
sS = slipSystem.pyramidal2CA(CS,15)
PF_graphic   =strcat(file,'_SF_PyrCA');
elseif i==4
sS = slipSystem.twinT1(CS,2)
PF_graphic   =strcat(file,'_SF_TTW');
elseif i==5
sS = slipSystem.twinC1(CS,15)
PF_graphic   =strcat(file,'_SF_CTW');
elseif i==6
sS = slipSystem.hcpMg(CS)
PF_graphic   =strcat(file,'_SF_AllModes');
sS.CRSS(1) = 1;
sS.CRSS(2) = 5;
sS.CRSS(3) = 15;
sS.CRSS(4) = 2;
sS.CRSS(5) = 15;
end
%
sS = sS.symmetrise;
% 
disp('Before SF')
SFMax(:,i) = CalSF(ebsd, grains, sS, PF_graphic, sigma);

%__________________________________________________________________________
% TF
%
if i==1
sS = slipSystem.hcpMgBasalPrs(CS)
sS.CRSS(1) = 1;
sS.CRSS(2) = 5;
PF_graphic   =strcat(file, '_TF_BasalPrsA');
elseif i==2
sS = slipSystem.hcpMgBasalPyr(CS)
sS.CRSS(1) = 1;
sS.CRSS(2) = 15;
PF_graphic   =strcat(file,'_TF_BasalPyrCA');
elseif i==3
sS = slipSystem.hcpMgBasalTTW(CS)
sS.CRSS(1) = 1;
sS.CRSS(2) = 2;
PF_graphic   =strcat(file,'_TF_BasalTTW');
elseif i==4
sS = slipSystem.hcpMgBasalPrsTTW(CS)
sS.CRSS(1) = 1;
sS.CRSS(2) = 5;
sS.CRSS(3) = 2;
PF_graphic   =strcat(file,'_TF_BasalPrsATTW');
elseif i==5
sS = slipSystem.hcpMgBasalPyrTTW(CS)
sS.CRSS(1) = 1;
sS.CRSS(2) = 15;
sS.CRSS(3) = 2;
PF_graphic   =strcat(file,'_TF_BasalPryCATTW');
elseif i==6
sS = slipSystem.hcpMg2(CS)
PF_graphic   =strcat(file, '_TF_AllModes');
sS.CRSS(1) = 1;
sS.CRSS(2) = 5;
sS.CRSS(3) = 15;
sS.CRSS(4) = 2;
end
%
sS = sS.symmetrise;
disp('Before TF')
TFMax(:,i) = CalTF(ebsd, grains, sS, PF_graphic, eps);
%
end 

end

%%
function SFMax = CalSF(ebsd, grains, sS, PF_graphic, sigma)

% rotate slip systems into specimen coordinates
sSLocal = grains.meanOrientation * sS
%
SF = sSLocal.SchmidFactor(sigma);
%
% take the maxium allong the rows
[SFMax,active] = max(SF,[],2);
%
% plot the maximum Schmid factor
figure
plot(grains,SFMax,'micronbar','off','linewidth',2)
mtexColorbar('title','Schmid Factors','location','southoutside')
%
text(grains,grains.id, 'FontSize',7);
PF_graphic   =strcat(PF_graphic, '.jpg');
set(gcf,'name',PF_graphic)
saveas(gcf,PF_graphic)
%
%__________________________________________________________________________
% Slip Traces
%
% take the active slip system and rotate it in specimen coordinates
sSactive = grains.meanOrientation .* sS(active);
%
hold on
% visualize the trace of the slip plane
quiver(grains,sSactive.trace,'color','b')
%
% and the slip direction
quiver(grains,sSactive.b,'color','r')
hold off
%
end

%%
%
%
function SFMax = CalSFp(ebsd, grains, sS, PF_graphic, sigma)

% rotate slip systems into specimen coordinates
sSLocal = grains.meanOrientation * sS;
sSLocalp = ebsd('indexed').orientations * sS;

%
% compute Schmid factor during compression along the Z
%
%sigma = stressTensor.uniaxial(vector3d.Z*-1)
SF = sSLocal.SchmidFactor(sigma);
SFp = sSLocalp.SchmidFactor(sigma);

%
% take the maxium allong the rows
[SFMax,active] = max(SF,[],2);
[SFMaxp,activep] = max(SFp,[],2);

%
% plot the maximum Schmid factor
figure
plot(grains,SFMax,'micronbar','off','linewidth',2)
mtexColorbar('title','Schmid Factors','location','southoutside')
%
text(grains,grains.id, 'FontSize',7);
set(gcf,'name',PF_graphic)
saveas(gcf,PF_graphic,'jpg')

%
%__________________________________________________________________________
% Slip Traces
%
% take the active slip system and rotate it in specimen coordinates
sSactive = grains.meanOrientation .* sS(active);
%
hold on
% visualize the trace of the slip plane
quiver(grains,sSactive.trace,'color','b')
%
% and the slip direction
quiver(grains,sSactive.b,'color','r')
hold off
%
% plot the maximum Schmid factor for pixels
figure
plot(ebsd('indexed'),SFMaxp,'micronbar','off','linewidth',2); hold on
plot(grains.boundary,'lineColor',[1 0 0],'linewidth',2); hold off
mtexColorbar('title','Schmid Factors','location','southoutside')
%
%text(ebsd('indexed'),grains.id, 'FontSize',7);
PF_graphic_p   =strcat(PF_graphic, '_p');
set(gcf,'name',PF_graphic_p)
saveas(gcf,PF_graphic_p,'jpg')

end

%%
% Strain based analysis on the same data set
%
function TFMax = CalTF(ebsd, grains, sS, PF_graphic, eps)
%
%
epsCrystal = inv(grains.meanOrientation) * eps;

%
[TFMax, b] = calcTaylor(epsCrystal, sS);
%
[c1,c2] = size(grains);
for i = 1:c1
if TFMax(i) >= 10
    TFMax(i) = 10;
end
end
%
figure
plot(grains,TFMax,'micronbar','off')
%mtexColorbar southoutside
mtexColorbar('title','Taylor Factors','location','southoutside')
%
text(grains,grains.id,'FontSize',7);
PF_graphic   =strcat(PF_graphic, '.jpg');
set(gcf,'name',PF_graphic)
saveas(gcf,PF_graphic)
%
[ bMax , bMaxId ] = max( b , [ ] , 2 ) ;
sSGrains = grains.meanOrientation .* sS(bMaxId) ;
hold on
quiver ( grains , sSGrains.b)
quiver ( grains , sSGrains.trace)
hold off
%
%
%
end

%%
% Strain based analysis on the same data set
%
function TFMax = CalTFp(ebsd, grains, sS, PF_graphic, eps)
%
% compression along the Z
%
%eps = strainTensor(diag([0.5,0.5,-1]));
%
epsCrystal = inv(grains.meanOrientation) * eps;
epsCrystalp = inv(ebsd('indexed').orientations) * eps;

%
[TFMax, b] = calcTaylor(epsCrystal, sS);
[TFMaxp, bp] = calcTaylor(epsCrystalp, sS);

%
[c1,c2] = size(grains);
for i = 1:c1
if TFMax(i) >= 10
    TFMax(i) = 10;
end
end
%
figure
plot(grains,TFMax,'micronbar','off')
%mtexColorbar southoutside
mtexColorbar('title','Taylor Factors','location','southoutside')
%
text(grains,grains.id,'FontSize',7);
set(gcf,'name',PF_graphic)
saveas(gcf,PF_graphic,'jpg')
%
[ bMax , bMaxId ] = max( b , [ ] , 2 ) ;
sSGrains = grains.meanOrientation .* sS(bMaxId) ;
hold on
quiver ( grains , sSGrains.b)
quiver ( grains , sSGrains.trace)
hold off
%
% plot the Taylor factors for pixels
%
figure
plot(ebsd('indexed'),TFMaxp,'micronbar','off','linewidth',2); hold on
plot(grains.boundary,'lineColor',[1 0 0],'linewidth',2); hold off
mtexColorbar('title','Taylor Factors','location','southoutside')
%
%text(grains,grains.id,'FontSize',7);
PF_graphic_p   =strcat(PF_graphic, '_p');
set(gcf,'name',PF_graphic_p)
saveas(gcf,PF_graphic_p,'jpg')
%
end

**Error Message**
Unrecognized method, property, or field 'symmetrise' for class 'slipSystem'.
Error in Twinning_Analysis_SFTF>ComputeSFTF (line 674)
sS = sS.symmetrise;
Error in Twinning_Analysis_J_SFTF (line 556)
[SFMax, TFMax] = ComputeSFTF(CS, file, ebsd, grains)

**What MTEX version do you use?**
5.8.0