跳转至

HydraulicBlock

user_L3HydraulicBlock1.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
%step1: packing the elements
clear;
fs.randSeed(1);%random model seed, 1,2,3...
B=obj_Box;%declare a box object
B.name='HydraulicBlock';
%--------------initial model------------
B.GPUstatus='auto';%program will test the CPU and GPU speed, and choose the quicker one
B.ballR=0.001;
B.isShear=0;
B.isClump=0;%if isClump=1, particles are composed of several balls
B.distriRate=0.25;%define distribution of ball radius, 
B.SET.border=0.01;
B.SET.sampleW0=0.075;
B.SET.sampleH0=0.15;
B.sampleW=B.SET.sampleW0+B.SET.border*2;%width, length, height, average radius
B.sampleL=0;%when L is zero, it is a 2-dimensional model
B.sampleH=B.SET.sampleH0*1.15;
B.boundaryRrate=0.999999;
B.BexpandRate=2;%boundary is 4-ball wider than 
B.PexpandRate=1;
B.isSample=1;
B.type='TriaxialCompression';
B.setType();
B.buildInitialModel();%B.show();
d=B.d;%d.breakGroup('sample');d.breakGroup('lefPlaten');
%you may change the size distribution of elements here, e.g. d.mo.aR=d.aR*0.95;
d.showB=1;
%--------------end initial model------------

%----------remove overlap platen elements
d.mo.setGPU('off');
delId=[d.GROUP.topPlaten(end-1:end);d.GROUP.botPlaten(end-1:end)];
d.delElement(delId);
%----------end remove overlap platen elements

%---------remove elements around the sample %this part is new code @@@@@@@
delFilter=d.mo.aX<B.SET.border|d.mo.aX>B.SET.border+B.SET.sampleW0;
sampleFilter=false(d.aNum,1);
sampleFilter(d.GROUP.sample)=true;
delId=find(delFilter&sampleFilter);
d.delElement(delId);
d.moveGroup('lefPlaten',B.SET.border,0,0);
d.moveGroup('rigPlaten',-B.SET.border,0,0);
lrPlatenId=[d.GROUP.lefPlaten;d.GROUP.rigPlaten];
d.addFixId('X',lrPlatenId);
d.addFixId('Y',lrPlatenId);
d.addFixId('Z',lrPlatenId);
%---------end remove elements around the sample

d.mo.zeroBalance();
d.mo.setShear('off');%because d.mo.isShear will be reset to 1 in d.delElement
%---------- gravity sedimentation
B.gravitySediment(1);%you may use B.gravitySediment(10); to increase sedimentation time (10)
B.compactSample(5);%input is compaction time
mfs.reduceGravity(d,5);

%------------return and save result--------------
d.status.dispEnergy();%display the energy of the model
d.Rrate=1;
d.mo.setGPU('off');
d.clearData(1);%clear dependent data
d.recordCalHour('Step1Finish');
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();
d.show('aR');
user_L3HydraulicBlock2.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
%set the material of the model
clear
load('TempModel/HydraulicBlock1.mat');
B.setUIoutput();%set output of message
d=B.d;
d.calculateData();
d.mo.setGPU('off'); 

topPlatenX=d.aX(d.GROUP.topPlaten);%record current position of top platen
topPlatenY=d.aY(d.GROUP.topPlaten);
topPlatenZ=d.aZ(d.GROUP.topPlaten);
d.getModel();%get xyz from d.mo

%make a crack with specified size
crackL=0.020;
cx1=B.sampleW/2;
cx2=B.sampleW/2;
cz1=0.15/2-crackL/2;
cz2=0.15/2+crackL/2;
Rrate=0.5;
lineX=[cx1;cx2];
lineY=zeros(size(lineX));
lineZ=[cz1;cz2];
curveObj1=f.run('fun/make3DCurve.m',lineX,lineY,lineZ,B.ballR*0.1,Rrate);
lineId=d.addElement(1,curveObj1,'wall');
d.addGroup('crack',lineId);
d.minusGroup('sample','crack',0);
d.delElement(d.GROUP.crack);

d.mo.aX(d.GROUP.topPlaten)=topPlatenX;%move the top platen to its original position
d.mo.aY(d.GROUP.topPlaten)=topPlatenY;
d.mo.aZ(d.GROUP.topPlaten)=topPlatenZ;

