%% Schmid FactorcsSF = ebsd('Iron fcc').CS;% consider fcc slipsS = slipSystem.fcc(csSF);% and all symmetrically equivalent variantssS = sS.symmetrise;
sigma = stressTensor.uniaxial(xvector); % anyway to define neagtive xvector?
% compute Schmid factor for all slip systemsSF = sS.SchmidFactor(inv(grains('Iron fcc').meanOrientation) * sigma);% find the maximum Schmidt factor (along the rows)[SFmax,active] = max(SF,[],2);% plot the maximum Schmid factor (for each grain)figureplot(grains('Iron fcc'),SFmax,'micronbar','off');mtexColorbar% take the active slip system and rotate it in specimen coordinatessSGrain = grains('Iron fcc').meanOrientation .* sS(active);% plot then the plane normal and the Burgers vectors into the centers% of the grainshold on% visualize the trace of the slip plane (plane normal)quiver(grains('Iron fcc'),cross(sSGrain.n,zvector),'displayName','slip plane','color','k');% and the slip direction (Burgers vectors)quiver(grains('Iron fcc'),sSGrain.b,'displayName','slip direction','color','r');hold off
%% Schmid FactorcsSF = ebsd('Iron fcc').CS;% consider fcc slipsS = slipSystem.fcc(csSF);% and all symmetrically equivalent variantssS = sS.symmetrise;
% compute Schmid factor for all slip systems
SF = sS.SchmidFactor(inv(grains('Iron fcc').meanOrientation)*xvector);
% find the maximum Schmidt factor (along the rows)[SFmax,active] = max(SF,[],2);% plot the maximum Schmid factor (for each grain)figureplot(grains('Iron fcc'),SFmax,'micronbar','off');mtexColorbar
setColorRange([0.43 0.48])axis off% The variable active contains now for each grain the id of the slip system% with the largest Schmidt factor. In order to visualize it, we first% rotate for each grain the slip system with largest Schmid factor in% specimen coordinates
sSGrain = grains('Iron fcc').meanOrientation .* sS(active);% plot then the plane normal and the Burgers vectors into the centers% of the grainshold on% visualize the trace of the slip plane (plane normal)quiver(grains('Iron fcc'),cross(sSGrain.n,zvector),'displayName','slip plane','color','k');% and the slip direction (Burgers vectors)quiver(grains('Iron fcc'),sSGrain.b,'displayName','slip direction','color','r');hold off