-
Notifications
You must be signed in to change notification settings - Fork 0
/
For_A2dA1_or_A2_back.m
executable file
·292 lines (239 loc) · 8.37 KB
/
For_A2dA1_or_A2_back.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
%cd G:\orange_backup % any dir
%cd /Volumes/GROUP_BLACK/orange_backup/
clear all
%Gi=[0.05 0.1 0.2 0.3 0.4 0.5 1 1.25 3]; %All the G
Gi=[0.2 0.3 0.4 ];
for i3=Gi
close all
clearvars -except i3
%cd '/Volumes/GROUP_BLACK/orange_backup/'
cd E:\Independent_23_Dec
gstr=num2str(i3,['%10.1','f']);
list0=dir(['g',gstr,'*m2.5*']);
%A1din = input('input: digits after decimal point for A_1 legend? (default is 3 digits)','s');
%if size(A1din)==0;
A1din= '3';
%end
maximumA1=inf;
A2switch=false; % A2=true or A2dA1=false
mrswitch=0; %mass ratio is a variable or not
n1=1;%starting number of files
disp(['starting number= ',num2str(n1)])
if A2switch
disp('drawing A2 graph')
else
disp('drawing A2/A1 graph')
end
if mrswitch
disp('dealing with mass ratios')
else
disp('NOT dealing with mass ratios')
end
n0=length(list0);
s=0;sp=0;
yaxismax=0;xaxismax=0;
yaxismin=0;xaxismin=0;
aryaxismax=0;arxaxismax=0;
aryaxismin=0;arxaxismin=0;
countl=0;
clear gamall aryaxismax aryaxismin arxaxismax arxaxismin
for j=n1:n0
cd (list0(j).name)
list=dir('0*');
n=length(list);
cd ('../')
str=list0(j).name;
str(str=='r')=[' '];
str(str=='u')=[];
str(str=='n')=[];
str(str=='_')=[];
str(str=='z')=[];
str(str=='l')=[' '];
str1=str;
str(str=='g')=' ';
str(str=='a')=' ';
str(str=='m')=' ';
gam=str2num(str);
gamall(1:length(gam),j)=gam;
A1=gam(2);
if A1>maximumA1
continue
end
countl=countl+1;
%CM = lines(10);
%{
for i=1:1
dirnamef=[list0(j).name,'/',list(i).name,'/'];
%v01=load([dirname,'VIV01.DAT']);
v01=load([dirnamef,'VIV01.DAT']);
disp(dirnamef);
%tn=length(v01)/5;%Number of lines plotted
s=s+1;
figure(s)
%plot(v01(1:tn,1),v01(1:tn,4),'color','b') % y displacement of cylinder 1 (forced)
%hold on;
plot(v01(:,1),v01(:,4),'color','b') % y displacement of cylinder 2 (free)
title([list0(j).name,' f1/fn2=',list(i).name,' VIV01'])
xlabel('t*fn2');
ylabel('X/D');
tiname=[list0(j).name,'_',list(i).name,'_VIV01'];
cd ('plotting')
print('-dpng','-r600',['Plotting_',tiname,'.png']);
cd ('../')
end
%}
% if not(A1==0.1)
% continue
% end
for i=1:n
dirnamef=[list0(j).name,'/',list(i).name,'/'];
disp(dirnamef);
f(i)=str2double(list(i).name);
% if A1==0.1 && f(i)==0.4
% stop
% else
% continue
% end
period=1/str2double(list(i).name); %
v02=load([dirnamef,'VIV02.DAT']);
v02=unique(v02,'rows');
t=v02(:,1);
y=v02(:,4);
period1n=0;
while true %count point number in one period
period1n=period1n+1;
if t(period1n)>=period
break
end
end
period1n=period1n*1;% number of periods for A=(max-min)/2
tn=length(t);
nperiod=floor(tn/(period1n));
for i1=1:nperiod %
tstartn=(i1-1)*period1n+1;
tendn=i1*period1n;
ymax(i1)=max(y(tstartn:tendn));
ymin(i1)=min(y(tstartn:tendn));
yamp(i1)=(ymax(i1)-ymin(i1))/2;
end
yampds=sort(yamp,'descend');
yampn=floor(1/3*(length(yampds)));% N of 1/3 values
%average of 1/3 value in the middle of yampds
%s=s+1;
%figure(s)
%plot(yampds(yampn:2*yampn))
%plot(yamp);
if gam(1)<3
A2(i)=max(yamp(nperiod-3:nperiod));%based on assumption fo f1=f2
%and vibration becomes
%steady after a few periods
else
A2(i)=mean(yampds(yampn:2*yampn));
end
%A2(i)=yampds(1);
if A2switch==false
A2dA1(i)=A2(i)/A1;
end
clear ymax ymin yamp yampds t v02 y;
end
if A2switch==false
if max(A2dA1)>yaxismax
[aryaxismax(j),peaki]=max(A2dA1);
aryaxismin(j)=min(A2dA1((peaki-1):(peaki+1)));
arxaxismax(j)=f(peaki+1);
arxaxismin(j)=f(peaki-1)-(f(peaki+1)-f(peaki-1));
end
else
if max(A2)>yaxismax
[aryaxismax(j),peaki]=max(A2);
aryaxismin(j)=min(A2((peaki-1):(peaki+1)));
arxaxismax(j)=f(peaki+1);
arxaxismin(j)=f(peaki-1)-(f(peaki+1)-f(peaki-1));
end
end
%v02=load([dirnamef,'VIV02.DAT']);
% %tn=length(v02)/5;%Number of lines plotted
%s=s+1;
%figure(s)
%plot(v01(1:tn,1),v01(1:tn,4),'color','b') % y displacement of cylinder 1 (forced)
%hold on;
%plot(v02(:,1),v02(:,4),'color','r') % y displacement of cylinder 2 (free)
sp=sp+1;
if A2switch
h(sp)=plot(f,A2);
else
h(sp)=plot(f,A2dA1);
end
hold on
if mrswitch
%legendInfo{j} = ['G=',num2str(gamall(1,j),4),' A_1=',num2str(gamall(2,j),['%10.',A1din,'f']),' m^*=',num2str(gamall(3,j),['%10.',A1din,'f'])];
legendInfo{j} = ['m^*=',num2str(gamall(3,j),['%10.1f'])];
else
legendInfo{j} = ['G=',num2str(gamall(1,j),4),' A_1=',num2str(gamall(2,j),['%10.',A1din,'f']), 'm^*=',num2str(gamall(3,j),['%10.1f'])];%specify digit of legend number
end
end
mkdir(['plotting/Amplitude_Frequency/'])
cd ('plotting/Amplitude_Frequency/')
yaxismax=max(aryaxismax);
yaxismin=min(aryaxismin);
xaxismax=max(arxaxismax);
xaxismin=min(arxaxismin);
gmin=num2str(min(gamall(1,:)));gmax=num2str(max(gamall(1,:)));
a1min=num2str(min(gamall(2,:)));a1max=num2str(max(gamall(2,:)));
mrmin=num2str(min(gamall(3,:)));mrmax=num2str(max(gamall(3,:)));
%legend(['G=',num2str(gamall(1,1)),' A_1=',num2str(gamall(2,1))],'G=3.0 A_1=1.0','G=3.0 A_1=1.5','G=3.0 A_1=2.0','Location','northeast')
%title(['G=',num2str(gam(1)),' A1=',num2str(gam(2)),' m*=',num2str(gam(3))])
legend(legendInfo)
xlabel('$f_1$','Interpreter','LaTex','FontSize',20);
if A2switch
ylabel('$A_2$','Interpreter','LaTex','FontSize',20);
else
ylabel('$A_2/A_1$','Interpreter','LaTex','FontSize',20);
end
set(gca,'XTick',0:0.2:2.5);
grid on
%cd ('../')
%cd ('../')
%set(h,'Color','Black');
markerset={'o';'+';'*';'x';'s';'d';'^'};
set(h(1:countl),{'Marker'},markerset(1:countl));
set(h,'Color','Black');
%set(h,{'linestyle'},{'-';'-.'});
[hleg1, hobj1] = legend;
set(hleg1,'position',[0.6 0.5 0.2 0.3])
set(hleg1,'FontSize',15)
%% figure1
tiname=['G=',gmin,'-',gmax,'_A1=',a1min,'-',a1max,'_mr=',mrmin,'-',mrmax];
if A2switch
print('-dpng','-r600',[tiname,'_A2_overall','.png']);
else
print('-dpng','-r600',[tiname,'_A2dA1_overall','.png']);
end
%% figure 2
set(hleg1,'position',[0.2 0.5 0.2 0.3])
set(hleg1,'FontSize',15)
set(gca,'XTick',0:0.1:2.5);
%axis(gca, [xmin xmax ymin ymax])
axis(gca, [0.3 1.0 0 (yaxismax+0.1)]);
%print('-dpng','-r600',[tiname,'_A2dA1','.png']);
%tiname=['G=',gmin,'-',gmax,'_A1=',a1min,'-',a1max,'_mr_max=',mrmin,'-',mrmax];
if A2switch
print('-dpng','-r600',[tiname,'_A2_zoom','.png']);
else
print('-dpng','-r600',[tiname,'_A2dA1_zoom','.png']);
end
%% figure 3
set(gca,'XTick',0:0.025:2.5);
%zoom on
%axis(gca, [xmin xmax ymin ymax])
xmargin=(xaxismax-xaxismin)/10;
ymargin=(yaxismax-yaxismin)/10;
axis(gca, [xaxismin-xmargin xaxismax+xmargin yaxismin-ymargin yaxismax+ymargin]);
%tiname=['G=',gmin,'-',gmax,'_A1=',a1min,'-',a1max,'_mr_max=',mrmin,'-',mrmax];
if A2switch
print('-dpng','-r600',[tiname,'_A2_details','.png']);
else
print('-dpng','-r600',[tiname,'_A2dA1_details','.png']);
end
%%
end