sZ=d.mo.aZ(d.GROUP.sample);
sR=d.mo.aR(d.GROUP.sample);
topFilter=(sZ+sR)>max(sZ)-B.SET.sampleH0*0.05;
d.delElement(find(topFilter));
d.resetStatus();

%d.show('aR');return

%----------set material of model
matTxt=load('Mats\ZhaoRock.txt');
rate=1;
matTxt(4)=matTxt(4)*rate;
matTxt(3)=matTxt(3)*rate;
matTxt(1)=matTxt(1)*0.1;%lower 
Mats{1,1}=material('RockHydro',matTxt,B.ballR);
Mats{1,1}.Id=1;
d.Mats=Mats;
%----------end set material of model
d.showB=2;

%---------assign material to layers and balance the model
d.mo.setShear('on');
d.removeFixId('Z',[d.GROUP.lefPlaten;d.GROUP.rigPlaten]);
d.addFixId('Z',[d.GROUP.lefPlaten(end-1),d.GROUP.lefPlaten(end),d.GROUP.rigPlaten(end-1),d.GROUP.rigPlaten(end)]);
d.setGroupMat('sample','RockHydro');
d.groupMat2Model({'sample'});
platenIds=[d.GROUP.lefPlaten;d.GROUP.rigPlaten];
d.mo.aKN(platenIds)=d.mo.aKN(platenIds)*0.1;
d.mo.aMUp(platenIds)=0;
d.mo.mGZ(:)=0;

%---------start computing
d.mo.setGPU('auto');
d.breakGroup();
d.connectGroup('sample');
d.removePrestress(0.1);
d.balance('Standard',2);
d.connectGroup('sample');
d.removePrestress(0.1);
d.balance('Standard',2);

d.show();
%---------end assign material to layers and balance the model1. 

%---------save the data
d.mo.setGPU('off'); 
d.clearData(1);
d.recordCalHour('Step2Finish');
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_L3HydraulicBlock3.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
%apply initial stress on the model
clear
load('TempModel/HydraulicBlock2.mat');
B.setUIoutput();%set output of message
d=B.d;
d.calculateData();
d.mo.setGPU('off'); 
d.getModel();
d.resetStatus();
d.mo.isCrack=1;

%move the left and right platens to their original position
d.moveGroup('lefPlaten',-B.SET.border,0,0);
d.moveGroup('rigPlaten',B.SET.border,0,0);

sZ=d.mo.aZ(d.GROUP.sample);
topFilter=sZ>0.15;
d.addGroup('topBlock',find(topFilter));
area=B.SET.sampleW0*B.ballR*2;
stresszz=-20e6;
gZ=area*stresszz/sum(d.mo.mM(d.GROUP.topBlock));
d.mo.mGZ(d.GROUP.topBlock)=d.mo.mM(d.GROUP.topBlock)*gZ;

d.mo.aMUp(d.GROUP.topBlock)=2;
d.mo.aKS(d.GROUP.topBlock)=d.mo.aKS(d.GROUP.topBlock)*5;
platens=[d.GROUP.lefPlaten;d.GROUP.lefPlaten;d.GROUP.lefPlaten;d.GROUP.lefPlaten;];
d.addGroup('platens',platens);
d.setClump('platens');

d.mo.setGPU('auto'); 
d.balance('Standard',4);
%---------end assign material to layers and balance the model1. 

%---------save the data
d.mo.setGPU('off');
d.show();
d.clearData(1);
d.recordCalHour('Step2Finish');
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();
user_L3HydraulicBlock4.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
clear
fs.randSeed(2);
load('TempModel/HydraulicBlock3.mat');
B.setUIoutput();
%--------initializing the model
d=B.d;
d.calculateData();
d.mo.setGPU('off');

d.showB=2;
d.deleteConnection('boundary');
d.Rrate=1;
d.getModel();
d.resetStatus();
d.mo.isCrack=1;
d.mo.mVis=d.mo.mVis./d.vRate*0.01;%use uniform viscosity

px1=B.sampleW/2;%
pz1=0.15/2;
center_pId=d.findNearestId(px1,0,pz1);
top_pId=d.findNearestId(px1,0,B.sampleH-B.ballR*2);

