Skip to content

Commit

Permalink
Created new from the old YL repo for single phase
Browse files Browse the repository at this point in the history
This is for solid solution stage i.e. does not consider elastic or plastic inclusions as in precipitation strengthened alloys.
  • Loading branch information
manasijy authored Jan 10, 2024
0 parents commit b048008
Show file tree
Hide file tree
Showing 40 changed files with 10,380 additions and 0 deletions.
56 changes: 56 additions & 0 deletions BHfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
1.00 -1.00 0.00 0.00 0.00 0.00
0.00 1.00 -1.00 0.00 0.00 0.00
-1.00 0.00 1.00 0.00 0.00 0.00
0.00 0.00 0.00 1.00 0.00 0.00
0.00 0.00 0.00 0.00 1.00 0.00
0.00 0.00 0.00 0.00 0.00 1.00
0.50 -1.00 0.50 0.00 0.50 0.00
0.50 -1.00 0.50 0.00 -0.50 0.00
-1.00 0.50 0.50 0.50 0.00 0.00
-1.00 0.50 0.50 -0.50 0.00 0.00
0.50 0.50 -1.00 0.00 0.00 0.50
0.50 0.50 -1.00 0.00 0.00 -0.50
0.50 0.00 -0.50 0.50 0.00 0.50
0.50 0.00 -0.50 -0.50 0.00 0.50
0.50 0.00 -0.50 0.50 0.00 -0.50
0.50 0.00 -0.50 -0.50 0.00 -0.50
0.00 -0.50 0.50 0.00 0.50 0.50
0.00 -0.50 0.50 0.00 -0.50 0.50
0.00 -0.50 0.50 0.00 0.50 -0.50
0.00 -0.50 0.50 0.00 -0.50 -0.50
-0.50 0.50 0.00 0.50 0.50 0.00
-0.50 0.50 0.00 -0.50 0.50 0.00
-0.50 0.50 0.00 0.50 -0.50 0.00
-0.50 0.50 0.00 -0.50 -0.50 0.00
0.00 0.00 0.00 0.50 0.50 -0.50
0.00 0.00 0.00 0.50 -0.50 0.50
0.00 0.00 0.00 -0.50 0.50 0.50
0.00 0.00 0.00 0.50 0.50 0.50
-1.00 1.00 0.00 0.00 0.00 0.00
0.00 -1.00 1.00 0.00 0.00 0.00
1.00 0.00 -1.00 0.00 0.00 0.00
0.00 0.00 0.00 -1.00 0.00 0.00
0.00 0.00 0.00 0.00 -1.00 0.00
0.00 0.00 0.00 0.00 0.00 -1.00
-0.50 1.00 -0.50 0.00 -0.50 0.00
-0.50 1.00 -0.50 0.00 0.50 0.00
1.00 -0.50 -0.50 -0.50 0.00 0.00
1.00 -0.50 -0.50 0.50 0.00 0.00
-0.50 -0.50 1.00 0.00 0.00 -0.50
-0.50 -0.50 1.00 0.00 0.00 0.50
-0.50 0.00 0.50 -0.50 0.00 -0.50
-0.50 0.00 0.50 0.50 0.00 -0.50
-0.50 0.00 0.50 -0.50 0.00 0.50
-0.50 0.00 0.50 0.50 0.00 0.50
0.00 0.50 -0.50 0.00 -0.50 -0.50
0.00 0.50 -0.50 0.00 0.50 -0.50
0.00 0.50 -0.50 0.00 -0.50 0.50
0.00 0.50 -0.50 0.00 0.50 0.50
0.50 -0.50 0.00 -0.50 -0.50 0.00
0.50 -0.50 0.00 0.50 -0.50 0.00
0.50 -0.50 0.00 -0.50 0.50 0.00
0.50 -0.50 0.00 0.50 0.50 0.00
0.00 0.00 0.00 -0.50 -0.50 0.50
0.00 0.00 0.00 -0.50 0.50 -0.50
0.00 0.00 0.00 0.50 -0.50 -0.50
0.00 0.00 0.00 -0.50 -0.50 -0.50
28 changes: 28 additions & 0 deletions BHfile_half.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
1.00 -1.00 0.00 0.00 0.00 0.00
0.00 1.00 -1.00 0.00 0.00 0.00
-1.00 0.00 1.00 0.00 0.00 0.00
0.00 0.00 0.00 1.00 0.00 0.00
0.00 0.00 0.00 0.00 1.00 0.00
0.00 0.00 0.00 0.00 0.00 1.00
0.50 -1.00 0.50 0.00 0.50 0.00
0.50 -1.00 0.50 0.00 -0.50 0.00
-1.00 0.50 0.50 0.50 0.00 0.00
-1.00 0.50 0.50 -0.50 0.00 0.00
0.50 0.50 -1.00 0.00 0.00 0.50
0.50 0.50 -1.00 0.00 0.00 -0.50
0.50 0.00 -0.50 0.50 0.00 0.50
0.50 0.00 -0.50 -0.50 0.00 0.50
0.50 0.00 -0.50 0.50 0.00 -0.50
0.50 0.00 -0.50 -0.50 0.00 -0.50
0.00 -0.50 0.50 0.00 0.50 0.50
0.00 -0.50 0.50 0.00 -0.50 0.50
0.00 -0.50 0.50 0.00 0.50 -0.50
0.00 -0.50 0.50 0.00 -0.50 -0.50
-0.50 0.50 0.00 0.50 0.50 0.00
-0.50 0.50 0.00 -0.50 0.50 0.00
-0.50 0.50 0.00 0.50 -0.50 0.00
-0.50 0.50 0.00 -0.50 -0.50 0.00
0.00 0.00 0.00 0.50 0.50 -0.50
0.00 0.00 0.00 0.50 -0.50 0.50
0.00 0.00 0.00 -0.50 0.50 0.50
0.00 0.00 0.00 0.50 0.50 0.50
28 changes: 28 additions & 0 deletions DC_matrix_function.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
%% This function creates the direction cosine matrix for one set of euler angles
% This is a common utility function used in many of the programs in other repositories

