-
Notifications
You must be signed in to change notification settings - Fork 0
/
e_xtal_euler.m
62 lines (43 loc) · 2.53 KB
/
e_xtal_euler.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%% This program transforms the external strain tensor to the crystal reference frame.
% The x direction of the external strain is taken along RD, TD and 45 from RD.
% The crystal orientation is asked in the euler angle notation in a .txt file format
clear;
close;
%% Reading the external strain tensor
fprintf('Please enter strain condition \n For plane strain input 1 \n For axisymmetric strain inpur 2 \n For any other strain condition enter 3 \n')
y = input('');
switch y
case 1
e_ext= [1,0,0;0,-1,0;0,0,0];
case 2
e_ext= [1,0,0;0,-0.5,0;0,0,-0.5];
%e_ext= [-0.5,0,0;0,1,0;0,0,-0.5];
case 3
prompt = 'Please enter the external strain matrix : e11 e12 e13 e21 e22 e23 e31 e32 e33\n';
e_ext = input(prompt);
otherwise
warning('Unexpected choice entered. strain tensor can not be calculated.');
break;
end
%% Reading the orientation data file
prompt = 'The euler angle file name with .txt extension \n';
g_vectorfile = input(prompt); %% this stores the file name in a string array variable g_vectorfile. This file is an array of orientation vectors, each vector has three euler angles as components.
g = fopen(g_vectorfile); %% g stores the link to the file g_vectorfile
g_matrix_RD = textscan(g, '%f %f %f'); %% g_matrix stores the file (g_vectorfile) data in a matrix
fclose(g);
A = DC_matrix_function(g_matrix_RD{1,1}(1),g_matrix_RD{1,2}(1),g_matrix_RD{1,3}(1));
[e]= transform_e_function(e_ext,A);
disp(e)
g_matrix_TD = g_matrix_RD;
g_matrix_TD{1,3}(:) = g_matrix_TD{1,3}(:)-90; %g_matrix_TD{1,1}(:)+90; in place of g_matrix_TD{1,3}(:)+90;
A = DC_matrix_function(g_matrix_TD{1,1}(1),g_matrix_TD{1,2}(1),g_matrix_TD{1,3}(1));
[e]= transform_e_function(e_ext,A);
disp(e)
g_matrix_45RD = g_matrix_RD;
g_matrix_45RD{1,3}(:) = g_matrix_45RD{1,3}(:)-45;
A = DC_matrix_function(g_matrix_45RD{1,1}(1),g_matrix_45RD{1,2}(1),g_matrix_45RD{1,3}(1));
[e]= transform_e_function(e_ext,A);
disp(e)
%% This program was created to calculate the strain tensor as resolved in the crystal reference frame. When we give certain external strain, we already fix the x,y and z axis.
%We can change the axes either by swaping rows of the strain matrix or by
%rotating the phi1 euler angle. Here, both approaches can be taken.