d.Rrate=1;

%start building pore system
p=pore(d);
p.fluid_k=0.4615e-4;p.fluid_c=870;%use oil property, default value is water

d.mo.dT=d.mo.dT*2;%
p.dT=p.d.mo.dT;
p.pathLimitRate=0.3;%path diameter<pathLimitRate*ballR will be connection
p.isCouple=1;%fluid-solid coupling
p.setInitialPores();
p.setPlaten('fix');%fix the coordinates of platens
%---------end initializing the model

%----------set the drawing of result during iterations
%setappdata(0,'simpleFigure',1);%use simpleFigure to increase drawing speed
%setappdata(0,'ballRate',0.01);%use small ballRate to increase drawing speed
showType='*pPressure';
d.figureNumber=1;
%----------end set the drawing of result during iterations

%d.show('Crack');hold all;d.show('--');

%---------calculate connection diameter and flow K
k=0.00000001;%permeability factor
%---------end calcualte connection diameter and flow K
k=k/10;%change the permeability

pPressureHigh=100e6;%use greater pressure
pPressure0=0.1e6;%use greater pressure
%---------setting of the simulation
totalCircle=5;
dPressure=pPressureHigh/totalCircle;
stepNum=100;
fName=['data/step/2' B.name num2str(B.ballR) '-' num2str(B.distriRate) 'loopNum'];
save([fName '0.mat']);%return;
d.tic(totalCircle);%record the initial time of loop
%d.mo.setGPU('on');
%p.setGPU('on');

for i=1:totalCircle
    pPressure=dPressure*totalCircle;
    for j=1:stepNum
        cDiameterFlow=p.cDiameter+p.cDiameterAdd;%calculate the diameter of
        cDiameterFlow(cDiameterFlow<0)=0;
        p.cKFlow=cDiameterFlow*k./p.cPathLength;%default K of throat is determined by diameter and path length
        cbFilter=d.mo.bFilter(p.cnIndex);%bonded filter of cList
        p.cKFlow(cbFilter)=p.cKFlow(cbFilter)/100;%K of intacted bond is very small
        p.setBallPressure(center_pId,pPressure);%set the pressure in the crack
        p.setBallPressure(top_pId,pPressure0);%set the pressure around the sample

        p.balance();
        d.balance(10);
        d.recordStatus();
    end
    cla;%clear the previous figure
    d.show('Displacement');
    %p.show(showType);
    %pause(0.1);%pause and show the figure
    save([fName num2str(i) '.mat']);%save data
    d.recordStatus();
    d.toc();
end
%---------save the data
d.mo.setGPU('off');
d.clearData(1);
d.recordCalHour('Step3Finish');
save(['TempModel/' B.name '4.mat'],'B','d');
save(['TempModel/' B.name '4R' num2str(B.ballR) '-distri' num2str(B.distriRate)  'aNum' num2str(d.aNum) '.mat']);
d.calculateData();
%user_makeGIF
user_L3HydraulicBlockTest2.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
%set the material of the model
clear
load('TempModel/HydraulicBlock1.mat');
B.setUIoutput();%set output of message
B.name=[B.name 'Test'];
d=B.d;
d.calculateData();
d.mo.setGPU('off'); 
topPlatenX=d.aX(d.GROUP.topPlaten);%record current position of top platen
topPlatenY=d.aY(d.GROUP.topPlaten);
topPlatenZ=d.aZ(d.GROUP.topPlaten);
d.getModel();%get xyz from d.mo

d.mo.aX(d.GROUP.topPlaten)=topPlatenX;%move the top platen to its original position
d.mo.aY(d.GROUP.topPlaten)=topPlatenY;
d.mo.aZ(d.GROUP.topPlaten)=topPlatenZ;

%cut the top part of the sample
sZ=d.mo.aZ(d.GROUP.sample);
sR=d.mo.aR(d.GROUP.sample);
topFilter=(sZ+sR)>max(sZ)-B.SET.sampleH0*0.05;
d.delElement(find(topFilter));
d.resetStatus();