function [DC] = DC_matrix_function(phi1,phi,phi2)

c1 = cosd(phi1);
c2 = cosd(phi2);
c0 = cosd(phi);
s1 = sind(phi1);
s2 = sind(phi2);
s0 = sind(phi);

% Now calculating direction cosine matrix for conversion into the
% crystal reference frame
a11= c1*c2-s1*s2*c0;
a12= s1*c2+c1*s2*c0;
a13= s2*s0;
a21= -c1*s2-s1*c2*c0;
a22= -s1*s2+c1*c2*c0;
a23= c2*s0;
a31= s1*s0;
a32= -c1*s0;
a33= c0;

DC = [a11,a12,a13;a21,a22,a23;a31,a32,a33];

end

70 changes: 70 additions & 0 deletions ITC2euler.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
%% This program calculates the euler angles for the given hkl, uvw crystal orientation
clear
close

fprintf('This program calculates the euler angles \n for the given {hkl}<uvw> \n')
fprintf('PLEASE ENTER h k l u v w of the crystal\n')
O= input(''); % crystal_orientation array
XO = sscanf(O,'%d');


h=XO(1);
k=XO(2);
l=XO(3);
u=XO(4);
v=XO(5);
w=XO(6);
t1=k*w-l*v;
t2=l*u-h*w;
t3=h*v-k*u;

b=sqrt(u^2+v^2+w^2); % modulus of uvw vector
n=sqrt(h^2+k^2+l^2); % modulus of hkl vector
t=sqrt(t1^2+t2^2+t3^2); % modulus of transverse vector

%% alternative calculation
phi = acosd(1/n);

if (h^2 + k^2)<0.01
phi1=0;
phi2=phi1;
else
phi1= asind((w/b)*(n/sqrt(h^2 + k^2)));
phi2 = acosd(k/sqrt(h^2 + k^2));

end



%% Other method of calculating euler angles


