%step1: packing the elementsclear;fs.randSeed(1);%random model seed, 1,2,3...B=obj_Box;%declare a box objectB.name='PoreFlood';%--------------initial model------------B.GPUstatus='auto';%program will test the CPU and GPU speed, and choose the quicker oneB.ballR=0.005;B.isShear=0;B.isClump=0;%if isClump=1, particles are composed of several ballsB.distriRate=0.2;%define distribution of ball radius, B.sampleW=0.2;%width, length, height, average radiusB.sampleL=0;%when L is zero, it is a 2-dimensional modelB.sampleH=0.2;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------------d.mo.setGPU('off');%----------remove overlap platen elementsdelId=[d.GROUP.topPlaten(end-1:end);d.GROUP.botPlaten(end-1:end)];d.delElement(delId);d.mo.zeroBalance();%----------end remove overlap platen elements%---------- gravity sedimentationB.gravitySediment(1);%you may use B.gravitySediment(10); to increase sedimentation time (10)%------------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();
%set the material of the modelclearload('TempModel/PoreFlood1.mat');B.setUIoutput();%set output of messaged=B.d;d.calculateData();d.mo.setGPU('off');d.getModel();%get xyz from d.mo%------------remove top elements of sample to make ocean areatopModelFilter=d.mo.aZ>max(d.mo.aZ)*0.7;d.addGroup('topModel',find(topModelFilter));maxS=max(d.GROUP.sample);topSampleId=d.GROUP.topModel(d.GROUP.topModel<=maxS);d.delElement(topSampleId);%------------end remove top elements of sample to make ocean area%----------set material of modelmatTxt=load('Mats\RockHydro.txt');Mats{1,1}=material('RockHydro',matTxt,B.ballR);Mats{1,1}.Id=1;d.Mats=Mats;%----------end set material of model%---------assign material to layers and balance the modelB.setPlatenFixId();d.setGroupMat('sample','RockHydro');d.groupMat2Model({'sample'});d.balanceBondedModel0();d.balance('Standard',5);%---------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();
%set the material of the modelclearfs.randSeed(2);load('TempModel/PoreFlood2.mat');B.setUIoutput();%--------initializing the modeld=B.d;d.calculateData();d.mo.setGPU('off');d.getModel();%get xyz from d.mod.showB=2;d.deleteConnection('boundary');d.Rrate=1;d.getModel();d.mo.isCrack=1;d.mo.bFilter(:)=false;%break all connectionsd.mo.zeroBalance();d.mo.mVis=d.mo.mVis./d.vRate*0.001;%use uniform viscosityp=pore(d);d.mo.dT=d.mo.dT/5;%use small step timep.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%-----------drawing settingsetappdata(0,'simpleFigure',1);%use simpleFigure to increase drawing speedsetappdata(0,'ballRate',0.01);%use small ballRate to increase drawing speedshowType='*pPressure';figureNumber=d.show('mV');%define figureNumber, figure will shown in one form during iterationsd.figureNumber=figureNumber;%-----------end drawing setting%---------calculate connection diameter and flow Kk=0.00000001;%permeability factor%---------end calcualte connection diameter and flow Kk=k/10;pPressureHigh=p.pPressure(1)*10000;%use greater pressuretotalCircle=10;stepNum=200;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 loopticfori=1:totalCircleforj=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 lengthp.setBallPressure(1,pPressureHigh);p.balance();d.balance();endsave([fNamenum2str(i)'.mat']);d.recordStatus();p.show(showType);d.toc();endp.show('pPressure');toc%---------savethedatad.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();