-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_Batch_free_cylinder_input_darwin_v16_Re_varies.m
executable file
·533 lines (455 loc) · 13.6 KB
/
Test_Batch_free_cylinder_input_darwin_v16_Re_varies.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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
%% To use the same config as "Flow mediated interactions between two cylinders at finite Re numbers"
%% in order to validate the numerical method.
%makeinput_v11_auto_copyall_SBATCH_remesh_input_mass_ratio
%this version can deal with damping ratio
%clc
clear all
close all
fclose all;
cd('/Users/zhonglulin/Documents/OneDrive - University Of Cambridge/OneDrive/PhDWorks/VIV')
mkdir('Batch_free_cylinder')
cd('Batch_free_cylinder')
%cd ('C:\running_tasks\')
%folderlist=dir('*r83');
% damp f
% Gtarget=0.4;
% A1target=0.025;
% mtarget=1.5;
% damptarget=[
% 0.00
% 0.05
% 0.10
% 0.20
% 0.40
% ];
% f1target=[ % corresponding each damp
% 0.78
% 0.78
% 0.78
% 0.795
% 0.9
% ];
copyall_or_not=1;
ttperiods=500;
account='SOGA'; % zl352
codename='8'; %to remove the spring (restoring force)
%account='LIANG-SL3';%dl359 xz328 fy hj
ristart=9316;%;
disp(['Starting from ',num2str(ristart)])
%disp(' Are you ready?')
%pause
ri=ristart-1;
s=0;
%%{
if1=[
1
]';
%}
%if1=[0.379 0.757];
%if1=[2.8:0.4:10];
% if1=[
% 0.35
% 0.36
% 0.37
% 0.38
% 0.39
% 0.4
% 0.41
% 0.42
% 0.43
% 0.44
% 0.45
%
% 0.705
% 0.71
% 0.715
% 0.72
% 0.725
% 0.73
% 0.735
% 0.74
% 0.745
% 00.750
% 0.755
% 0.76
% 0.765
% 0.77
% 0.775
% 0.78
% 0.785
% 0.79
% 0.795
% ]';
%re=100;% Reynolds Number
scal=0;
for sn=1:6
scal=scal+1;
if scal==1
ristart2=ristart;
else
ristart2=ri+1;
end
if sn==1 %A1 varies
gii=[1];
reii=[10 25 39 55 70];
aii=1;
mii=[1.000001];
dampii=[0];% not used for free cylinder cases
end
if sn==2 %A1 varies
gii=[1.5];
reii=[10 20 27 40 50];
aii=1;
mii=[1.000001];
dampii=[0];% not used for free cylinder cases
end
if sn==3 %A1 varies
gii=[2];
reii=[10 15 22 30 40];
aii=1;
mii=[1.000001];
dampii=[0];% not used for free cylinder cases
end
if sn==4 %A1 varies
gii=[3];
reii=[10 15 19 25 30]; %50 80 100 120 150 180 200];
aii=1;
mii=[1.00000];
dampii=[0];% not used for free cylinder cases
end
if sn==5 %A1 varies
gii=[3.5];
reii=[10 15 18 25 30];
aii=1;
mii=[1.000001];
dampii=[0];% not used for free cylinder cases
end
if sn==6 %A1 varies
gii=[4];
reii=[10 15 18 25 30];
aii=1;
mii=[1.000001];
dampii=[0];% not used for free cylinder cases
end
if sn==7 %A1 varies
gii=[2.5];
reii=[10 15 18 25 30];
aii=1;
mii=[1.000001];
dampii=[0];% not used for free cylinder cases
end
if sn==8 %A1 varies
gii=[2.5];
reii=[5 10 18 19];
aii=1;
mii=[1];
dampii=[0];% not used for free cylinder cases
end
clear txt
% for gi=gii
%for ai=aii
for gi=gii
% if length(aii)~=length(gii)
% stop%
% end
%gi=gii(iag);
%aii=[gi/2,gi/3,gi/4,gi/5];
for ai=aii
%ai=aii(iag);
for mi=mii
for dampi=dampii
for rei=reii
ri=ri+1;
temp1=['g',num2str(gi,'%.1f'),...
'a',num2str(ai,'%.3f'), ...
'm',num2str(mi,'%.1f'),...
'd',num2str(dampi,'%.2f'),...
'e',num2str(rei,'%.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
end
end
disp('===1st level folders created===')
%% write submit.com file
fid = fopen(['./',num2str(ristart2),'_to_',num2str(ri),'_subauto_hpc'], 'w');
for ii = 1:length(txt)
fprintf(fid,'%s\n', txt{ii});
end
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
%Global Calculation parameters
odfis=2000;% Output data frequency in steps
misfve=12000;% Maximum iteration step for velocity equation
misfppe=10000;% Maximum iteration step for Pressure Possion equation
NITRB= '360'; % 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')=' ';
str(str=='d')=' ';
str(str=='e')=' ';
gam=str2num(str);
%% INPUT PARAMETERs 1
g=gam(1);%G/D
a1=gam(2);%A1
m=gam(3);%m*
damp=gam(4);%damp ratio
re=gam(5); %Renolds Number
ftspara=0.00025;%normally 0.00025 for interaction of two cylinders
% 0.00075 courant number = 0.76
taskstr=['r',num2str(gam(end))] ;%task number
%% Adjust Title Format
gstr=num2str(g,'%.2f');% ,'%.3f'
a1str=num2str(a1,'%.3f');% ,'%.3f'
mstr=num2str(m);%,'%.1f'
dampstr=num2str(damp,'%.2f');
restr=num2str(re,'%.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,' damp=',dampstr,' re=',restr])
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=['f',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=['Not in use: 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'];
txtv{11} = [dampstr,' -> damping factor of cylinder 2'];
%
%%
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{66} = ['options=" | tee -a test0.e "']; %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('====================================')
fclose all;
cd ('../')
end