% %% Calculation of direction cosines form hkl uvw and t1 t2 and t3
%
% a11= u/b;
% a12= t1/t;
% a13= h/n;
% a21= v/b;
% a22= t2/t;
% a23= k/n;
% a31= w/b;
% a32= t3/t;
% a33= l/n;
%
%
% % A = [a11,a12,a13;a21,a22,a23;a31,a32,a33];
%
% if a33>0.99 || a33<-0.99
% phi = 0;
% phi1 = (atand(a12/a11)); % As per formula given in Rollet L3, RHS is divided by 2 and phi2=phi1
% phi2=0; % but if phi is 0, phi1 and phi2 are same rotations so they add.
% else
% phi=acosd(a33);
% phi1=atan2d((a31/sin(phi)),(-a32/sin(phi)));
% phi2=atan2d((a13/sin(phi)),(a23/sin(phi)));
% end

%% output

fprintf('phi1 = "%f" \n phi= "%f" \n phi2= "%f" \n',phi1, phi, phi2)

76 changes: 76 additions & 0 deletions Poly_crystal_YL_3D.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
% clear;
% close;

%% Creating Bishop Hill stress state matrix from the text file named: BHfile.txt

B = fopen('BHfile.txt');
BH = textscan(B, ' %f %f %f %f %f %f');
fclose(B);

%% Reading the orientation file

prompt = 'The euler angle file name with .txt extension \n';
g_vectorfile = input(prompt);
g = fopen(g_vectorfile);
g_matrix = textscan(g, '%f %f %f');
l_g = length(g_matrix{1,1});

%% Reading the strain file

S = fopen('strains.txt');
strain = textscan(S, ' %f %f %f ');
l_s = length(strain{1,1});
fclose(S);
M = zeros(1,l_s);
ro = zeros(1,l_s);

for u=1:1:l_s
for v = 1:1:11
gamma12 = -1 + 0.2*(v-1);
e_ext=[strain{1,1}(u),gamma12,0;gamma12,strain{1,2}(u),0;0,0,strain{1,3}(u)];
Wmax= zeros(l_g,1);
for c=1:1:l_g
A = DC_matrix_function(g_matrix{1,1}(c),g_matrix{1,2}(c),g_matrix{1,3}(c));
[e]= transform_e_function(e_ext,A);
W= zeros(1,56);
BH_state = zeros(56,6);

for m=1:1:56
W(m)= -(BH{1,2}(m)*e(1,1))+ BH{1,1}(m)*e(2,2)+ BH{1,4}(m)*(e(2,3)+e(3,2))+BH{1,5}(m)*(e(1,3)+e(3,1))+BH{1,6}(m)*(e(1,2)+e(2,1));
BH_state(m,:) = [BH{1,1}(m),BH{1,2}(m),BH{1,3}(m),BH{1,4}(m),BH{1,5}(m),BH{1,6}(m)]; % [A,B,C,F,G,H]
end

Wmax(c)= max(abs(W));
end
M(u,v) = mean(Wmax)/e_ext(1,1);
ro(u,v) = -strain{1,2}(u)/strain{1,1}(u);
g(u,v) = gamma12/strain{1,1}(u);
end
end

%% Matix to store YL data points
azimuth = 0:5:360;
elevation = -90:5:90;
[az, el] = meshgrid(azimuth, elevation);
radius = 2*ones(size(az));

for u=1:1:l_s
for v=1:1:11
%aX+bY+cZ = M, a =1; b = -rho,c = 2gamma
b= -ro(u,v);
c= 2*g(u,v);
m = M(u,v);
r = abs(m./(cosd(az).*cosd(el)+ b.*cosd(el).*sind(az)+ c.*sind(el)));
radius = bsxfun(@min,r,radius);
end
end

%% Plotting the YL
[X,Y,Z] = sph2cart(az*(pi/180),el*(pi/180),radius);
surf(X,Y,Z)
xlim([-1.5 1.5]);
ylim([-1.5 1.5]);
zlim([-1.5 1.5]);
xlabel('SigmaXX');
ylabel('SigmaYY');
zlabel('TauXY');
113 changes: 113 additions & 0 deletions Poly_crystal_YL_3D_Quadrant_visulalization.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
%% This program plots the 3D quadrant section of the yield volume.
% It is good for visulatization. Basically it shows how the yield locaus
% is the inner envelope of the all planes passing the stress space

