-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_darwin_v12_b1_for_1period_anime.m
executable file
·433 lines (362 loc) · 10.2 KB
/
input_darwin_v12_b1_for_1period_anime.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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
%makeinput_v11_auto_copyall_SBATCH_remesh_input_mass_ratio
%clc
clear all
close all
fclose all;
cd('/Users/zhonglulin/Documents/OneDrive - University Of Cambridge/OneDrive/PhDWorks/VIV')
%cd ('C:\running_tasks\')
%folderlist=dir('*r83');
copyall_or_not=1;
ttperiods=1;%maximum periods in each run
odfis=2;% Output data frequency in steps
%account='SOGA';% zl352
account='LIANG-SL3';%dl359 xz328 fy hj
ristart=1169;%;
ri=ristart-1;
s=0;
%{
if1=[
00.050
00.100
00.150
00.200
00.250
00.300
00.350
00.375
00.400
00.425
00.450
00.500
00.550
00.600
00.650
00.700
00.750
00.800
00.825
00.850
00.900
00.950
01.000
01.100
01.200
01.300
01.400
01.600
01.800
02.000
02.400]';
%}
%if1=[0.379 0.757];
if1=[
2.5
3
3.5
4
4.5
5
5.5
6
6.5
7
7.5
8
8.5
9
9.5
10
10.5
11
11.5
12
]';
re=100;% Reynolds Number
for gi=[0.4]
for ai=[
%0.005 0.025 0.05 0.075 0.1
0.075
]
for mi=[
%1.50 1.7 2.0 2.2 2.5
1.5
]
ri=ri+1;
temp1=['g',num2str(gi,'%.1f'),'a',num2str(ai,'%.3f'), ...
'm',num2str(mi,'%.1f'),'r',num2str(ri)];
mkdir(temp1)
disp(temp1)
s=s+1;
txt{s}=['cd ./*r',num2str(ri),'; chmod u+x suball.com; ./suball.com; cd ../'];
end
end
end
%% write submit.com file
fid = fopen(['./',num2str(ristart),'_to_',num2str(ri),'_subauto_hpc'], 'w');
for ii = 1:length(txt)
fprintf(fid,'%s\n', txt{ii});
end
%%
start_task_num=ristart;
end_task_num=ri;%117+18-1;
nn=end_task_num-start_task_num+1;
for ii=1:nn
task_num=start_task_num+ii-1;
folderlist=dir(['*r',num2str(task_num)]);
foldername=folderlist.name;
disp(foldername)
walltime='12:00:00'; %Wall clock time
codename='7';
%Global Calculation parameters
%odfis=1;% Output data frequency in steps
misfve=12000;% Maximum iteration step for velocity equation
misfppe=10000;% Maximum iteration step for Pressure Possion equation
NITRB= '350'; % MAXIMUM ITERATION STEP FOR MESH UPDATE EUQATION
AERB = '1.D-15'; % ALLOW ERROR FOR SOLVING THE MESH UPDATE EQUATION
% NITRB= '350'; By convention
% AERB = '1.D-15'; By convention
%mkdir (foldername)
cd (foldername)
mkdir('00')
rmdir('0*','s');
str=foldername;
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);
%% INPUT PARAMETERs 1
g=gam(1);%G/D
a1=gam(2);%A1
m=gam(3);%m*
%Renolds Number
ftspara=0.00025;%normally 0.00025 for interaction of two cylinders
taskstr=['r',num2str(gam(4))] ;%task number
%% Adjust Title Format
gstr=num2str(g,'%.2f');% ,'%.3f'
a1str=num2str(a1,'%.3f');% ,'%.3f'
mstr=num2str(m);%,'%.1f'
protodir=['/Users/zhonglulin/Documents/OneDrive - University Of Cambridge/OneDrive/PhDWorks/VIV/Chosen_mesh_19_Dec/g',num2str(g,'%.1f')];
%% =============================FOLDERs====================== f1s to be run
%---
i=0;
j=0;
s=0;
clear txt
%% j=if1
for j=if1
%for j=[0.81:0.01:0.99]
%if j==0.85||j==0.90||j==0.95
%continue
%end
name=['0',num2str(j,'%05.3f'),''];
mkdir(name)
%end
s=s+1;
txt{s}=['cd ./',name,'; qsub slurm_submit.txt; cd ../'];
end
%% write suball.com file
fid = fopen(['./suball.com'], 'w');
for ii = 1:length(txt)
fprintf(fid,'%s\n', txt{ii});
end
disp('folder created')
%%
%% =============================COPY1======================
if copyall_or_not
disp('copying from proto...')
origindir=pwd;
cd (protodir)
list1=dir('*.TXT');
n1=length(list1);
cd (origindir)
list0=dir('0*');
n0=length(list0);
%%
%n0=3;%for test
%%
for j=1:n0
for i=1:n1
origin=[protodir,'/',list1(i).name];
destin=['./',list0(j).name];
copyfile(origin,destin)
end
end
disp('copy done')
%% =============================COPY2======================
%%
%n0=3;%for test
%%
% for j=1:n0
% for i=1:n1
% origin=['./proto/',list1(i).name];
% destin=['./',list0(j).name];
% copyfile(origin,destin)
% end
% end
% disp('copy done')
%% ===========================
end % end of copy
%% =============================EDIT======================
%clear all
%close all
list0=dir('0*');
n0=length(list0);
%n0=3;%test f=0.05
%%
disp(['alter value for ','G/D=',gstr,', A1=',a1str,', m*=',mstr])
for j=1:n0
%% Calculated INPUT PARAMETERs
%disp(['alter value for ','G/D=',num2str(g),', A1=',num2str(a1),', m*=',num2str(m), ...,
% ' f1=',list0(j).name])
f1=str2num(list0(j).name);
visc=2*3.14159265*f1*a1/re; %viscosity
fts=ftspara/(2*3.14159265*a1*f1); %flow time step
tts=floor(ttperiods/f1/fts);% total time step
f1str=list0(j).name;
taskname=['Z',f1str,taskstr];
%taskdirdarwin=['cd /home/zl352/VIVHPC/','g',gstr,'a',a1str,'m',mstr,'zl_',taskstr,'_code',codename,'/',list0(j).name];
%taskdirorange=['cd /projects/y73/dongfang/','g',gstr,'a',a1str,'m',mstr,'zl_',taskstr,'_code',codename,'/',list0(j).name];
%taskdirdarwin=['cd ~/scratch/','g',gstr,'a',a1str,'m',mstr,'zl_',taskstr,'/',list0(j).name];
taskdirdarwin='cd $workdir';
taskdirorange=['cd /projects/y73/dongfang/','g',gstr,'a',a1str,'m',mstr,'zl_',taskstr,'/',list0(j).name];
%% Reading and edit txt
%
origindir=pwd;
cd (protodir)
fid = fopen('VIV_PARA.TXT','r');
i = 1;
tline = fgetl(fid);
txtv{i} = tline;
while ischar(tline)
i = i+1;
tline = fgetl(fid);
txtv{i} = tline;
end
fclose(fid);
% Change cell
txtv{3} = [strrep(sprintf('%d',a1),'e','D'),' -> amplitude of the forced vibration'];
txtv{4} = [strrep(sprintf('%d',f1),'e','D'),' -> frequency (1/period) of the forced vibration'];
txtv{9} = [mstr,' -> mass ratio'];
%
%%
fid = fopen('CALCULATION_PARA.TXT','r');
i = 1;
tline = fgetl(fid);
txtc{i} = tline;
while ischar(tline)
i = i+1;
tline = fgetl(fid);
txtc{i} = tline;
end
fclose(fid);
% Change cell
txtc{1} = [strrep(sprintf('%d',visc),'e','D'),' --> viscosity'];
txtc{2} = [strrep(sprintf('%d',fts),'e','D'),' --> FLOW TIME STEP'];
txtc{4} = [num2str(tts),' --> Total time steps'];
txtc{5} = [num2str(odfis),' --> Output data frequency in steps'];
txtc{7} = [num2str(misfve),' --> Maximum iteration step for velocity equation'];
txtc{10} = [num2str(misfppe),' --> Maximum iteration step for Pressure Possion equation'];
txtc{14} = [NITRB,' --> MAXIMUM ITERATION STEP FOR MESH UPDATE EUQATION '];
txtc{15} = [AERB,' --> ALLOW ERROR FOR SOLVING THE MESH UPDATE EQUATION'];
%% SLURM
fid = fopen('slurm_submit.txt','r');
i = 1;
tline = fgetl(fid);
txts{i} = tline;
while ischar(tline)
i = i+1;
tline = fgetl(fid);
txts{i} = tline;
end
fclose(fid);
% Change cell
txts{13} = ['#SBATCH -J ',taskname];
txts{15} = ['#SBATCH -A ',account];
txts{21} = ['#!SBATCH --mem=200'];
txts{24} = ['#SBATCH --time=',walltime];
txts{25} = ['#SBATCH --mail-user=zl352'];
txts{26} = ['#SBATCH --mail-type=END'];
%txts{63} = ['application="/home/zl352/VIVHPC/code',codename,'/viv"']; %code dir
txts{63} = ['application="~/scratch/code',codename,'/viv"']; %code dir
txts{107} = taskdirdarwin; %running dir
%txts{107} = 'cd $workdir';
%% PBS
fid = fopen('pbs.sh','r');
i = 1;
tline = fgetl(fid);
txtp{i} = tline;
while ischar(tline)
i = i+1;
tline = fgetl(fid);
txtp{i} = tline;
end
fclose(fid);
% Change cell
txtp{3} = ['#PBS -l walltime=',walltime];
txtp{6} = ['#PBS -N ',taskname];
txtp{7} = taskdirorange;
txtp{8} = ['/projects/y73/dongfang/code',codename,'/viv > test.e'];
%% write txt
cd (origindir)
cd (list0(j).name)
fid = fopen('VIV_PARA.TXT', 'w');
for i = 1:numel(txtv)
if txtv{i+1} == -1
fprintf(fid,'%s', txtv{i});
break
else
fprintf(fid,'%s\n', txtv{i});
end
end
fid = fopen('CALCULATION_PARA.TXT', 'w');
for i = 1:numel(txtc)
if txtc{i+1} == -1
fprintf(fid,'%s', txtc{i});
break
else
fprintf(fid,'%s\n', txtc{i});
end
end
fid = fopen('slurm_submit.txt', 'w');
for i = 1:numel(txts)
if txts{i+1} == -1
fprintf(fid,'%s', txts{i});
break
else
fprintf(fid,'%s\n', txts{i});
end
end
fid = fopen('pbs.sh', 'w');
for i = 1:numel(txtp)
if txtp{i+1} == -1
fprintf(fid,'%s', txtp{i});
break
else
fprintf(fid,'%s\n', txtp{i});
end
end
%%
fclose(fid);
cd ('../')
end
disp('====================================')
disp(pwd)
disp(['NOTE! acount: ',account])
disp(['NOTE! Output step ',num2str(odfis)])
disp(['NOTE! codename= ',codename])
disp(['NOTE! flow_time_step_para= ',num2str(ftspara)])
disp(['NOTE! taskdir_darwin= ',taskdirdarwin])
%disp(['NOTE! taskdir_orange= ',taskdirorange])
disp(['NOTE! walltime= ', walltime])
disp(['NOTE! Reynolds number= ', num2str(re)])
disp('====================================')
fclose all;
cd ('../')
end