-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlaneStrain.m
200 lines (170 loc) · 6.32 KB
/
PlaneStrain.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
classdef PlaneStrain
properties (Access = public)
e % eccentricity of the deformed ellipse
end
%properties (Constant)
% r = 5; % a random choice for the radius of the circle
%end
properties (Access = protected)
r = 5;
vertices
tintersect
xlimit
ylimit
Rmatrix
end
properties(Dependent)
twophi % angle between k1 and k2, also k1' and k2'
alpha % angle betwee k1' and k1, or k2' and k2
end
methods
function obj = PlaneStrain(e)
obj.e = e; % eccentricity of the ellipse
end
function output = get.vertices(obj)
% obtains a and b from the eccentricity of the ellipse
syms a b
eqn1 = a*b==obj.r^2;
eqn2 = obj.e== sqrt(a^2 - b^2)./a;
soln = solve(eqn1,eqn2,a,b);
output = [double(soln.a(1)), double(soln.b(1))];
end
function soln = get.tintersect(obj)
% t is the parametrization of circle and ellpse
% identifies t= t0 where the circle and ellipse
% coincide
syms t
xcircle = obj.r*cos(t);
ycircle = obj.r*sin(t);
xellipse = obj.vertices(1)*cos(t);
yellipse = obj.vertices(2)*sin(t);
eqn = xcircle^2 + ycircle^2 == xellipse^2 + yellipse^2;
soln = double(solve(eqn,t));
end
function output = get.twophi(obj)
% obtains angle between conjugate undistorted planes
% ie. angle between k1 and k2 (also k1' and k2')
t = obj.tintersect();
m1 = sin(t(1)) ./ cos(t(1));
m2 = sin(t(2)) ./ cos(t(2));
output = abs(atand((m2-m1)./(1+m1*m2)));
end
function output = get.alpha(obj)
% obtains angle between k1 and k1' (type II twinning)
% or the angle between k2 and k2' (type I twinning)
output = 90 - obj.twophi;
end
function output = get.xlimit(obj)
% obtains x-axis limit for the figure
output = floor(obj.vertices(1)+1);
end
function output = get.ylimit(obj)
% obtains y-axis limit for the figure
output = floor(obj.r + 1);
end
function soln = get.Rmatrix(obj)
% obtains the Rotational matrix to coincide
% k1 and k1' (type I twinning)
% k2 and k2' (type II twinning)
theta = obj.alpha;
soln = [ ...
cosd(theta), sind(theta);...
-sind(theta), cosd(theta)];
end
function plotCircle(obj)
t = linspace(0,2*pi,200);
x = obj.r*cos(t);
y = obj.r*sin(t);
plot(x,y,'b','LineWidth',2)
axis equal
xlim([-obj.xlimit obj.xlimit])
ylim([-obj.ylimit obj.ylimit])
set(gca,'FontName','Times New Roman','FontSize',18)
ax = gca;
rtick = floor(-obj.r):2:ceil(obj.r);
ax.XTick = rtick;
ax.YTick = rtick;
ax.XTickLabel =[];
ax.YTickLabel = [];
grid on; box on;
clear t x y ax
end
function plotEllipse(obj)
t = linspace(0,2*pi,200);
x = obj.vertices(1).*cos(t);
y = obj.vertices(2).*sin(t);
plot(x,y,'r','LineWidth',2)
axis equal
xlim([-obj.xlimit obj.xlimit])
ylim([-obj.ylimit obj.ylimit])
set(gca,'FontName','Times New Roman','FontSize',18)
ax = gca;
ax.XTickLabel =[];
ax.YTickLabel = [];
grid on; box on;
clear t x y ax
end
function plotK(obj)
t = obj.tintersect;
m1 = sin(t(1))./cos(t(1));
m2 = sin(t(2))./cos(t(2));
syms x
fplot(x,m1*x,[-obj.ylimit obj.ylimit],'b:','LineWidth',2), hold on
fplot(x,m2*x,[-obj.ylimit obj.ylimit],'b:','LineWidth',2)
xlim([-obj.xlimit obj.xlimit])
ylim([-obj.ylimit obj.ylimit])
end
function plotKprime(obj)
t = obj.tintersect;
a = obj.vertices(1);
b = obj.vertices(2);
m1 = (b.*sin(t(1))) /(a.*cos(t(1)));
m2 = (b.*sin(t(2))) /(a.*cos(t(2)));
syms x
fplot(x,m1*x,[-obj.ylimit obj.ylimit],'r:','LineWidth',2), hold on
fplot(x,m2*x,[-obj.ylimit obj.ylimit],'r:','LineWidth',2)
xlim([-obj.xlimit obj.xlimit])
ylim([-obj.ylimit obj.ylimit])
end
function plotREllipse(obj)
t = linspace(0,2*pi,200);
a = obj.vertices(1);
b = obj.vertices(2);
x = a.*cos(t);
y = b.*sin(t);
rCoords = obj.Rmatrix*[x ; y];
xr = rCoords(1,:)';
yr = rCoords(2,:)';
plot(xr,yr,'k','LineWidth',2)
end
function plotRKprime(obj)
t = obj.tintersect;
a = obj.vertices(1);
b = obj.vertices(2);
x = a.*cos(t);
y = b.*sin(t);
rCoords = obj.Rmatrix*[x' ; y'];
xr = rCoords(1,:)';
yr = rCoords(2,:)';
m1 = yr(1)./xr(1);
m2 = yr(2)./xr(2);
syms x
fplot(x,m1*x,[-obj.ylimit obj.ylimit],'k:','LineWidth',2), hold on
fplot(x,m2*x,[-obj.ylimit obj.ylimit],'k:','LineWidth',2)
xlim([-obj.xlimit obj.xlimit])
ylim([-obj.ylimit obj.ylimit])
end
function plotAll(obj)
figure, hold on
obj.plotCircle();
obj.plotK();
pause
obj.plotEllipse();
obj.plotKprime();
pause
obj.plotREllipse();
obj.plotRKprime();
hold off
end
end
end