clear;
close;

%% Creating Bishop Hill stress state matrix from the text file named: BHfile.txt

B = fopen('BHfile.txt');
BH = textscan(B, ' %f %f %f %f %f %f');
fclose(B);

% %% ppt details
% f = 0.008;
% sigma_bar = 10000e6;
% tau = 88e6;

%% Reading the orientation file

prompt = 'The euler angle file name with .txt extension \n';
g_vectorfile = input(prompt);
g = fopen(g_vectorfile);
g_matrix = textscan(g, '%f %f %f');
l_g = length(g_matrix{1,1});

%% Reading the strain file

S = fopen('strains.txt');
strain = textscan(S, ' %f %f %f ');
l_s = length(strain{1,1});
fclose(S);
M = zeros(1,l_s);
ro = zeros(1,l_s);


for u=1:1:l_s
% for rho = -1:0.1:1
for v = 1:1:11
gamma12 = -1 + 0.2*(v-1);
e_ext=[strain{1,1}(u),gamma12,0;gamma12,strain{1,2}(u),0;0,0,strain{1,3}(u)];
% e_ext=[strain{1,1}(u),0,0;0,strain{1,2}(u),0;0,0,strain{1,3}(u)];
Wmax= zeros(l_g,1);
for c=1:1:l_g


A = DC_matrix_function(g_matrix{1,1}(c),g_matrix{1,2}(c),g_matrix{1,3}(c));
[e]= transform_e_function(e_ext,A);
W= zeros(1,56);
BH_state = zeros(56,6);

for m=1:1:56

W(m)= -(BH{1,2}(m)*e(1,1))+ BH{1,1}(m)*e(2,2)+ BH{1,4}(m)*(e(2,3)+e(3,2))+BH{1,5}(m)*(e(1,3)+e(3,1))+BH{1,6}(m)*(e(1,2)+e(2,1));
BH_state(m,:) = [BH{1,1}(m),BH{1,2}(m),BH{1,3}(m),BH{1,4}(m),BH{1,5}(m),BH{1,6}(m)]; % [A,B,C,F,G,H]
end

Wmax(c)= max(abs(W));

end
M(u,v) = mean(Wmax)/e_ext(1,1);
ro(u,v) = -strain{1,2}(u)/strain{1,1}(u);
g(u,v) = gamma12/strain{1,1}(u);
end
end



%% Plotting the YL
figure
for u=1:1:l_s
for v=1:1:11
%aX+bY+cZ = M, a =1; b = -rho,c = 2gamma

b= -ro(u,v);
c= 2*g(u,v);
% Y = -4:0.2:4;
% Z = -4:0.2:4;
[Y,Z] = meshgrid(0:.2:2);
X = M(u,v) - b*Y - c*Z;
surf(Y,Z,X,'LineWidth',1,'EdgeColor',[1 0 0]);
% surf(Y,Z,X);
hold on
end
end

% % % For negative M values
% for u=1:1:l_s
% for v=1:1:11
% %aX+bY+cZ = M, a =1; b = -rho,c = 2gamma
%
% b= -ro(u,v);
% c= 2*g(u,v);
% % Y = -4:0.2:4;
% % Z = -4:0.2:4;
% [Y,Z] = meshgrid(0:.2:2);
% X = -M(u,v) - b*Y - c*Z;
% % surf(Y,Z,X);
% surf(Y,Z,X,'LineWidth',1,'EdgeColor',[1 0 0]);
% hold on
% end
% end

xlim([-1.5 1.5]);
ylim([-1.5 1.5]);
zlim([-2 2]);
xlabel('SigmaXX');
ylabel('SigmaYY');
zlabel('TauXY');
% shading faceted;%interp %flat
hold off


Loading

0 comments on commit b048008

Please sign in to comment.