跳转至

BoxSlope

user_BoxSlope1.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
%make a box model, which will be put on a slope
clear;
fs.randSeed(1);%build random model
B=obj_Box;%build a box object
B.name='BoxSlope';
B.GPUstatus='auto';
B.ballR=0.035;
B.isClump=1;
B.distriRate=0.2;
B.sampleW=0.8;
B.sampleL=0.8;
B.sampleH=1.5;
%B.BexpandRate=4;
%B.PexpandRate=4;
B.type='GeneralSlope';
%B.type='TriaxialCompression';
B.setType();
B.buildInitialModel();%B.show();

B.setUIoutput();

d=B.d;%d.breakGroup('sample');d.breakGroup('lefPlaten');
%--------------end initial model------------
B.gravitySediment();
B.compactSample(2);%input is compaction time
mfs.reduceGravity(d,5);
%------------return and save result--------------
d.status.dispEnergy();%display the energy of the model
d.show('aR');

d.mo.setGPU('off');
d.clearData(1);%clear dependent data
d.recordCalHour('BoxSlope1Finish');
save(['TempModel/' B.name '1.mat'],'B','d');
save(['TempModel/' B.name '1R' num2str(B.ballR) '-distri' num2str(B.distriRate)  'aNum' num2str(d.aNum) '.mat']);
d.calculateData();%because data is clear, it will be re-calculated
user_BoxSlope2.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
%step1: packing the elements
clear;
load('TempModel/BoxSlope1.mat');
B.d.mo.setGPU('off');
packBallR=B.ballR;%record the ballR of the small box block
packBoxObj=B.d.group2Obj('sample');%make struct object from a group

%make a big box for the simulation
fs.randSeed(1);%random model seed, 1,2,3...
B=obj_Box;%declare a box object
B.name='BoxSlope';
%--------------initial model------------
B.GPUstatus='auto';%program will test the CPU and GPU speed, and choose the quicker one
B.ballR=packBallR;
B.isShear=0;
B.isClump=0;%if isClump=1, particles are composed of several balls
B.distriRate=0.2;%define distribution of ball radius, 
B.sampleW=6;%width, length, height, average radius
B.sampleL=4;%when L is zero, it is a 2-dimensional model
B.sampleH=3;
B.BexpandRate=2;%boundary is 4-ball wider than 
B.PexpandRate=0;
B.type='botPlaten';%add a top platen to compact model
B.isSample=0;
%B.type='TriaxialCompression';
B.setType();
B.buildInitialModel();
d=B.d;
d.mo.setGPU('off');%close GPU when modifing the model
d.showB=3;
d.delElement('topB');%remove top boundary
%d.show('aR');return;
slopeW=3;slopeL=B.sampleL;slopeH=B.ballR;
slope=mfs.denseModel(0.8,@mfs.makeBox,slopeW,slopeL,slopeH,B.ballR);%make a pile struct
slopeId=d.addElement(1,slope,'boundary');%add a slope boundary
d.addGroup('slope',slopeId);%add a new group
rotateX=max(d.aX(d.GROUP.slope));rotateZ=max(d.aZ(d.GROUP.slope));
d.rotateGroup('slope','XZ',-30,rotateX,0,rotateZ);%rotate the group along XZ plane
d.moveGroup('slope',-min(d.aX(d.GROUP.slope)),0,-min(d.aZ(d.GROUP.slope)));%move the slope

%import a regular packing box on the top right side of the model
smallBoxW=slopeW/4;
smallBox=mfs.denseModel(1.1,@mfs.makeBox,smallBoxW,smallBoxW,smallBoxW,B.ballR);%make a box struct
boxId=d.addElement(1,smallBox);
d.addGroup('box',boxId);%add a new group
d.moveGroup('box',B.sampleW*3/4,B.sampleL*1/4,B.sampleH*2/4);

%import the packed box (from step 1) on the top left side of the model
boxObjId=d.addElement(1,packBoxObj);%add regular model elements (not boundary)
d.addGroup('boxObj',boxObjId);%add a new group
d.setClump();%d.GROUP.groupId<-10 will be clump
d.moveGroup('boxObj',B.sampleW/8,B.sampleL*1/2,B.sampleH*2/4);
d.delElement('botPlaten');%remove bottom platen
d.show('aR');

%------------record data
d.mo.setGPU('off');
d.clearData(1);%clear dependent data in d
d.recordCalHour('BoxSlope2Finish');
save(['TempModel/' B.name '2.mat'],'B','d');
save(['TempModel/' B.name '2R' num2str(B.ballR) '-distri' num2str(B.distriRate)  'aNum' num2str(d.aNum) '.mat']);
d.calculateData();
user_BoxSlope3.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
clear;
load('TempModel/BoxSlope2.mat');
B.setUIoutput();
d=B.d;
d.calculateData();
d.mo.setGPU('off');
d.getModel();%d.setModel();%reset the initial status of the model
d.status=modelStatus(d);%initialize model status, which records running information

d.mo.isHeat=1;%calculate heat in the model
visRate=0.0001;
d.mo.mVis=d.mo.mVis*visRate;%use low viscosity for dynamic simulation
gpuStatus=d.mo.setGPU('auto');
d.setStandarddT();

totalCircle=20;
d.tic(totalCircle);
%.mat files will be saved in the folder data/step
fName=['data/step/' B.name num2str(B.ballR) '-' num2str(B.distriRate) 'loopNum'];
save([fName '0.mat']);%return;
for i=1:totalCircle
    d.mo.setGPU(gpuStatus);
    d.balance(50,d.SET.packNum);
    d.clearData(1);
    save([fName num2str(i) '.mat']);
    d.calculateData();
    d.toc();%show the note of time
end

d.mo.setGPU('off');
d.clearData(1);
d.recordCalHour('BoxSlope3Finish');
save(['TempModel/' B.name '3.mat'],'B','d');
save(['TempModel/' B.name '3R' num2str(B.ballR) '-distri' num2str(B.distriRate)  'aNum' num2str(d.aNum) '.mat']);
d.calculateData();