%step1: packing the elementsclear;fs.randSeed(1);%random model seed, 1,2,3...B=obj_Box;%declare a box objectB.name='LavaBlock';%--------------initial model------------B.GPUstatus='auto';%program will test the CPU and GPU speed, and choose the quicker oneB.ballR=5;B.isShear=0;B.isClump=0;%if isClump=1, particles are composed of several ballsB.distriRate=0.25;%define distribution of ball radius, B.sampleW=1000;%width, length, height, average radiusB.sampleL=0;%when L is zero, it is a 2-dimensional modelB.sampleH=500;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 elementsd.mo.setGPU('off');delId=[d.GROUP.topPlaten(end-1:end);d.GROUP.botPlaten(end-1:end)];d.delElement(delId);%----------end remove overlap platen elementsd.mo.zeroBalance();d.mo.setShear('off');%because d.mo.isShear will be reset to 1 in d.delElement%---------- gravity sedimentationB.gravitySediment(1);%you may use B.gravitySediment(10); to increase sedimentation time (10)B.compactSample(5);%input is compaction timemfs.reduceGravity(d,1);%------------return and save result--------------d.status.dispEnergy();%display the energy of the modeld.Rrate=1;d.mo.setGPU('off');d.clearData(1);%clear dependent datad.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');
%set the material of the modelclearload('TempModel/LavaBlock1.mat');B.setUIoutput();%set output of messaged=B.d;d.calculateData();d.mo.setGPU('off');d.mo.aX(d.GROUP.topPlaten)=d.aX(d.GROUP.topPlaten);d.mo.aY(d.GROUP.topPlaten)=d.aY(d.GROUP.topPlaten);d.mo.aZ(d.GROUP.topPlaten)=d.aZ(d.GROUP.topPlaten);platenId=[d.GROUP.lefPlaten;d.GROUP.rigPlaten;d.GROUP.botPlaten;d.GROUP.topPlaten];d.addFixId('XYZ',platenId);d.getModel();%get xyz from d.mod.resetStatus();%----------remove top partsX=d.mo.aX(d.GROUP.sample);sZ=d.mo.aZ(d.GROUP.sample);topFilter=sZ>0.9*B.sampleH;%----------make a holecx=B.sampleW/2;cz=0;holeR=50;cFilter=sqrt((sX-cx).^2+(sZ-cz).^2)<holeR;delId=find(topFilter|cFilter);d.delElement(delId);%---------define weak layersZ=d.mo.aZ(d.GROUP.sample);weakFilter=sZ>0.2*B.sampleH&sZ<0.25*B.sampleH;d.addGroup('WeakLayer',find(weakFilter));%----------set material of modelmatTxt=load('Mats\LavaRock.txt');rate=1;matTxt(4)=matTxt(4)*rate;matTxt(3)=matTxt(3)*rate;matTxt(1)=matTxt(1)*1;%lower Mats{1,1}=material('RockHydro',matTxt,B.ballR);Mats{1,1}.Id=1;rate2=0.1;matTxt(4)=matTxt(4)*rate2;matTxt(3)=matTxt(3)*rate2;Mats{2,1}=material('RockWeak',matTxt,B.ballR);Mats{2,1}.Id=2;d.Mats=Mats;%----------end set material of modeld.showB=2;%---------assign material to layers and balance the modeld.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.setGroupMat('WeakLayer','RockWeak');d.groupMat2Model({'sample','WeakLayer'},1);platenIds=[d.GROUP.lefPlaten;d.GROUP.rigPlaten];d.mo.aKN(platenIds)=d.mo.aKN(platenIds)*0.1;d.mo.aMUp(platenIds)=0;%d.show('aMatId');return%---------start computingd.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 datad.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();
%apply initial stress on the modelclearload('TempModel/LavaBlock2.mat');B.setUIoutput();%set output of messaged=B.d;d.calculateData();d.mo.setGPU('off');d.getModel();d.resetStatus();d.mo.isCrack=1;sZ=d.mo.aZ(d.GROUP.sample);topFilter=sZ>max(d.mo.aZ(d.GROUP.sample))-B.sampleH*0.05;d.addGroup('topBlock',find(topFilter));area=B.sampleW*B.ballR*2;stresszz=-5e6;%additional vertical pressure on the modelgZ=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 datad.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();
clearfs.randSeed(2);load('TempModel/LavaBlock3.mat');B.setUIoutput();%--------initializing the modeld=B.d;d.calculateData();d.mo.setGPU('off');d.showB=0;d.Rrate=1;d.getModel();d.resetStatus();d.mo.isCrack=1;d.mo.mVis=d.mo.mVis./d.vRate*0.1;%use uniform viscosityhole_pId=d.findNearestId(B.sampleW/2,0,0);top_pId=d.findNearestId(B.sampleW/2,0,B.sampleH);d.Rrate=0.2;%start building pore systemp=pore(d);p.fluid_k=0.4615e-4;p.fluid_c=870;%use oil property, default value is waterd.mo.dT=d.mo.dT;%p.dT=p.d.mo.dT;p.pathLimitRate=0.3;%path diameter<pathLimitRate*ballR will be connectionp.isCouple=1;%fluid-solid couplingp.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 speedshowType='*pPressure';d.figureNumber=1;%----------end set the drawing of result during iterations%d.show('Crack');hold all;d.show('--');%---------calculate connection diameter and flow Kk=0.00000001;%permeability factor%---------end calcualte connection diameter and flow Kk=k*10000;%change the permeabilitypPressureHigh=100e6;%use greater pressurepPressure0=0.1e6;%use greater pressure%---------setting of the simulationtotalCircle=10;%default value is 40, use 10 to increase speeddPressure=pPressureHigh/totalCircle;stepNum=50;fName=['data/step/2'B.namenum2str(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');fori=1:totalCirclepPressure=dPressure*totalCircle;forj=1:stepNumcDiameterFlow=p.cDiameter+p.cDiameterAdd;%calculate the diameter ofcDiameterFlow(cDiameterFlow<0)=0;p.cKFlow=cDiameterFlow*k./p.cPathLength;%default K of throat is determined by diameter and path lengthcbFilter=d.mo.bFilter(p.cnIndex);%bonded filter of cListp.cKFlow(cbFilter)=p.cKFlow(cbFilter)/100;%K of intacted bond is very smallp.setBallPressure(hole_pId,pPressure);%set the pressure in the crackp.setBallPressure(top_pId,pPressure0);%set the pressure around the samplep.balance();d.balance(10);d.recordStatus();ifj==0d.show('mV');returnendendcla;%clear the previous figurep.show('pPressure');%p.show(showType);%pause(0.1);%pause and show the figuresave([fNamenum2str(i)'.mat']);%save datad.recordStatus();d.toc();end%---------save the datad.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