%----------set material of model
matTxt=load('Mats\ZhaoRock.txt');
rate=1;
matTxt(4)=matTxt(4)*rate;
matTxt(3)=matTxt(3)*rate;
matTxt(1)=matTxt(1);%*0.1
Mats{1,1}=material('RockHydro',matTxt,B.ballR);
Mats{1,1}.Id=1;
d.Mats=Mats;
%----------end set material of model
d.showB=2;

%---------assign material to layers and balance the model
d.mo.setShear('on');
d.removeFixId('Z',[d.GROUP.lefPlaten;d.GROUP.rigPlaten]);%left and right platen will be flexible
d.addFixId('Z',[d.GROUP.lefPlaten(end-1),d.GROUP.lefPlaten(end),d.GROUP.rigPlaten(end-1),d.GROUP.rigPlaten(end)]);%corner of platen will be fixed
d.setGroupMat('sample','RockHydro');
d.groupMat2Model({'sample'});
platenIds=[d.GROUP.lefPlaten;d.GROUP.rigPlaten];
d.mo.aKN(platenIds)=d.mo.aKN(platenIds)*0.1;
d.mo.aMUp(platenIds)=0;
d.mo.mGZ(:)=0;

%---------start computing
d.mo.setGPU('auto');
d.breakGroup();%break all connections and glue the sample
d.connectGroup('sample');
d.removePrestress(0.1);%remove internal stress of sample
d.balance('Standard',0.5);
d.connectGroup('sample');
d.removePrestress(0.1);%remove internal stress of sample
d.balance('Standard',0.5);

d.show();
%---------end assign material to layers and balance the model1. 

%---------save the data
d.mo.setGPU('off'); 
d.clearData(1);
d.recordCalHour('Step2Finish');
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_L3HydraulicBlockTest3.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
clear
fs.randSeed(2);
load('TempModel/HydraulicBlockTest2.mat');
B.setUIoutput();%set output of message

%-------------set parameters of test
TestType='Tu';
isClumpBlock=1;%is pressure block a clump or not
stressZZ=0e6;%do not change it in Tu and Cu tests
stressXX=0;%do not change it in Tu and Cu tests
stressXXFinal=0e6;%do not change it in Tu and Cu tests

if strcmp(TestType,'Cu')
    stressZZFinal=-200e6;
    borderRate=0.125;
else
    stressZZFinal=20e6;
    borderRate=0.25;
end
%-------------end set parameters of test
totalCircle=20;
stepNum=100;%10~500, 100 is OK
balanceRate=0.001;%0.001~0.01, 0.002 is OK

%---------set the boundary condition
B.name=[B.name TestType];
d=B.d;
d.calculateData();
d.getModel();
d.resetStatus();
d.mo.isCrack=1;

d.mo.setGPU('off'); 
d.moveGroup('lefPlaten',-B.SET.border,0,0);
d.moveGroup('rigPlaten',B.SET.border,0,0);

%-------set the pressure blocks
borderW=B.SET.sampleW0*borderRate;%set the block size
borderH=B.SET.sampleH0*borderRate;
sFilter=false(d.aNum,1);%filter of sample
sFilter(d.GROUP.sample)=true;

lefFilter=d.mo.aX<B.SET.border+borderW;%filter of left block
lefId=find(lefFilter&sFilter);%Id of left block of sample
rigFilter=d.mo.aX>B.sampleW-B.SET.border-borderW;
rigId=find(rigFilter&sFilter);
botFilter=d.mo.aZ<borderH;
botId=find(botFilter&sFilter);
topFilter=d.mo.aZ>max(d.mo.aZ(d.GROUP.sample))-borderH;
topId=find(topFilter&sFilter);
centerId=find(sFilter&~(botFilter|topFilter|lefFilter|rigFilter));

d.addGroup('botBlock',botId);%define groups
d.addGroup('topBlock',topId);
d.addGroup('lefBlock',lefId);
d.addGroup('rigBlock',rigId);
d.addGroup('centerBlock',centerId);

%-------end set the pressure blocks

%define the parameters of loop
Ts=[];
botBlockForceZZ=[];
topBlockForceZZ=[];
lefBlockForceXX=[];
rigBlockForceXX=[];
botBoundaryForceZZ=[];
center_botBlockForceZZ=[];
center_topBlockForceZZ=[];

dStressZZ=(stressZZFinal-stressZZ)/(totalCircle*stepNum);%increment of stress
dStressXX=(stressXXFinal-stressXX)/(totalCircle*stepNum);
d.tic(totalCircle*stepNum);
fName=['data/step/' B.name  num2str(B.ballR) '-' num2str(B.distriRate) 'loopNum'];

%when this value is 1, the top and bottom block will become clumps
%which will not break and generate boundary friction
if isClumpBlock==1
d.setClump('topBlock');
d.setClump('botBlock');
end

d.connectGroup('botPlaten','botB');%bond the bottom side of the sample
d.connectGroup('botPlaten','sample');
d.mo.zeroBalance();
%increase strength of bottom elements in Tu test
if strcmp(TestType,'Tu')
    botId=[d.GROUP.botBlock;d.GROUP.botPlaten;d.GROUP.botB];
    d.mo.aBF(botId)=d.mo.aBF(botId)*1000;
end

save([fName '0.mat']);%return;
gpuStatus=d.mo.setGPU('auto');
for i=1:totalCircle
    d.mo.setGPU(gpuStatus);
    for j=1:stepNum
        stressZZ=stressZZ+dStressZZ;
        areaZZ=B.SET.sampleW0*B.ballR*2;
        forceZZ=areaZZ*stressZZ;

        %fs.setBodyForce(d,d.GROUP.botBlock,'Z',-forceZZ);
        fs.setBodyForce(d,d.GROUP.topBlock,'Z',forceZZ);

        stressXX=stressXX+dStressXX;
        areaXX=B.SET.sampleH0*B.ballR*2;
        forceXX=areaXX*stressXX;

        fs.setBodyForce(d,d.GROUP.lefBlock,'X',-forceXX);
        fs.setBodyForce(d,d.GROUP.rigBlock,'X',forceXX);

        d.balance('Standard',balanceRate);
        d.recordStatus();

        %record the parameters and draw the curve later
        nFZ=d.mo.nFnZ+d.mo.nFsZ;
        botBlockForcezz=gather(sum(sum(nFZ(d.GROUP.botBlock,:))));
        topBlockForcezz=gather(sum(sum(nFZ(d.GROUP.topBlock,:))));

        nFX=d.mo.nFnX+d.mo.nFsX;
        lefBlockForcexx=gather(sum(sum(nFX(d.GROUP.lefBlock,:))));
        rigBlockForcexx=gather(sum(sum(nFX(d.GROUP.rigBlock,:))));

        FCB=d.getGroupForce('centerBlock','botBlock');
        FCT=d.getGroupForce('centerBlock','topBlock');

        Ts=[Ts,d.mo.totalT];
        botBlockForceZZ=[botBlockForceZZ;botBlockForcezz];
        topBlockForceZZ=[topBlockForceZZ;topBlockForcezz];
        lefBlockForceXX=[lefBlockForceXX;lefBlockForcexx];
        rigBlockForceXX=[rigBlockForceXX;rigBlockForcexx];
        botBoundaryForceZZ=[botBoundaryForceZZ;d.status.bottomBFs(end,3)];

        center_botBlockForceZZ=[center_botBlockForceZZ;FCB.totalFZ];
        center_topBlockForceZZ=[center_topBlockForceZZ;FCT.totalFZ];

        d.toc();%show the note of time
    end
    d.clearData(1);%clear data before saving
    save([fName num2str(i) '.mat']);
    d.calculateData();%calculate the data for further calculation
end

%draw the curves
areaZZcenter=B.SET.sampleW0*(1-borderRate*2)*B.ballR*2;

figure
plot(Ts,botBlockForceZZ/areaZZ);
hold all
plot(Ts,-topBlockForceZZ/areaZZ);
plot(Ts,lefBlockForceXX/areaXX);
plot(Ts,rigBlockForceXX/areaXX);

plot(Ts,botBoundaryForceZZ/areaZZ,'--b');
plot(Ts,-center_botBlockForceZZ/areaZZcenter,'--r');
plot(Ts,center_topBlockForceZZ/areaZZcenter,'--g');
legend('botBlock','topBlock','lefBlock','rigBlock','botBoundary','botP','topP');

d.mo.setGPU('off');
d.clearData(1);
d.recordCalHour('Step3Finish');
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();