This commit is contained in:
xinxiao
2026-03-13 11:24:41 +08:00
commit 04e2bb29c7
238 changed files with 29102 additions and 0 deletions
@@ -0,0 +1,523 @@
function r = GridProp_DP(modelflag,nx, ny, nz, dx, dy, dz, kx, ky, kz, kx_matrixLayer, ky_matrixLayer, kz_matrixLayer, f, frac_information, fellip, Kf, Wf, pori, pori_matrixLayer, prpor, cpor, Porf, prporf, cporf, cf, ca,NTG)
tic;
%% 基质网格参数及网格参数计算、存储
r.modelflag=modelflag;
r.nx = nx;
r.ny = ny;
r.nz = nz;
r.dx = dx;
r.dy = dy;
r.dz = dz;
r.kx = kx;
r.ky = ky;
r.kz = kz;
r.kx_matrixLayer = kx_matrixLayer;
r.ky = ky;
r.kz = kz;
r.Kf = Kf;%裂缝面对应的渗透率,非裂缝单元
r.Wf = Wf;%裂缝面对应的缝宽,非裂缝单元
r.cf = cf;
r.ca = ca;
% r.co=co;
r.cpor=cpor;
r.cporf=cporf;
r.NTG=NTG;
r.frac_information = frac_information;
[coordinates, nodes, nP, nE, dxv, dyv,dzv,zm,vm,xrao,yrao,zrao,cell_mid_coordinates] = GenerateNode_final(dx, dy,dz ,nx,ny,nz,NTG);
r.coordinates = coordinates;
r.nodes = nodes;
nmc=nE;
r.nmc =nmc;
r.dxv = dxv;
r.dyv = dyv;
r.dzv = dzv;
r.vm=vm;
r.cell_mid_coordinates=cell_mid_coordinates;
%% 求解裂缝与基质网格连接情况
%% 关键参数矩阵初始化
m=size(f,1);
n=size(fellip,1);
nfr=m/5;%矩形规则裂缝条数
nfir=n/5;%不规则裂缝条数(当然包含椭圆)
r.nfr=nfr; r.nfir=nfir;
nf=nfr+nfir;
r.nf=nf;
if (nfir~=0) && (nfr~=0)
f=[f;fellip];
else if nfr~=0
f=f;
else if nfir~=0
f=fellip;
else error('Dr Rao reminds you that there is no information about fractures');
end
end
end
%d3intersection=-1000*ones(1000,3);%用-1000做标识
raopoint=cell(nfr+nfir,2);%利用元胞数组存储每条裂缝与基质网格线的交点,
%第一列是三维坐标形式,即d3intersection
%第二列是裂缝面参数形式,即anothersection
pointvsregion=cell(nfr+nfir,3);%利用元胞数组存储interarea函数的结果numofmesh, numvspoint,numofregion
fracrossfra=cell(nfr+nfir,nfr+nfir-1);%判断裂缝之间两交点坐标
fratmaxfra=zeros(nfr+nfir,nfr+nfir-1);%判断裂缝之间交线参数的最大值
fratminfra=zeros(nfr+nfir,nfr+nfir-1);%判断裂缝之间交线参数的最小值
fracturemesh=cell(nf,1);%每一行是一条裂缝面上的网格剖分情况
%% 计算裂缝与基质网格相交情况
for i=1:nfr
raopoint{i,1}= intersectionsolve_new_modified_r(f((5*i-4):(5*i),:),dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
raopoint{i,2}= anosection( f((5*i-4):(5*i),:),raopoint{i,1} );
[ pointvsregion{i,1},pointvsregion{i,2} ,pointvsregion{i,3}] = interarea( raopoint{i,1},dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
end
% 不规则缝计算
if nfir>0
for i=1:nfir
raopoint{nfr+i,1}= intersectionsolve_new_modified_irr(fellip((5*i-4):(5*i),:),dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
raopoint{nfr+i,2}= anosection( f((5*(nfr+i)-4):(5*(nfr+i)),:),raopoint{nfr+i,1} );
[ pointvsregion{nfr+i,1},pointvsregion{nfr+i,2} ,pointvsregion{nfr+i,3}] = interarea( raopoint{nfr+i,1},dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
end
end
%% 计算裂缝之间相交线情况
for i=1:nf
for j=1:nf
if i>nfr || j>nfr cross=zeros(2,3);tmax=0;tmin=0;
else
% [ cross,tmax,tmin ]=frac_cross_frac( f((5*i-4):(5*i),:),f((5*j-4):(5*j),:) );
cross=zeros(2,3);tmax=0;tmin=0;
end
fracrossfra{i,j}=cross;fratmaxfra(i,j)=tmax;fratminfra(i,j)=tmin;
end
end
%% 计算裂缝被基质网格、其它裂缝与之相交后的网格分布情况,绘制二维裂缝平面参数坐标系上的网格分布情况
% figure('color','w');
addflag=zeros(nf,1);%乘2的幂次,防止因为裂缝条数较多,造成矩阵太大
for i=1:nf
d3intersection=raopoint{i,1};anothersection=raopoint{i,2};
[ mesh ] = frac_mat_mesh( d3intersection,anothersection,pointvsregion{i,2},pointvsregion{i,1} );
% for j=1:nf
% [ mesh,d3intersection,anothersection,add_flag ]= frac_frac_mesh_modified(xrao,yrao,zrao,mesh,f(5*i-4,:),f(5*i-3,:),f(5*i-2,:),fracrossfra{i,j},fratmaxfra(i,j),fratminfra(i,j),d3intersection,anothersection,pointvsregion{i,2},pointvsregion{i,1} );
% addflag(j,1)=addflag(j,1)+add_flag;
% end
raopoint{i,1} = d3intersection; raopoint{i,2} = anothersection;%由原来裂缝与网格的交点不断更新加入其它裂缝与该裂缝的交点
fracturemesh{i,1}=mesh;
% subplot(nf,1,i);color_fill={'y','r','b','g'};
% plotmesh2D(mesh,raopoint{i,2},color_fill{1,mod(i,4)+1});
end
%% 绘制三维背景网格(基质网格)及裂缝网格分布
%figure(2)
%network3D(dx,dy,dz,nx,ny,nz );
%hold on;
figure('color','w');
% plot_reservoir_3D(max(xrao),max(yrao),dz(1),1,1,nz);
% plot_reservoir_3D(dx(1),dy(1),dz(1),nx,ny,nz);
network3D(dx(1),dy(1),dz(1),nx,ny,nz);
% network3D(1000,700,10,1,1,1);
% network3D(800,300,10,1,1,1);
hold on;
% network3D_arbitrary(dx,dy,dz,nx,ny,nz);
% refine;
% hold on;
for i=1:nf
% color_fill={'y','r','b','g','c','m'};
% color_fill={'y','r','b','g'};
% plotmesh3D( fracturemesh{i,1},raopoint{i,1},color_fill{1,mod(i,4)+1});hold on;
if i <= 100
color_fill='b'; %流动屏障
% elseif i <=19
% color_fill='b'; %压裂缝
% if i == 2 || i == 9
% color_fill='r';
% end
else
color_fill='k'; %天然裂缝
end
% plotmesh3D( fracturemesh{i,1},raopoint{i,1},color_fill{1,mod(i,4)+1});hold on;
plotmesh3D( fracturemesh{i,1},raopoint{i,1},color_fill);hold on;
end
% % % basic_node_coord = [0,0,0];
% % % x_length = 700;
% % % y_length = 800;
% % % z_length = 10;
% % % nodes_domain = [basic_node_coord;]
% % % fill3(x,y,z,'w');
% refine1;
% refine_chengjiepaper;
% refine;
% plot_reservoir_3D(max(xrao),max(yrao),dz(1),1,1,nz);
% plot_reservoir_3D(dx(1),dy(1),dz(1),nx,ny,nz);
xlabel('x, m','FontSize',14);
ylabel('y, m','FontSize',14);
zlabel('z, m','FontSize',14);
ax = gca;
ax.FontSize = 14;
%
% zticks([0, 5]);
% yticks(-1:0.5:1);
% 设置x轴和y轴的刻度标签
% zticklabels({'-2005', '-2000'});
% yticklabels({'-1', '-0.5', '0', '0.5', '1'});
% 关闭刻度标签的旋转
% xticklabels('Rotation', 0);
% yticklabels('Rotation', 0);
% axis equal;
% refine;
% hold on
% network3D(dx(1),dy(1),dz(1),nx,ny,nz);
% network3D(max(xrao),max(yrao),max(zrao),1,1,1 );
% network3D(10,10,10,2,1,1 );
% network3D(10,10,10,6,1,2 );
alpha(1)
view(3)
% axis([min(xrao),max(xrao),min(yrao),max(yrao),min(zrao),max(zrao)]);
% axis equal
% % hold off;
%% 确定裂缝编号及连接情况,计算传导系数
if modelflag==1 %表示用2014, Monifar
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,cell_divided_by_fracture_flag, flowArea, perm, matrixflag ] = connections_2014( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,pori,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.flowArea=flowArea;
r.perm=perm;
r.matrixflag=matrixflag;
elseif modelflag==4 %表示用 PEDFM
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_new( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==5 % 表示实用型PEDFM
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff, flowArea, perm, matrixflag ] = connections_PEDFM_new_new( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,pori,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
r.flowArea=flowArea;
r.perm=perm;
r.matrixflag=matrixflag;
elseif modelflag==6 % 表示基于非结构网格pEDFM的validation model
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag] = connections_unstructured_EDFM( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
% 劈分或增加
vm_the_added_cell = vm(cell_divided_by_fracture_flag)*1/2;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag)*1/2;
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==7
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_EX1_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==8 % 表示基于非结构网格pEDFM的validation model
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX1_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
% 劈分或增加
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==9 % EX2 不同情况下 pEDFM 解
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_EX2_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==10 % 表示基于非结构网格pEDFM的 EX2 参考解
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX2_1to3_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
% 劈分或增加
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==11 % 表示基于非结构网格pEDFM的 EX2 参考解
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX2_1to2_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
% 劈分或增加
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==12 % 表示基于非结构网格pEDFM的 EX2 参考解
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX2_1to4_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
% 劈分或增加
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==13 % 表示基于非结构网格pEDFM的 EX2 参考解
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_TPFA_MFD( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,perm,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==14 %表示用 PEDFM
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_new_twofractures( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
else
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,NTG );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%基质网格和裂缝单元总数
r.nex=nex;%具有流体交换的总数
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%裂缝单元对应的渗透率
r.wf=wf;%裂缝单元对应的缝宽
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
%% 计算传导系数
% dxvector=ones(1,nx);dyvector=ones(1,ny);dzvector=ones(1,nz);
% [ transmatrix,transfracture ] = trans(dxvector,dyvector,dzvector ,nx,ny,nz,nf,fracnumber,lengthvsfra,disvsfra,fracstart,connect_infrac,corevsfra,matrixvsfra,raopoint,f );
%% 计算基质与裂缝之间窜流的相关系数
if modelflag==2 %表示用2018, Rao
[ G,Gfm,Gff,Gf,Ap,Apf ]=interflowmf1(r,dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
[Ka, M, F2M , MF_coef] = transFunc_aniso(nc,coordinates, nodes, connectmf,Ap,Apf, matrixvsfra,N,T,kx, ky,kz);
r.Ka = Ka;
r.M = M;
r.F2M = F2M;
r.MF_coef = MF_coef;
elseif modelflag==5 %表示用 Modified Rao, steady, 2018
[ G,Gfm,Gff,Gf,Ap,Apf ] = interflowmf_MODIFIED(r,dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
[Ka, M, F2M , MF_coef] = transFunc_aniso_MODIFIED(nc,coordinates, nodes, connectmf,Ap,Apf, matrixvsfra,N,T,kx, ky,kz);
r.Ka = Ka;
r.M = M;
r.F2M = F2M;
r.MF_coef = MF_coef;
% [ G,Gfm,Gff,Gf,Ap,Apf,Apmt,Apft ]=interflowmf1_transient(dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
end
% [ G,Gfm,Gff,Gf,Ap,Apf ]=interflowmf1(dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
%%
% r.MF_deltt=MF_deltt;
end
%% 计算深度(以下平面为基准计算得到的高度,值为正数)
z=[zm;zf];
r.z=z;
rpt = [ones(nmc, 1); zeros(nfc, 1)];
r.rpt = rpt;
r.Porf = Porf;
pori = [pori; porf];
r.pori = pori;
r.por = @(p)por(p, prpor, pori, cpor, prporf, cporf, r.rpt);
tpre=toc;
r.tpre=tpre;
end
@@ -0,0 +1,534 @@
function r = GridProp_DP(modelflag, r, kx, ky, kz, kx_matrixLayer, ky_matrixLayer, kz_matrixLayer, f, frac_information, fellip, Kf, Wf, pori, pori_matrixLayer, prpor, cpor, Porf, prporf, cporf, cf, ca,NTG,sigma,valid_grids)
tic;
%%
nx = r.nx;
ny = r.ny;
nz = r.nz;
dx = r.dx;
dy = r.dy;
dz = r.dz;
coordinates = r.coordinates;
nodes = r.nodes;
nP = r.nP;
nmc = r.nmc;
dxv = r.dxv;
dyv = r.dyv;
dzv = r.dzv;
zm = r.zm;
vm = r.vm;
xrao = r.xrao;
yrao = r.yrao;
zrao = r.zrao;
cell_mid_coords = r.cell_mid_coords;
%
r.modelflag=modelflag;
r.kx_matrixLayer = kx_matrixLayer;
r.ky_matrixLayer = ky_matrixLayer;
r.kz_matrixLayer = kz_matrixLayer;
r.Kf = Kf;%
r.Wf = Wf;%
r.cf = cf;
r.ca = ca;
% r.co=co;
r.cpor=cpor;
r.cporf=cporf;
r.NTG=NTG;
r.frac_information = frac_information;
% [coordinates, nodes, nP, nE, dxv, dyv,dzv,zm,vm,xrao,yrao,zrao,cell_mid_coordinates] = GenerateNode_final(dx, dy,dz ,nx,ny,nz,NTG);
% r.coordinates = coordinates;
% r.nodes = nodes;
% nmc=nE;
% r.nmc =nmc;
% r.dxv = dxv;
% r.dyv = dyv;
% r.dzv = dzv;
% r.vm=vm;
% r.cell_mid_coordinates=cell_mid_coordinates;
%%
%%
m=size(f,1);
n=size(fellip,1);
nfr=m/5;%
nfir=n/5;%
r.nfr=nfr; r.nfir=nfir;
nf=nfr+nfir;
r.nf=nf;
if (nfir~=0) && (nfr~=0)
f=[f;fellip];
else if nfr~=0
f=f;
else if nfir~=0
f=fellip;
else error('Dr Rao reminds you that there is no information about fractures');
end
end
end
%d3intersection=-1000*ones(1000,3);%-1000
raopoint=cell(nfr+nfir,2);%线
%d3intersection
%anothersection
pointvsregion=cell(nfr+nfir,3);%interarea函数的结果numofmesh, numvspoint,numofregion
fracrossfra=cell(nfr+nfir,nfr+nfir-1);%
fratmaxfra=zeros(nfr+nfir,nfr+nfir-1);%线
fratminfra=zeros(nfr+nfir,nfr+nfir-1);%线
fracturemesh=cell(nf,1);%
%%
for i=1:nfr
raopoint{i,1}= intersectionsolve_new_modified_r(f((5*i-4):(5*i),:),dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
raopoint{i,2}= anosection( f((5*i-4):(5*i),:),raopoint{i,1} );
[ pointvsregion{i,1},pointvsregion{i,2} ,pointvsregion{i,3}] = interarea( raopoint{i,1},dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
end
%
if nfir>0
for i=1:nfir
raopoint{nfr+i,1}= intersectionsolve_new_modified_irr(fellip((5*i-4):(5*i),:),dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
raopoint{nfr+i,2}= anosection( f((5*(nfr+i)-4):(5*(nfr+i)),:),raopoint{nfr+i,1} );
[ pointvsregion{nfr+i,1},pointvsregion{nfr+i,2} ,pointvsregion{nfr+i,3}] = interarea( raopoint{nfr+i,1},dx,dy,dz,nx,ny,nz,xrao,yrao,zrao );
end
end
%% 线
for i=1:nf
for j=1:nf
if i>nfr || j>nfr cross=zeros(2,3);tmax=0;tmin=0;
else
% [ cross,tmax,tmin ]=frac_cross_frac( f((5*i-4):(5*i),:),f((5*j-4):(5*j),:) );
cross=zeros(2,3);tmax=0;tmin=0;
end
fracrossfra{i,j}=cross;fratmaxfra(i,j)=tmax;fratminfra(i,j)=tmin;
end
end
%% ,
% figure('color','w');
addflag=zeros(nf,1);%2
for i=1:nf
d3intersection=raopoint{i,1};anothersection=raopoint{i,2};
[ mesh ] = frac_mat_mesh( d3intersection,anothersection,pointvsregion{i,2},pointvsregion{i,1} );
% for j=1:nf
% [ mesh,d3intersection,anothersection,add_flag ]= frac_frac_mesh_modified(xrao,yrao,zrao,mesh,f(5*i-4,:),f(5*i-3,:),f(5*i-2,:),fracrossfra{i,j},fratmaxfra(i,j),fratminfra(i,j),d3intersection,anothersection,pointvsregion{i,2},pointvsregion{i,1} );
% addflag(j,1)=addflag(j,1)+add_flag;
% end
raopoint{i,1} = d3intersection; raopoint{i,2} = anothersection;%
fracturemesh{i,1}=mesh;
% subplot(nf,1,i);color_fill={'y','r','b','g'};
% plotmesh2D(mesh,raopoint{i,2},color_fill{1,mod(i,4)+1});
end
%%
%figure(2)
%network3D(dx,dy,dz,nx,ny,nz );
%hold on;
figure('color','w');
% plot_reservoir_3D(max(xrao),max(yrao),dz(1),1,1,nz);
% plot_reservoir_3D(dx(1),dy(1),dz(1),nx,ny,nz);
network3D(dx(1),dy(1),dz(1),nx,ny,nz);
% network3D(1000,700,10,1,1,1);
% network3D(800,300,10,1,1,1);
hold on;
% network3D_arbitrary(dx,dy,dz,nx,ny,nz);
% refine;
% hold on;
for i=1:nf
% color_fill={'y','r','b','g','c','m'};
% color_fill={'y','r','b','g'};
% plotmesh3D( fracturemesh{i,1},raopoint{i,1},color_fill{1,mod(i,4)+1});hold on;
if i <= 100
color_fill='b'; %
% elseif i <=19
% color_fill='b'; %
% if i == 2 || i == 9
% color_fill='r';
% end
else
color_fill='k'; %
end
% plotmesh3D( fracturemesh{i,1},raopoint{i,1},color_fill{1,mod(i,4)+1});hold on;
plotmesh3D( fracturemesh{i,1},raopoint{i,1},color_fill);hold on;
end
% % % basic_node_coord = [0,0,0];
% % % x_length = 700;
% % % y_length = 800;
% % % z_length = 10;
% % % nodes_domain = [basic_node_coord;]
% % % fill3(x,y,z,'w');
% refine1;
% refine_chengjiepaper;
% refine;
% plot_reservoir_3D(max(xrao),max(yrao),dz(1),1,1,nz);
% plot_reservoir_3D(dx(1),dy(1),dz(1),nx,ny,nz);
xlabel('x, m','FontSize',14);
ylabel('y, m','FontSize',14);
zlabel('z, m','FontSize',14);
ax = gca;
ax.FontSize = 14;
%
% zticks([0, 5]);
% yticks(-1:0.5:1);
% x轴和y轴的刻度标签
% zticklabels({'-2005', '-2000'});
% yticklabels({'-1', '-0.5', '0', '0.5', '1'});
%
% xticklabels('Rotation', 0);
% yticklabels('Rotation', 0);
% axis equal;
% refine;
% hold on
% network3D(dx(1),dy(1),dz(1),nx,ny,nz);
% network3D(max(xrao),max(yrao),max(zrao),1,1,1 );
% network3D(10,10,10,2,1,1 );
% network3D(10,10,10,6,1,2 );
alpha(1)
view(3)
% axis([min(xrao),max(xrao),min(yrao),max(yrao),min(zrao),max(zrao)]);
% axis equal
% % hold off;
%%
if modelflag==1 %2014, Monifar
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,cell_divided_by_fracture_flag, flowArea, perm, matrixflag, T_diff ] = connections_2014_DP( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz, kx_matrixLayer, ky_matrixLayer, kz_matrixLayer, pori, pori_matrixLayer, Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,sigma,addflag,valid_grids );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.nmc = 2*nmc;
nc=nfc+r.nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.T_diff = T_diff;
r.vf=vf;
r.V=[vm;vm;vf];
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.flowArea=flowArea;
r.perm=perm;
r.matrixflag=matrixflag;
elseif modelflag==4 % PEDFM
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_new( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==5 % PEDFM
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff, flowArea, perm, matrixflag ] = connections_PEDFM_new_new( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,pori,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
r.flowArea=flowArea;
r.perm=perm;
r.matrixflag=matrixflag;
elseif modelflag==6 % pEDFM的validation model
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag] = connections_unstructured_EDFM( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
%
vm_the_added_cell = vm(cell_divided_by_fracture_flag)*1/2;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag)*1/2;
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==7
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_EX1_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==8 % pEDFM的validation model
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX1_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
%
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==9 % EX2 pEDFM
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_EX2_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==10 % pEDFM的 EX2
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX2_1to3_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
%
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==11 % pEDFM的 EX2
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX2_1to2_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
%
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==12 % pEDFM的 EX2
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,number_of_adding,cell_divided_by_fracture_flag,volume_ratio,fractureCell_matrixCell_addedMatrixCell] = connections_unstructured_EDFM_EX2_1to4_solutions( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
r.number_of_adding=number_of_adding;
nmc = nmc+number_of_adding;
r.nmc = nmc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.T_convection=T_convection;
r.vf=vf;
r.fractureCell_matrixCell_addedMatrixCell = fractureCell_matrixCell_addedMatrixCell;
r.volume_ratio=volume_ratio;
%
vm_the_added_cell = vm(cell_divided_by_fracture_flag).*volume_ratio;
vm(cell_divided_by_fracture_flag) = vm(cell_divided_by_fracture_flag).*(1-volume_ratio);
vm = [vm; vm_the_added_cell];
r.V=[vm;vf];
pori = [pori; pori(cell_divided_by_fracture_flag)];
r.cell_divided_by_fracture_flag = cell_divided_by_fracture_flag;
r.porf=porf;
r.fcff=fcff;
r.mat_frac=mat_frac;
elseif modelflag==13 % pEDFM的 EX2
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_TPFA_MFD( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,perm,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
elseif modelflag==14 % PEDFM
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections_PEDFM_new_twofractures( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,coordinates,nodes,NTG,addflag,frac_information, coordinates);
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
else
[ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac, N,T,zf,fcinff,vf,porf,fcff ] = connections( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz,Kf,Wf,Porf,dxv,dyv,dzv,NTG );
nfc=size(fracnumber,1);
nex=size(T,1);
r.nfc=nfc;
nc=nfc+nmc;
r.nc=nc;%
r.nex=nex;%
kf=Kf(fcinff);
wf=Wf(fcinff);
r.kf=kf;%
r.wf=wf;%
r.N=N;
r.T=T;
r.vf=vf;
r.V=[vm;vf];
r.porf=porf;
r.fcff=fcff;
%%
% dxvector=ones(1,nx);dyvector=ones(1,ny);dzvector=ones(1,nz);
% [ transmatrix,transfracture ] = trans(dxvector,dyvector,dzvector ,nx,ny,nz,nf,fracnumber,lengthvsfra,disvsfra,fracstart,connect_infrac,corevsfra,matrixvsfra,raopoint,f );
%%
if modelflag==2 %2018, Rao
[ G,Gfm,Gff,Gf,Ap,Apf ]=interflowmf1(r,dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
[Ka, M, F2M , MF_coef] = transFunc_aniso(nc,coordinates, nodes, connectmf,Ap,Apf, matrixvsfra,N,T,kx, ky,kz);
r.Ka = Ka;
r.M = M;
r.F2M = F2M;
r.MF_coef = MF_coef;
elseif modelflag==5 % Modified Rao, steady, 2018
[ G,Gfm,Gff,Gf,Ap,Apf ] = interflowmf_MODIFIED(r,dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
[Ka, M, F2M , MF_coef] = transFunc_aniso_MODIFIED(nc,coordinates, nodes, connectmf,Ap,Apf, matrixvsfra,N,T,kx, ky,kz);
r.Ka = Ka;
r.M = M;
r.F2M = F2M;
r.MF_coef = MF_coef;
% [ G,Gfm,Gff,Gf,Ap,Apf,Apmt,Apft ]=interflowmf1_transient(dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
end
% [ G,Gfm,Gff,Gf,Ap,Apf ]=interflowmf1(dxv,dyv,dzv,matrixvsfra,connectmf,fracstart,fracnumber,raopoint,f,nodes,coordinates,nf,corevsfra );
%%
% r.MF_deltt=MF_deltt;
end
%%
z=[zm;zm;zf];
r.z=z;
rpt = [ones(r.nmc, 1); zeros(nfc, 1)];
r.rpt = rpt;
r.Porf = Porf;
pori = [pori; pori_matrixLayer; porf];
r.pori = pori;
r.por = @(p)por(p, prpor, pori, cpor, prporf, cporf, r.rpt);
tpre=toc;
r.tpre=tpre;
end
@@ -0,0 +1,5 @@
function [Ppr,BG,MUG] = cal_gas_prop(prg,Bgi,cg,vgi,cvg)
Ppr = (0.1:0.1:100)';
BG = Bgi * (1 - cg * (Ppr - prg));
MUG = vgi + cvg * (Ppr - prg);
end
@@ -0,0 +1,579 @@
function [ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac,N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,cell_divided_by_fracture_flag, flowArea, perm, matrixflag] = connections_2014( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz, kx_matrixLayer, ky_matrixLayer, kz_matrixLayer, pori, pori_matrixLayer,kf,wf,Porf,dxv,dyv,dzv,coord,nodes,NTG,sigma,addflag )
% 该函数用以给裂缝面网格编号,并存储网格间的连接关系及传导率,是前处理的关键步骤
% 不同于二维嵌入式离散裂缝模型,三维模型中,裂缝是二维平面,网格之间连接关系复杂,
%不能简单得从基质网格来判定,若所处基质网格不相邻,则裂缝网格必不相邻,若所处基质网格相邻,裂缝网格却不一定相邻
%上述原则无助于我们去确定connections,故拟采取以下方案:
%第一步:按照xink矩阵去掉零行后,按照行数依次给某裂缝面网格编号,同时存储裂缝网格所在的基质网格序号
%第二步:存储每个裂缝网格的面积,边界,边界长度,中心点坐标,中心点到各边界的距离,为后续操作做准备
%第三步:按照裂缝网格序号顺序,按照边界进行搜索,如果有相同的边界,则两个裂缝网格是相邻的
%matrixvsfra矩阵代表基质网格中包含裂缝网格编号的情况
%fracnumber矩阵,行序号表示该裂缝网格编号,行内容表示该网格包含的点序号
%areavsfra矩阵,行序号表示该裂缝网格编号,行内容表示该裂缝网格的面积
%每相邻两列是一条边,然后将顺序反过来,又是两列一条边
%lengthvsfra矩阵,行序号表示该裂缝网格编号,行内容表示该裂缝网格的各边长度
%corevsfra矩阵,行序号表示该裂缝网格编号,行内容表示该裂缝网格的重心坐标
%disvsfra矩阵,行序号表示该裂缝网格编号,行内容表示该裂缝网格的重心到各边的距离
matrixvsfra=zeros(nx*ny*nz,10);%为了减少该矩阵的大小,考虑实际情况,一个基质网格中,一般不会有超过10个裂缝网格
fracnumber=zeros(1000,20);%根据实际情况,裂缝网格一般不会超过1000个,也可根据实际情况改变
%m=size(xink,1);
rownum=zeros(nf,1);
for i=1:nf
rownum(i)=size(fracturemesh{i,1},1);
end
%% 将所有裂缝面网格连起来一起编号,并将编号扔给相应的基质网格
q=1;
fracstart=zeros(nf+1,1);%这个表示在总编号中,每条裂缝起始的号码
for j=1:nf
fracstart(j)=q;
numofmesh=pointvsregion{j,1};
for i=1:1:rownum(j)
if(norm(fracturemesh{j,1}(i,:))~=0)
raoindice=size(fracturemesh{j,1}(i,:),2);
fracnumber(q,1:raoindice)=fracturemesh{j,1}(i,:);%q即是该裂缝编号
% m=floor((i+(2^nf)-1)/(2^nf));
m=floor((i+(2^addflag(j)-1))/(2^addflag(j)));
indice=find(matrixvsfra(numofmesh(m),:)~=0);
% indice=find(matrixvsfra(numofmesh(i),:)~=0);
if (size(indice,2)==0) xiang=1;
else
rao=max(indice');
xiang=rao(1)+1;
end
matrixvsfra(numofmesh(m),xiang)=q;%将裂缝编号附给相应的基质网格
q=q+1;
end
end
end
fracstart(nf+1)=q;%裂缝网格总数量+1
fracnumber(q:1000,:)=[];
%% 将包含有裂缝单元的基质网格筛选出来,并进行处理
m=size(matrixvsfra,1);
mat_frac=[];
connectmf=cell(1,4);
% for i=1:m
% if (norm(matrixvsfra(i,:))~=0)
% ConnecS = cell(1,4);
cc = 0;
cl = 1;
for i = 1 : m
%筛选出包含裂缝的基质网格
% if ~isempty(matrixvsfra(i,:))
if (norm(matrixvsfra(i,:)))~=0
cc = cc + 1;
%存储该基质网格编号
connectmf{cc,1} = i;
mat_frac=[mat_frac;i];
%给这些裂缝点/裂缝单元按顺序编号
A=matrixvsfra(i,:);
A(A==0)=[];
connectmf{cc,2} =A;
end
end
%% 一条条裂缝计算裂缝网格面积、边界等等
% edgevsfra=cell(nf,1);
% Kffl=funtion_data.Kffl;
% Dffl=funtion_data.Dffl;
% kffl=zeros(q-1,1);
% dffl=zeros(q-1,1);
normalvec=zeros(q-1,3);%unit 法向量
areavsfra=zeros(q-1,1);%q-1即裂缝网格总数
lengthvsfra=zeros(q-1,10);
Kf=zeros(q-1,1);%裂缝网格渗透率
Wf=zeros(q-1,1);%裂缝单元缝宽
corevsfra=zeros(q-1,3);
disvsfra=zeros(q-1,10);
tran=zeros(q-1,10);
avtran=zeros(q-1,1);%裂缝网格平均传导,用于后续的简化计算
ave_disvsfra=zeros(q-1,1);
fcinff=zeros(q-1,1);%表示裂缝单元所在的裂缝面序号
zf=zeros(q-1,1);%裂缝单元高度(以下表面为基准)
vf=zeros(q-1,1);%裂缝单元的体积
porf=zeros(q-1,1);%裂缝单元的孔隙度
avfracFaceArea = zeros(q-1,1);
for i=1:1:q-1 %对裂缝网格进行操作
if(norm(fracnumber(i,:))==0) break;
else
for k=2:(nf+1)
if(i<fracstart(k)) fcinff(i)=k-1; break;%判断该点处在哪个裂缝平面上,k-1号裂缝面
end
end
d3intersection=raopoint{k-1,1};
anothersection=raopoint{k-1,2};
fraindice=find(fracnumber(i,:)~=0);
rx=size(fraindice,2);
for j = 1:rx-1
corevsfra(i,:)=1/(rx-1)*d3intersection(fracnumber(i,j),:)+corevsfra(i,:);%计算每个裂缝网格重心的坐标
end
for j=1:1:(rx-1)
%edgevsfra(i,(4*j-3):(4*j))=[fracnumber(i,j),fracnumber(i,j+1),fracnumber(i,j+1),fracnumber(i,j)];%完成对edgevsfra矩阵赋值
%%因为是凸多边形,因此只要代表裂缝网格的两个行向量的共有元素有2个,即有公共边;
%如果多于2个,则是相同的裂缝网格;如果小于两个,则没有共有的边线
normalvec(i,:)=cross(f(5*(k-1)-3,:),f(5*(k-1)-2,:))/norm(cross(f(5*(k-1)-3,:),f(5*(k-1)-2,:)));
areavsfra(i)=area(anothersection(fracnumber(i,1:(rx-1))',:) ,f(5*(k-1)-3,:),f(5*(k-1)-2,:) );%计算出每个裂缝网格的面积
vf(i)=areavsfra(i)*wf(k-1);
porf(i)=Porf(k-1);
Kf(i,1)=kf(k-1);
Wf(i,1)=wf(k-1);
% kffl(i,1)=Kffl(k-1);
% dffl(i,1)=Dffl(k-1);
lengthvsfra(i,j)=norm(d3intersection(fracnumber(i,j+1),:)-d3intersection(fracnumber(i,j),:));%计算裂缝网格每条边的长度
zf(i)=corevsfra(i,3);%裂缝网格计算深度(以下平面为基准计算得到的高度,值为正数)
rao1=corevsfra(i,:)-d3intersection(fracnumber(i,j),:);
rao2=d3intersection(fracnumber(i,j+1),:)-d3intersection(fracnumber(i,j),:);
disvsfra(i,j)=norm(cross(rao1',rao2'))/norm(rao2);%计算出每个裂缝网格重心到每条边的距离
tran(i,j)=kf(k-1)*wf(k-1)*lengthvsfra(i,j)./disvsfra(i,j);
fracFaceArea(i,j)=wf(k-1)*lengthvsfra(i,j);
end
avtran(i)=sum(tran(i,:))/(rx-1);
ave_disvsfra(i)=sum(disvsfra(i,:))/(rx-1);
avfracFaceArea(i)=sum(fracFaceArea(i,:))/(rx-1);
end
end
% %% 生成裂缝单元及所在裂缝面的cell数组及其它形状信息
% fcff=cell(1,8);
% fcff{1,1}=fracnumber; fcff{1,2}=fcinff;fcff{1,3}=lengthvsfra;fcff{1,4}=corevsfra;fcff{1,5}=disvsfra;fcff{1,6}=tran;fcff{1,7}=avtran;fcff{1,8}=areavsfra;
%% 为了防止出现某裂缝网格面积相对过小,引起计算出错,故将面积很小的裂缝网格给去掉
maxarea=max(areavsfra,2);
% minlength=min(lengthvsfra,[],2);
% maxlength=max(lengthvsfra,[],2);
newnum=zeros(q-1,1);
[deindex1,~]=find(areavsfra<0*maxarea);
deindex2=[];
for i=1:(q-1)
zeroindex=find(lengthvsfra(i,:)~=0);
minlength=min(lengthvsfra(i,zeroindex));
maxlength=max(lengthvsfra(i,:));
if minlength<0*maxlength
deindex2=[deindex2;i];
end
end
deindex=[deindex1;deindex2];
deindex=unique(deindex);
deindex=sort(deindex);
hui=length(deindex);
if hui>0
for i=1:(q-1)
[dogindex,~]=find(deindex==i);
if length(dogindex)~=0
newnum(i)=0;
else
[catindex,~]=find(deindex<i);
rao=length(catindex);
newnum(i)=i-rao;
end
end
fracnumber(deindex,:)=[];
fcinff(deindex,:)=[];
lengthvsfra(deindex,:)=[];
corevsfra(deindex,:)=[];
disvsfra(deindex,:)=[];
tran(deindex,:)=[];
avtran(deindex,:)=[];
areavsfra(deindex,:)=[];
zf(deindex,:)=[];
vf(deindex,:)=[];
porf(deindex,:)=[];
% change matrixvsfra
for i=1:m%matrixvsfra矩阵的行数
for j=1:10
if matrixvsfra(i,j)~=0
matrixvsfra(i,j)=newnum(matrixvsfra(i,j));
end
end
end
% change fracstart
fracstart(nf+1,1)=length(fracnumber)+1;
for i=1:nf
[daiindex,~]=find(deindex<fracstart(i,1));
dai=length(daiindex);
fracstart(i)=fracstart(i)-dai;
end
end
%% 生成裂缝单元及所在裂缝面的cell数组及其它形状信息
fcff=cell(1,8);
fcff{1,1}=fracnumber; fcff{1,2}=fcinff;fcff{1,3}=lengthvsfra;fcff{1,4}=corevsfra;fcff{1,5}=disvsfra;fcff{1,6}=tran;fcff{1,7}=avtran;fcff{1,8}=areavsfra;
%% 裂缝单元的连接情况
%% 在同一裂缝面上,裂缝单元的连接情况及传导率计算(不包含在同一基质网格中的相邻裂缝单元)
connect_infrac=cell(nf,1);
Nff=zeros(1,2); %记录同一裂缝面上的网格相邻情况,第一列和第二列分别是相邻网格的编号
Tff=zeros(1,1); %记录相应的传导系数
Tff_convection=zeros(1,1); %对流项
perm_ff = zeros(1,1);
flowArea_ff = zeros(1,1);
for i=1:nf
p=1;
raoconnect=zeros(fracstart(i+1)-fracstart(i),10);%一般来说,裂缝网格不超过10条边
d3intersection=raopoint{i,1};
anothersection=raopoint{i,2};
for j=fracstart(i):((fracstart(i+1)-1)-1)%第i条裂缝的编号范围
q=1;
for k=j:(fracstart(i+1)-1)
A=fracnumber(j,:);
B=fracnumber(k,:);
%将两个向量很可能都有的0去掉,这个0没有什么意义
A(A==0)=[];
B(B==0)=[];
[a,~]=find(matrixvsfra==j); [b,~]=find(matrixvsfra==k);
if length(a)~=1
heihei=1;
end
raoflag=intersect(A,B);
if((size(raoflag,2)>2)||((size(raoflag,2)<2))) continue;%因为是凸多边形,因此只要代表裂缝网格的行向量的共有元素有2个,即有公共边;
%如果多于2个,则是相同的裂缝网格,因为如果不是,则必有一个是凹多边形,矛盾,证毕;如果小于两个,则没有共有的边线
else if (a==b) continue; %说明这两个裂缝单元在同一个基质网格中,因此不应该算在此类中
else
raoconnect(p,q)=k;q=q+1;
lengthcat=norm(d3intersection(raoflag(1),:)-d3intersection(raoflag(2),:));%计算裂缝单元公共边长度
rao1k=corevsfra(k,:)-d3intersection(raoflag(1),:);
rao1j=corevsfra(j,:)-d3intersection(raoflag(1),:);
rao2=d3intersection(raoflag(1),:)-d3intersection(raoflag(2),:);
%分别计算两裂缝单元中心到公共边的距离
disk=norm(cross(rao1k',rao2'))/norm(rao2);
disj=norm(cross(rao1j',rao2'))/norm(rao2);
if kf(i)==0
hartran=0;hartran_convection=0;
kij = 0;
else
tran1=kf(i)*wf(i)*lengthcat/disk;
tran2=kf(i)*wf(i)*lengthcat/disj;
% hartran=length/(disk+disj);%取调和平均
hartran=tran1*tran2/(tran1+tran2);
k_harmony= kf(i);
hartran_convection=kf(i)/(disk+disj)^2;
kij = 2*(Kf(j)^(-1)+Kf(k)^(-1))^(-1);
end
Nff=[Nff; j,k];
Tff=[Tff;hartran];
Tff_convection=[Tff_convection;hartran_convection];
perm_ff = [perm_ff; kij];
flowArea_ff = [flowArea_ff; wf(i)*lengthcat];
%计算出每个裂缝网格重心到每条边的距离
end
end
p=p+1;
end
connect_infrac{i,1}=raoconnect;
end
end
Nff(1,:)=[]; %去除第一行的零行
Tff(1,:)=[];
Tff_convection(1,:)=[];
perm_ff(1,:)=[];
flowArea_ff(1,:)=[];
%% 在同一基质网格中的裂缝单元连接情况及传导率计算
nmc=size(matrixvsfra,1);
Nmff=zeros(1,2);
Tmff=zeros(1,1);
Tmff_convection=zeros(1,1);
perm_mff=zeros(1,1);
flowArea_mff=zeros(1,1);
for i=1:nmc
if(norm(matrixvsfra(i,:))~=0)
indice=find(matrixvsfra(i,:)~=0);
n=size(indice,2);
if (n>1) %此时表明要采取下述的简化算法
% lengthvsfra(matrixvsfra(i,indice))./disvsfra(matrixvsfra(i,indice))
for j=1:n-1
for k=(j+1):n
Nmff=[Nmff;matrixvsfra(i,indice(j)), matrixvsfra(i,indice(k))];
% 此时的计算方式是先求每个裂缝网格的算术平均,再算包含在该基质网格中的所有裂缝单元的算术平均
fc1=matrixvsfra(i,indice(j)); fc2=matrixvsfra(i,indice(k));
allfc=matrixvsfra(i,1:n); sumtran=sum(fcff{1,7}(allfc));
if sumtran==0
Tmff=[Tmff; 0];Tmff_convection=[Tmff_convection;0];
perm_mff=[perm_mff;0];flowArea_mff=[flowArea_mff;(avfracFaceArea(fc1)+avfracFaceArea(fc2))/2];
else
Tmff=[Tmff; fcff{1,7}(fc1)*fcff{1,7}(fc2)/sumtran];
perm_mff=[perm_mff;(Kf(fc1)^(-1)+Kf(fc2)^(-1))^(-1)];
flowArea_mff=[flowArea_mff;(avfracFaceArea(fc1)+avfracFaceArea(fc2))/2];
end
end
end
end
end
end
Nmff(1,:)=[]; %去掉开头的零行
Tmff(1,:)=[];
% Tmff =Tmff*0;
Tmff_convection(1,:)=[];
perm_mff(1,:)=[];
flowArea_mff(1,:)=[];
% N = [N; Nmff+nmc];
% T = [T; Tmff];
%% 基质网格的连接情况及传导系数计算
nmc= nx * ny*nz;%基质网格数目
nfc=size(fracnumber,1);%裂缝单元数目
rpt = [ones(nmc, 1); zeros(nfc, 1)];
% r.rpt = rpt;
nmm = (nx-1)*ny*nz+(ny-1)*nx*nz+(nz-1)*nx*ny;%nmm是基质网格之间存在流体交换的总数
% r.nf = nmm + nff;%nff是裂缝单元之间存在流体交换的总数
Kx=kx.*ones(nmc,1);
Ky=ky.*ones(nmc,1);
Kz=kz.*ones(nmc,1);
N = zeros(nmm, 2);%存储基质网格之间存在流体交换的网格编号
T = zeros(nmm, 1);%存储对应与N矩阵的传导系数
T_convection = zeros(nmm, 1);
perm = zeros(nmm, 1);
flowArea = zeros(nmm, 1);
c = 0;
for k= 1 : nz
for j = 1 : ny
for i = 1 : nx - 1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + 1;
N(c, :) = [index, indexn];
T(c) = 2 * dzv(index)*dyv(index)*Kx(index)*Kx(indexn)*NTG(index)*NTG(indexn)/(Kx(index)*dxv(indexn)*NTG(index) + Kx(indexn)*dxv(index)*NTG(indexn));
T_convection(c) = 2/(1/Kx(index)+1/Kx(indexn))/(dxv(indexn)+dxv(index));
perm(c)=2*Kx(index)*Kx(indexn)/(Kx(index) + Kx(indexn));
flowArea(c)=dzv(index)*dyv(index);
end
end
end
for k= 1 : nz
for i = 1 : nx
for j = 1 : ny - 1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nx;
N(c, :) = [index, indexn];
T(c) = 2 * dzv(index)*dxv(index)*Ky(index)*Ky(indexn)/(Ky(index)*dyv(indexn) + Ky(indexn)*dyv(index));
T_convection(c) = 2/(1/Ky(index)+1/Ky(indexn))/(dyv(indexn)+dyv(index));
perm(c)=2*Ky(index)*Ky(indexn)/(Ky(index) + Ky(indexn));
flowArea(c)=dzv(index)*dxv(index);
end
end
end
for i = 1 : nx
for j = 1 : ny
for k= 1: nz-1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nx * ny;
N(c, :) = [index, index + nx*ny];
T(c) = 2 * dxv(index)*dyv(index)*Kz(index)*Kz(indexn)/(Kz(index)*dzv(indexn) + Kz(indexn)*dzv(index));
T_convection(c) = 2/(1/Kz(index)+1/Kz(indexn))/(dzv(indexn)+dzv(index));
perm(c)=2*Kz(index)*Kz(indexn)/(Kz(index) + Kz(indexn));
flowArea(c)=dxv(index)*dyv(index);
end
end
end
%% 双重介质处理
%% 基质网格的连接情况及传导系数计算
nmc= nx * ny*nz;%基质网格数目
nfc=size(fracnumber,1);%裂缝单元数目
rpt = [ones(nmc, 1); ones(nmc, 1); zeros(nfc, 1)];
% r.rpt = rpt;
nmm = (nx-1)*ny*nz+(ny-1)*nx*nz+(nz-1)*nx*ny;%nmm是基质网格之间存在流体交换的总数
% r.nf = nmm + nff;%nff是裂缝单元之间存在流体交换的总数
Kx_matrixLayer=kx_matrixLayer.*ones(nmc,1);
Ky_matrixLayer=ky_matrixLayer.*ones(nmc,1);
Kz_matrixLayer=kz_matrixLayer.*ones(nmc,1);
N_matrixLayer = zeros(nmm, 2);%
T_matrixLayer = zeros(nmm, 1);%
T_convection_matrixLayer = zeros(nmm, 1);
perm_matrixLayer = zeros(nmm, 1);
flowArea_matrixLayer = zeros(nmm, 1);
c = 0;
for k= 1 : nz
for j = 1 : ny
for i = 1 : nx - 1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + 1;
N_matrixLayer(c, :) = [index, indexn];
T_matrixLayer(c) = 2 * dzv(index)*dyv(index)*Kx_matrixLayer(index)*Kx_matrixLayer(indexn)*NTG(index)*NTG(indexn)/(Kx_matrixLayer(index)*dxv(indexn)*NTG(index) + Kx_matrixLayer(indexn)*dxv(index)*NTG(indexn));
T_convection_matrixLayer(c) = 2/(1/Kx_matrixLayer(index)+1/Kx_matrixLayer(indexn))/(dxv(indexn)+dxv(index));
perm_matrixLayer(c)=2*Kx_matrixLayer(index)*Kx_matrixLayer(indexn)/(Kx_matrixLayer(index) + Kx_matrixLayer(indexn));
flowArea_matrixLayer(c)=dzv(index)*dyv(index);
end
end
end
for k= 1 : nz
for i = 1 : nx
for j = 1 : ny - 1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nx;
N_matrixLayer(c, :) = [index, indexn];
T_matrixLayer(c) = 2 * dzv(index)*dxv(index)*Ky_matrixLayer(index)*Ky_matrixLayer(indexn)/(Ky_matrixLayer(index)*dyv(indexn) + Ky_matrixLayer(indexn)*dyv(index));
T_convection_matrixLayer(c) = 2/(1/Ky_matrixLayer(index)+1/Ky_matrixLayer(indexn))/(dyv(indexn)+dyv(index));
perm_matrixLayer(c)=2*Ky_matrixLayer(index)*Ky_matrixLayer(indexn)/(Ky_matrixLayer(index) + Ky_matrixLayer(indexn));
flowArea_matrixLayer(c)=dzv(index)*dxv(index);
end
end
end
for i = 1 : nx
for j = 1 : ny
for k= 1: nz-1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nx * ny;
N_matrixLayer(c, :) = [index, index + nx*ny];
T_matrixLayer(c) = 2 * dxv(index)*dyv(index)*Kz_matrixLayer(index)*Kz_matrixLayer(indexn)/(Kz_matrixLayer(index)*dzv(indexn) + Kz_matrixLayer(indexn)*dzv(index));
T_convection_matrixLayer(c) = 2/(1/Kz_matrixLayer(index)+1/Kz_matrixLayer(indexn))/(dzv(indexn)+dzv(index));
perm_matrixLayer(c)=2*Kz_matrixLayer(index)*Kz_matrixLayer(indexn)/(Kz_matrixLayer(index) + Kz_matrixLayer(indexn));
flowArea_matrixLayer(c)=dxv(index)*dyv(index);
end
end
end
%% 构建基质层网格与裂缝层网格间的连接
N_fractureMatrixLayer = zeros(nmc, 2);%
T_fractureMatrixLayer = zeros(nmc, 1);%
T_convection_fractureMatrixLayer = zeros(nmc, 1);
perm_fractureMatrixLayer = zeros(nmc, 1);
flowArea_fractureMatrixLayer = zeros(nmc, 1);
for k= 1 : nz
for j = 1 : ny
for i = 1 : nx - 1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nmc;
N_fractureMatrixLayer(c, :) = [index, indexn];
T_fractureMatrixLayer(c) = dzv(index)*dyv(index)*dxv(index)*Kx(index)*sigma(c);
T_convection_fractureMatrixLayer(c) = 2/(1/Kx_matrixLayer(index)+1/Kx_matrixLayer(indexn));
perm_fractureMatrixLayer(c)=2*Kx_matrixLayer(index)*Kx_matrixLayer(indexn)/(Kx_matrixLayer(index) + Kx_matrixLayer(indexn));
flowArea_fractureMatrixLayer(c)=dzv(index)*dyv(index);
end
end
end
%% 按照2014年的方法,将窜流处理为与上述相似的形式
syms x y z;
Ninterflow=[];
Tinterflow=[];
Tinterflow_convection=[];
cell_divided_by_fracture_flag = [];
perm_interflow=[];
flowArea_interflow=[];
for i=1:nx*ny*nz %基质网格编号
flag = 0;
for j=1:10
if matrixvsfra(i,j)~=0 %this matrix cell contains a fracture cell
flag = flag + 1;
Ninterflow=[Ninterflow;i,matrixvsfra(i,j)+nmc];
kcell=(kx(i)*ky(i)*kz(i))^(1/3);
% kcell = sqrt(10*100)*1e-3;
Knnc=kcell*Kf(matrixvsfra(i,j))/(kcell+Kf(matrixvsfra(i,j)));
Annc=areavsfra(matrixvsfra(i,j));
fracore=corevsfra(matrixvsfra(i,j),:);
matnodes=nodes(i,:);
verco=coord(matnodes,:);norvec=normalvec(matrixvsfra(i,j),:);
matcore=mean(verco);d0=matcore-fracore;
dn=(x+d0(1))*norvec(1)+(y+d0(2))*norvec(2)+(z+d0(3))*norvec(3);
% dn=abs(dn);%影响数值积分效率
dn=sqrt(dn^2);
dn=matlabFunction(dn);
if norvec(1)~=0 && norvec(2)~=0 && norvec(3)~=0
Dn=integral3(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(1)~=0 && norvec(2)~=0
Dn=dzv(i)*NTG(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(1)~=0 && norvec(3)~=0
Dn=dyv(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(2)~=0 && norvec(3)~=0
Dn=dxv(i)*integral2(dn,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(1)~=0
Dn=dyv(i)*dzv(i)*NTG(i)*integral(dn,-dxv(i)/2,dxv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(2)~=0
Dn=dxv(i)*dzv(i)*NTG(i)*integral(dn,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(3)~=0
Dn=dxv(i)*dyv(i)*integral(dn,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
end
end
end
end
end
end
end
% raoT=Knnc*Annc/Dn;
% raoT_convection=2*Knnc/Dn^2;
% Tinterflow=[Tinterflow;raoT];
% Tinterflow_convection=[Tinterflow_convection;raoT_convection];
raoT1 = 2*kcell*Annc/Dn;
raoT2 = Kf(matrixvsfra(i,j))*Annc/(Wf(matrixvsfra(i,j))/2);
raoT = (raoT1^-1+raoT2^-1)^-1;
Tinterflow=[Tinterflow;raoT];
raoT1_conv = kcell/Dn^2;
raoT2_conv = Kf(matrixvsfra(i,j))/(Wf(matrixvsfra(i,j))/2)^2;
raoT_convection = (raoT1_conv^-1+raoT2_conv^-1)^-1;
Tinterflow_convection=[Tinterflow_convection;raoT_convection];
perm_mf_this = kcell*Kf(matrixvsfra(i,j))/(kcell+Kf(matrixvsfra(i,j)));
perm_interflow = [perm_interflow; perm_mf_this];
flowArea_interflow = [flowArea_interflow; Annc];
end
end
if flag >0
cell_divided_by_fracture_flag = [cell_divided_by_fracture_flag; i];
end
end
%% 按照2014年的方法,将窜流处理为与上述相似的形式
% syms x y z;
% Ninterflow=[];
% Tinterflow=[];
% for i=1:nx*ny*nz %基质网格编号
% for j=1:10
% if matrixvsfra(i,j)~=0 %this matrix cell contains a fracture cell
% Ninterflow=[Ninterflow;i,matrixvsfra(i,j)+nmc];
% kcell=(kx(i)*ky(i)*kz(i))^(1/3);
% K1=Kf(matrixvsfra(i,j));d1=Wf(matrixvsfra(i,j));
% K2=kffl(matrixvsfra(i,j));d2=dffl(matrixvsfra(i,j));
% Annc=2*areavsfra(matrixvsfra(i,j));
% fracore=corevsfra(matrixvsfra(i,j),:);
% matnodes=nodes(i,:);
% verco=coord(matnodes,:);norvec=normalvec(matrixvsfra(i,j),:);
% matcore=mean(verco);d0=matcore-fracore;
% dn=(x+d0(1))*norvec(1)+(y+d0(2))*norvec(2)+(z+d0(3))*norvec(3);
% % dn=abs(dn);%影响数值积分效率
% dn=sqrt(dn^2);
% dn=matlabFunction(dn);
% if norvec(1)~=0 && norvec(2)~=0 && norvec(3)~=0
% Dn=integral3(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(1)~=0 && norvec(2)~=0
% Dn=dzv(i)*NTG(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(1)~=0 && norvec(3)~=0
% Dn=dyv(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(2)~=0 && norvec(3)~=0
% Dn=dxv(i)*integral2(dn,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(1)~=0
% Dn=dyv(i)*dzv(i)*NTG(i)*integral(dn,-dxv(i)/2,dxv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(2)~=0
% Dn=dxv(i)*dzv(i)*NTG(i)*integral(dn,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(3)~=0
% Dn=dxv(i)*dyv(i)*integral(dn,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% end
% end
% end
% end
% end
% end
% end
% raoT=((Kcell*Annc/(Dn-d2))^(-1)+(K2*Annc/d2)^(-1)+(K1*Annc/d1)^(-1))^(-1);
% Tinterflow=[Tinterflow;raoT];
% end
% end
% end
%% 双重介质处理
%% 把上述三种情况的矩阵分别叠加起来
matrixflag = [ones(size(T,1),1); zeros(size(Tmff,1),1); zeros(size(Tff,1),1); ones(size(Tinterflow,1),1);];
N = [N; Nmff+nmc; Nff+nmc;Ninterflow;];
T = [T; Tmff; Tff;Tinterflow;];
T_convection = [T_convection;Tmff_convection; Tff_convection;Tinterflow_convection;];
perm = [perm; perm_mff; perm_ff;perm_interflow; ];
flowArea = [flowArea; flowArea_mff; flowArea_ff;flowArea_interflow;];
nex=size(N,1);
%% 转到CMG或者ECLIPSE进行计算
% [ Data_for_ECLIPSE ] = pEDFM_to_CMG_horizontalFractureWell(dxv,dyv,dzv,kx,ky,kz,pori,Kf,Wf,vf,porf,N,T);
% [ Data_for_ECLIPSE ] = pEDFM_to_CMG_horizontalFractureWell_net_pay(dxv,dyv,dzv,kx,ky,kz,pori,Kf,Wf,vf,porf,N,T);
end
@@ -0,0 +1,625 @@
function [ matrixvsfra,connectmf,fracnumber,fracstart,corevsfra,connect_infrac,N,T,zf,fcinff,vf,porf,fcff,T_convection,mat_frac,cell_divided_by_fracture_flag, flowArea, perm, matrixflag, T_diff] = connections_2014( fracturemesh,pointvsregion,raopoint,f,nf,nx,ny,nz,kx,ky,kz, kx_matrixLayer, ky_matrixLayer, kz_matrixLayer, pori, pori_matrixLayer,kf,wf,Porf,dxv,dyv,dzv,coord,nodes,NTG,sigma,addflag,invalid_grids )
%
%
%
%connections
%:xink矩阵去掉零行后
%:
%:
%matrixvsfra矩阵代表基质网格中包含裂缝网格编号的情况
%fracnumber矩阵
%areavsfra矩阵
%
%lengthvsfra矩阵
%corevsfra矩阵
%disvsfra矩阵
matrixvsfra=zeros(nx*ny*nz,10);%10
fracnumber=zeros(1000,20);%1000
%m=size(xink,1);
rownum=zeros(nf,1);
for i=1:nf
rownum(i)=size(fracturemesh{i,1},1);
end
%%
q=1;
fracstart=zeros(nf+1,1);%
for j=1:nf
fracstart(j)=q;
numofmesh=pointvsregion{j,1};
for i=1:1:rownum(j)
if(norm(fracturemesh{j,1}(i,:))~=0)
raoindice=size(fracturemesh{j,1}(i,:),2);
fracnumber(q,1:raoindice)=fracturemesh{j,1}(i,:);%q即是该裂缝编号
% m=floor((i+(2^nf)-1)/(2^nf));
m=floor((i+(2^addflag(j)-1))/(2^addflag(j)));
indice=find(matrixvsfra(numofmesh(m),:)~=0);
% indice=find(matrixvsfra(numofmesh(i),:)~=0);
if (size(indice,2)==0) xiang=1;
else
rao=max(indice');
xiang=rao(1)+1;
end
matrixvsfra(numofmesh(m),xiang)=q;%
q=q+1;
end
end
end
fracstart(nf+1)=q;%+1
fracnumber(q:1000,:)=[];
%% ,
m=size(matrixvsfra,1);
mat_frac=[];
connectmf=cell(1,4);
% for i=1:m
% if (norm(matrixvsfra(i,:))~=0)
% ConnecS = cell(1,4);
cc = 0;
cl = 1;
for i = 1 : m
%
% if ~isempty(matrixvsfra(i,:))
if (norm(matrixvsfra(i,:)))~=0
cc = cc + 1;
%
connectmf{cc,1} = i;
mat_frac=[mat_frac;i];
%/
A=matrixvsfra(i,:);
A(A==0)=[];
connectmf{cc,2} =A;
end
end
%%
% edgevsfra=cell(nf,1);
% Kffl=funtion_data.Kffl;
% Dffl=funtion_data.Dffl;
% kffl=zeros(q-1,1);
% dffl=zeros(q-1,1);
normalvec=zeros(q-1,3);%unit
areavsfra=zeros(q-1,1);%q-1
lengthvsfra=zeros(q-1,10);
Kf=zeros(q-1,1);%
Wf=zeros(q-1,1);%
corevsfra=zeros(q-1,3);
disvsfra=zeros(q-1,10);
tran=zeros(q-1,10);
tran_no_perm=zeros(q-1,10);
avtran=zeros(q-1,1);%
ave_disvsfra=zeros(q-1,1);
fcinff=zeros(q-1,1);%
zf=zeros(q-1,1);%
vf=zeros(q-1,1);%
porf=zeros(q-1,1);%
avfracFaceArea = zeros(q-1,1);
for i=1:1:q-1 %
if(norm(fracnumber(i,:))==0) break;
else
for k=2:(nf+1)
if(i<fracstart(k)) fcinff(i)=k-1; break;%,k-1
end
end
d3intersection=raopoint{k-1,1};
anothersection=raopoint{k-1,2};
fraindice=find(fracnumber(i,:)~=0);
rx=size(fraindice,2);
for j = 1:rx-1
corevsfra(i,:)=1/(rx-1)*d3intersection(fracnumber(i,j),:)+corevsfra(i,:);%
end
for j=1:1:(rx-1)
%edgevsfra(i,(4*j-3):(4*j))=[fracnumber(i,j),fracnumber(i,j+1),fracnumber(i,j+1),fracnumber(i,j)];%edgevsfra矩阵赋值
%%2
%2线
normalvec(i,:)=cross(f(5*(k-1)-3,:),f(5*(k-1)-2,:))/norm(cross(f(5*(k-1)-3,:),f(5*(k-1)-2,:)));
areavsfra(i)=area(anothersection(fracnumber(i,1:(rx-1))',:) ,f(5*(k-1)-3,:),f(5*(k-1)-2,:) );%
vf(i)=areavsfra(i)*wf(k-1);
porf(i)=Porf(k-1);
Kf(i,1)=kf(k-1);
Wf(i,1)=wf(k-1);
% kffl(i,1)=Kffl(k-1);
% dffl(i,1)=Dffl(k-1);
lengthvsfra(i,j)=norm(d3intersection(fracnumber(i,j+1),:)-d3intersection(fracnumber(i,j),:));%
zf(i)=corevsfra(i,3);%
rao1=corevsfra(i,:)-d3intersection(fracnumber(i,j),:);
rao2=d3intersection(fracnumber(i,j+1),:)-d3intersection(fracnumber(i,j),:);
disvsfra(i,j)=norm(cross(rao1',rao2'))/norm(rao2);%
tran(i,j)=kf(k-1)*wf(k-1)*lengthvsfra(i,j)./disvsfra(i,j);
tran_no_perm(i,j)=wf(k-1)*lengthvsfra(i,j)./disvsfra(i,j);
fracFaceArea(i,j)=wf(k-1)*lengthvsfra(i,j);
end
avtran(i)=sum(tran(i,:))/(rx-1);
ave_disvsfra(i)=sum(disvsfra(i,:))/(rx-1);
avfracFaceArea(i)=sum(fracFaceArea(i,:))/(rx-1);
end
end
% %% cell数组及其它形状信息
% fcff=cell(1,8);
% fcff{1,1}=fracnumber; fcff{1,2}=fcinff;fcff{1,3}=lengthvsfra;fcff{1,4}=corevsfra;fcff{1,5}=disvsfra;fcff{1,6}=tran;fcff{1,7}=avtran;fcff{1,8}=areavsfra;
%%
maxarea=max(areavsfra,2);
% minlength=min(lengthvsfra,[],2);
% maxlength=max(lengthvsfra,[],2);
newnum=zeros(q-1,1);
[deindex1,~]=find(areavsfra<0*maxarea);
deindex2=[];
for i=1:(q-1)
zeroindex=find(lengthvsfra(i,:)~=0);
minlength=min(lengthvsfra(i,zeroindex));
maxlength=max(lengthvsfra(i,:));
if minlength<0*maxlength
deindex2=[deindex2;i];
end
end
deindex=[deindex1;deindex2];
deindex=unique(deindex);
deindex=sort(deindex);
hui=length(deindex);
if hui>0
for i=1:(q-1)
[dogindex,~]=find(deindex==i);
if length(dogindex)~=0
newnum(i)=0;
else
[catindex,~]=find(deindex<i);
rao=length(catindex);
newnum(i)=i-rao;
end
end
fracnumber(deindex,:)=[];
fcinff(deindex,:)=[];
lengthvsfra(deindex,:)=[];
corevsfra(deindex,:)=[];
disvsfra(deindex,:)=[];
tran(deindex,:)=[];
avtran(deindex,:)=[];
areavsfra(deindex,:)=[];
zf(deindex,:)=[];
vf(deindex,:)=[];
porf(deindex,:)=[];
% change matrixvsfra
for i=1:m%matrixvsfra矩阵的行数
for j=1:10
if matrixvsfra(i,j)~=0
matrixvsfra(i,j)=newnum(matrixvsfra(i,j));
end
end
end
% change fracstart
fracstart(nf+1,1)=length(fracnumber)+1;
for i=1:nf
[daiindex,~]=find(deindex<fracstart(i,1));
dai=length(daiindex);
fracstart(i)=fracstart(i)-dai;
end
end
%% cell数组及其它形状信息
fcff=cell(1,8);
fcff{1,1}=fracnumber; fcff{1,2}=fcinff;fcff{1,3}=lengthvsfra;fcff{1,4}=corevsfra;fcff{1,5}=disvsfra;fcff{1,6}=tran;fcff{1,7}=avtran;fcff{1,8}=areavsfra;
%%
%% (
connect_infrac=cell(nf,1);
Nff=zeros(1,2); %
Tff=zeros(1,1); %
Tff_convection=zeros(1,1); %
Tff_diff=zeros(1,1);
perm_ff = zeros(1,1);
flowArea_ff = zeros(1,1);
for i=1:nf
p=1;
raoconnect=zeros(fracstart(i+1)-fracstart(i),10);%10
d3intersection=raopoint{i,1};
anothersection=raopoint{i,2};
for j=fracstart(i):((fracstart(i+1)-1)-1)%i条裂缝的编号范围
q=1;
for k=j:(fracstart(i+1)-1)
A=fracnumber(j,:);
B=fracnumber(k,:);
%00
A(A==0)=[];
B(B==0)=[];
[a,~]=find(matrixvsfra==j); [b,~]=find(matrixvsfra==k);
if length(a)~=1
heihei=1;
end
raoflag=intersect(A,B);
if((size(raoflag,2)>2)||((size(raoflag,2)<2))) continue;%2
%2线
else if (a==b) continue; %
else
raoconnect(p,q)=k;q=q+1;
lengthcat=norm(d3intersection(raoflag(1),:)-d3intersection(raoflag(2),:));%
rao1k=corevsfra(k,:)-d3intersection(raoflag(1),:);
rao1j=corevsfra(j,:)-d3intersection(raoflag(1),:);
rao2=d3intersection(raoflag(1),:)-d3intersection(raoflag(2),:);
%
disk=norm(cross(rao1k',rao2'))/norm(rao2);
disj=norm(cross(rao1j',rao2'))/norm(rao2);
if kf(i)==0
hartran=0;hartran_convection=0;
kij = 0;
else
tran1=kf(i)*wf(i)*lengthcat/disk;
tran2=kf(i)*wf(i)*lengthcat/disj;
% hartran=length/(disk+disj);%
hartran=tran1*tran2/(tran1+tran2);
tran1_diff=wf(i)*lengthcat/disk;
tran2_diff=wf(i)*lengthcat/disj;
% hartran=length/(disk+disj);%
hartran_diff=tran1_diff*tran2_diff/(tran1_diff+tran2_diff);
k_harmony= kf(i);
hartran_convection=kf(i)/(disk+disj)^2;
kij = 2*(Kf(j)^(-1)+Kf(k)^(-1))^(-1);
end
Nff=[Nff; j,k];
Tff=[Tff;hartran];
Tff_diff=[Tff_diff;hartran_diff];
Tff_convection=[Tff_convection;hartran_convection];
perm_ff = [perm_ff; kij];
flowArea_ff = [flowArea_ff; wf(i)*lengthcat];
%
end
end
p=p+1;
end
connect_infrac{i,1}=raoconnect;
end
end
Nff(1,:)=[]; %
Tff(1,:)=[];
Tff_convection(1,:)=[];
Tff_diff(1,:)=[];
perm_ff(1,:)=[];
flowArea_ff(1,:)=[];
%%
nmc=size(matrixvsfra,1);
Nmff=zeros(1,2);
Tmff=zeros(1,1);
Tmff_diff=zeros(1,1);
Tmff_convection=zeros(1,1);
perm_mff=zeros(1,1);
flowArea_mff=zeros(1,1);
for i=1:nmc
if(norm(matrixvsfra(i,:))~=0)
indice=find(matrixvsfra(i,:)~=0);
n=size(indice,2);
if (n>1) %
% lengthvsfra(matrixvsfra(i,indice))./disvsfra(matrixvsfra(i,indice))
for j=1:n-1
for k=(j+1):n
Nmff=[Nmff;matrixvsfra(i,indice(j)), matrixvsfra(i,indice(k))];
%
fc1=matrixvsfra(i,indice(j)); fc2=matrixvsfra(i,indice(k));
allfc=matrixvsfra(i,1:n); sumtran=sum(fcff{1,7}(allfc));sumtran_no_perm=sum(fcff{1,9}(allfc));
if sumtran==0
Tmff=[Tmff; 0];Tmff_convection=[Tmff_convection;0];
Tmff_diff=[Tmff_diff;0];
perm_mff=[perm_mff;0];flowArea_mff=[flowArea_mff;(avfracFaceArea(fc1)+avfracFaceArea(fc2))/2];
else
Tmff=[Tmff; fcff{1,7}(fc1)*fcff{1,7}(fc2)/sumtran];
Tmff_diff=[Tmff_diff;fcff{1,9}(fc1)*fcff{1,9}(fc2)/sumtran_no_perm];
perm_mff=[perm_mff;(Kf(fc1)^(-1)+Kf(fc2)^(-1))^(-1)];
flowArea_mff=[flowArea_mff;(avfracFaceArea(fc1)+avfracFaceArea(fc2))/2];
end
end
end
end
end
end
Nmff(1,:)=[]; %
Tmff(1,:)=[];
% Tmff =Tmff*0;
Tmff_convection(1,:)=[];
Tmff_diff(1,:)=[];
perm_mff(1,:)=[];
flowArea_mff(1,:)=[];
% N = [N; Nmff+nmc];
% T = [T; Tmff];
%%
nmc= nx * ny*nz;%
nfc=size(fracnumber,1);%
rpt = [ones(nmc, 1); zeros(nfc, 1)];
% r.rpt = rpt;
nmm = (nx-1)*ny*nz+(ny-1)*nx*nz+(nz-1)*nx*ny;%nmm是基质网格之间存在流体交换的总数
% r.nf = nmm + nff;%nff是裂缝单元之间存在流体交换的总数
Kx=kx.*ones(nmc,1);
Ky=ky.*ones(nmc,1);
Kz=kz.*ones(nmc,1);
N = zeros(nmm, 2);%
T = zeros(nmm, 1);%N矩阵的传导系数
T_convection = zeros(nmm, 1);
T_diff = zeros(nmm, 1);
perm = zeros(nmm, 1);
flowArea = zeros(nmm, 1);
c = 0;
for k= 1 : nz
for j = 1 : ny
for i = 1 : nx - 1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + 1;
N(c, :) = [index, indexn];
T(c) = 2 * dzv(index)*dyv(index)*Kx(index)*Kx(indexn)*NTG(index)*NTG(indexn)/(Kx(index)*dxv(indexn)*NTG(index) + Kx(indexn)*dxv(index)*NTG(indexn));
T_convection(c) = 2/(1/Kx(index)+1/Kx(indexn))/(dxv(indexn)+dxv(index));
perm(c)=2*Kx(index)*Kx(indexn)/(Kx(index) + Kx(indexn));
T_diff(c)=dzv(index)*dyv(index)/(2/(1/dxv(indexn)+1/dxv(index)));
flowArea(c)=dzv(index)*dyv(index);
end
end
end
for k= 1 : nz
for i = 1 : nx
for j = 1 : ny - 1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nx;
N(c, :) = [index, indexn];
T(c) = 2 * dzv(index)*dxv(index)*Ky(index)*Ky(indexn)/(Ky(index)*dyv(indexn) + Ky(indexn)*dyv(index));
T_convection(c) = 2/(1/Ky(index)+1/Ky(indexn))/(dyv(indexn)+dyv(index));
perm(c)=2*Ky(index)*Ky(indexn)/(Ky(index) + Ky(indexn));
T_diff(c)=dzv(index)*dxv(index)/(2/(1/dyv(indexn)+1/dyv(index)));
flowArea(c)=dzv(index)*dxv(index);
end
end
end
for i = 1 : nx
for j = 1 : ny
for k= 1: nz-1
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nx * ny;
N(c, :) = [index, index + nx*ny];
T(c) = 2 * dxv(index)*dyv(index)*Kz(index)*Kz(indexn)/(Kz(index)*dzv(indexn) + Kz(indexn)*dzv(index));
T_convection(c) = 2/(1/Kz(index)+1/Kz(indexn))/(dzv(indexn)+dzv(index));
perm(c)=2*Kz(index)*Kz(indexn)/(Kz(index) + Kz(indexn));
T_diff(c)=dxv(index)*dyv(index)/(2/(1/dzv(indexn)+1/dzv(index)));
flowArea(c)=dxv(index)*dyv(index);
end
end
end
%%
%%
N_matrixLayer = [];%
T_matrixLayer = [];%
T_convection_matrixLayer = [];
T_diff_matrixLayer = [];
perm_matrixLayer = [];
flowArea_matrixLayer = [];
% % % nmc= nx * ny*nz;%
% % % nfc=size(fracnumber,1);%
% % % rpt = [ones(nmc, 1); ones(nmc, 1); zeros(nfc, 1)];
% % % % r.rpt = rpt;
% % % nmm = (nx-1)*ny*nz+(ny-1)*nx*nz+(nz-1)*nx*ny;%nmm是基质网格之间存在流体交换的总数
% % % % r.nf = nmm + nff;%nff是裂缝单元之间存在流体交换的总数
% % % Kx_matrixLayer=kx_matrixLayer.*ones(nmc,1);
% % % Ky_matrixLayer=ky_matrixLayer.*ones(nmc,1);
% % % Kz_matrixLayer=kz_matrixLayer.*ones(nmc,1);
% % % N_matrixLayer = zeros(nmm, 2);%
% % % T_matrixLayer = zeros(nmm, 1);%
% % % T_convection_matrixLayer = zeros(nmm, 1);
% % % T_diff_matrixLayer = zeros(nmm, 1);
% % % perm_matrixLayer = zeros(nmm, 1);
% % % flowArea_matrixLayer = zeros(nmm, 1);
% % % c = 0;
% % % for k= 1 : nz
% % % for j = 1 : ny
% % % for i = 1 : nx - 1
% % % c = c + 1;
% % % index = i + (j - 1) * nx + (k - 1) * nx * ny;
% % % indexn = index + 1;
% % % N_matrixLayer(c, :) = [index+nmc, indexn+nmc];
% % % T_matrixLayer(c) = 2 * dzv(index)*dyv(index)*Kx_matrixLayer(index)*Kx_matrixLayer(indexn)*NTG(index)*NTG(indexn)/(Kx_matrixLayer(index)*dxv(indexn)*NTG(index) + Kx_matrixLayer(indexn)*dxv(index)*NTG(indexn));
% % % T_convection_matrixLayer(c) = 2/(1/Kx_matrixLayer(index)+1/Kx_matrixLayer(indexn))/(dxv(indexn)+dxv(index));
% % % perm_matrixLayer(c)=2*Kx_matrixLayer(index)*Kx_matrixLayer(indexn)/(Kx_matrixLayer(index) + Kx_matrixLayer(indexn));
% % % T_diff_matrixLayer(c)=dzv(index)*dyv(index)/(2/(1/dxv(indexn)+1/dxv(index)));
% % % flowArea_matrixLayer(c)=dzv(index)*dyv(index);
% % % end
% % % end
% % % end
% % %
% % % for k= 1 : nz
% % % for i = 1 : nx
% % % for j = 1 : ny - 1
% % % c = c + 1;
% % % index = i + (j - 1) * nx + (k - 1) * nx * ny;
% % % indexn = index + nx;
% % % N_matrixLayer(c, :) = [index+nmc, indexn+nmc];
% % % T_matrixLayer(c) = 2 * dzv(index)*dxv(index)*Ky_matrixLayer(index)*Ky_matrixLayer(indexn)/(Ky_matrixLayer(index)*dyv(indexn) + Ky_matrixLayer(indexn)*dyv(index));
% % % T_convection_matrixLayer(c) = 2/(1/Ky_matrixLayer(index)+1/Ky_matrixLayer(indexn))/(dyv(indexn)+dyv(index));
% % % perm_matrixLayer(c)=2*Ky_matrixLayer(index)*Ky_matrixLayer(indexn)/(Ky_matrixLayer(index) + Ky_matrixLayer(indexn));
% % % T_diff_matrixLayer(c)=dzv(index)*dxv(index)/(2/(1/dyv(indexn)+1/dyv(index)));
% % % flowArea_matrixLayer(c)=dzv(index)*dxv(index);
% % % end
% % % end
% % % end
% % %
% % % for i = 1 : nx
% % % for j = 1 : ny
% % % for k= 1: nz-1
% % % c = c + 1;
% % % index = i + (j - 1) * nx + (k - 1) * nx * ny;
% % % indexn = index + nx * ny;
% % % N_matrixLayer(c, :) = [index+nmc, index + nx*ny+nmc];
% % % T_matrixLayer(c) = 2 * dxv(index)*dyv(index)*Kz_matrixLayer(index)*Kz_matrixLayer(indexn)/(Kz_matrixLayer(index)*dzv(indexn) + Kz_matrixLayer(indexn)*dzv(index));
% % % T_convection_matrixLayer(c) = 2/(1/Kz_matrixLayer(index)+1/Kz_matrixLayer(indexn))/(dzv(indexn)+dzv(index));
% % % perm_matrixLayer(c)=2*Kz_matrixLayer(index)*Kz_matrixLayer(indexn)/(Kz_matrixLayer(index) + Kz_matrixLayer(indexn));
% % % T_diff_matrixLayer(c)=dxv(index)*dyv(index)/(2/(1/dzv(indexn)+1/dzv(index)));
% % % flowArea_matrixLayer(c)=dxv(index)*dyv(index);
% % % end
% % % end
% % % end
%%
N_fractureMatrixLayer = zeros(nmc, 2);%
T_fractureMatrixLayer = zeros(nmc, 1);%
T_convection_fractureMatrixLayer = zeros(nmc, 1);
T_diff_fractureMatrixLayer = zeros(nmc, 1);
perm_fractureMatrixLayer = zeros(nmc, 1);
flowArea_fractureMatrixLayer = zeros(nmc, 1);
c = 0;
for k= 1 : nz
for j = 1 : ny
for i = 1 : nx
c = c + 1;
index = i + (j - 1) * nx + (k - 1) * nx * ny;
indexn = index + nmc;
N_fractureMatrixLayer(c, :) = [index, indexn];
perm_fractureMatrixLayer(c)=(Kx(index)*Ky(index)*Kz(index))^(1/3);
T_fractureMatrixLayer(c) = dzv(index)*dyv(index)*dxv(index)*(Kx(index)*Ky(index)*Kz(index))^(1/3)*sigma(c);
T_convection_fractureMatrixLayer(c) = dzv(index)*dyv(index)*dxv(index)*Kx(index)*sigma(c)*dzv(index);
T_diff_fractureMatrixLayer(c) = dzv(index)*dyv(index)*dxv(index)*sigma(c);
flowArea_fractureMatrixLayer(c)=dxv(index)*dyv(index);
end
end
end
%% 2014
syms x y z;
Ninterflow=[];
Tinterflow=[];
Tinterflow_convection=[];
Tinterflow_diff=[];
cell_divided_by_fracture_flag = [];
perm_interflow=[];
flowArea_interflow=[];
for i=1:nx*ny*nz %
flag = 0;
for j=1:10
if matrixvsfra(i,j)~=0 %this matrix cell contains a fracture cell
flag = flag + 1;
Ninterflow=[Ninterflow;i,matrixvsfra(i,j)+2*nmc];
kcell=(kx(i)*ky(i)*kz(i))^(1/3);
% kcell = sqrt(10*100)*1e-3;
Knnc=kcell*Kf(matrixvsfra(i,j))/(kcell+Kf(matrixvsfra(i,j)));
Annc=areavsfra(matrixvsfra(i,j));
fracore=corevsfra(matrixvsfra(i,j),:);
matnodes=nodes(i,:);
verco=coord(matnodes,:);norvec=normalvec(matrixvsfra(i,j),:);
matcore=mean(verco);d0=matcore-fracore;
dn=(x+d0(1))*norvec(1)+(y+d0(2))*norvec(2)+(z+d0(3))*norvec(3);
% dn=abs(dn);%
dn=sqrt(dn^2);
dn=matlabFunction(dn);
if norvec(1)~=0 && norvec(2)~=0 && norvec(3)~=0
Dn=integral3(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(1)~=0 && norvec(2)~=0
Dn=dzv(i)*NTG(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(1)~=0 && norvec(3)~=0
Dn=dyv(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(2)~=0 && norvec(3)~=0
Dn=dxv(i)*integral2(dn,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(1)~=0
Dn=dyv(i)*dzv(i)*NTG(i)*integral(dn,-dxv(i)/2,dxv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(2)~=0
Dn=dxv(i)*dzv(i)*NTG(i)*integral(dn,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
else if norvec(3)~=0
Dn=dxv(i)*dyv(i)*integral(dn,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
end
end
end
end
end
end
end
% raoT=Knnc*Annc/Dn;
% raoT_convection=2*Knnc/Dn^2;
% Tinterflow=[Tinterflow;raoT];
% Tinterflow_convection=[Tinterflow_convection;raoT_convection];
raoT1 = 2*kcell*Annc/Dn;
raoT2 = Kf(matrixvsfra(i,j))*Annc/(Wf(matrixvsfra(i,j))/2);
raoT = (raoT1^-1+raoT2^-1)^-1;
Tinterflow=[Tinterflow;raoT];
raoT1_conv = kcell/Dn^2;
raoT2_conv = Kf(matrixvsfra(i,j))/(Wf(matrixvsfra(i,j))/2)^2;
raoT_convection = (raoT1_conv^-1+raoT2_conv^-1)^-1;
Tinterflow_convection=[Tinterflow_convection;raoT_convection];
Tinterflow_diff=[Tinterflow_diff;((2*Annc/Dn)^-1+(Annc/(Wf(matrixvsfra(i,j))/2))^-1)^-1;];
perm_mf_this = kcell*Kf(matrixvsfra(i,j))/(kcell+Kf(matrixvsfra(i,j)));
perm_interflow = [perm_interflow; perm_mf_this];
flowArea_interflow = [flowArea_interflow; Annc];
end
end
if flag >0
cell_divided_by_fracture_flag = [cell_divided_by_fracture_flag; i];
end
end
%% 2014
% syms x y z;
% Ninterflow=[];
% Tinterflow=[];
% for i=1:nx*ny*nz %
% for j=1:10
% if matrixvsfra(i,j)~=0 %this matrix cell contains a fracture cell
% Ninterflow=[Ninterflow;i,matrixvsfra(i,j)+nmc];
% kcell=(kx(i)*ky(i)*kz(i))^(1/3);
% K1=Kf(matrixvsfra(i,j));d1=Wf(matrixvsfra(i,j));
% K2=kffl(matrixvsfra(i,j));d2=dffl(matrixvsfra(i,j));
% Annc=2*areavsfra(matrixvsfra(i,j));
% fracore=corevsfra(matrixvsfra(i,j),:);
% matnodes=nodes(i,:);
% verco=coord(matnodes,:);norvec=normalvec(matrixvsfra(i,j),:);
% matcore=mean(verco);d0=matcore-fracore;
% dn=(x+d0(1))*norvec(1)+(y+d0(2))*norvec(2)+(z+d0(3))*norvec(3);
% % dn=abs(dn);%
% dn=sqrt(dn^2);
% dn=matlabFunction(dn);
% if norvec(1)~=0 && norvec(2)~=0 && norvec(3)~=0
% Dn=integral3(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(1)~=0 && norvec(2)~=0
% Dn=dzv(i)*NTG(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(1)~=0 && norvec(3)~=0
% Dn=dyv(i)*integral2(dn,-dxv(i)/2,dxv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(2)~=0 && norvec(3)~=0
% Dn=dxv(i)*integral2(dn,-dyv(i)/2,dyv(i)/2,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(1)~=0
% Dn=dyv(i)*dzv(i)*NTG(i)*integral(dn,-dxv(i)/2,dxv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(2)~=0
% Dn=dxv(i)*dzv(i)*NTG(i)*integral(dn,-dyv(i)/2,dyv(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% else if norvec(3)~=0
% Dn=dxv(i)*dyv(i)*integral(dn,-dzv(i)*NTG(i)/2,dzv(i)*NTG(i)/2)/(dxv(i)*dyv(i)*dzv(i)*NTG(i));
% end
% end
% end
% end
% end
% end
% end
% raoT=((Kcell*Annc/(Dn-d2))^(-1)+(K2*Annc/d2)^(-1)+(K1*Annc/d1)^(-1))^(-1);
% Tinterflow=[Tinterflow;raoT];
% end
% end
% end
%%
%%
matrixflag = [ones(size(T,1),1); ones(size(T_matrixLayer,1),1); ones(size(T_fractureMatrixLayer,1),1); zeros(size(Tmff,1),1); zeros(size(Tff,1),1); ones(size(Tinterflow,1),1);];
N = [N; N_matrixLayer; N_fractureMatrixLayer; Nmff+2*nmc; Nff+2*nmc;Ninterflow;];
T = [T; T_matrixLayer; T_fractureMatrixLayer; Tmff; Tff;Tinterflow;];
T_convection = [T_convection;T_convection_matrixLayer; T_convection_fractureMatrixLayer; Tmff_convection; Tff_convection;Tinterflow_convection;];
T_diff = [T_diff;T_diff_matrixLayer;T_diff_fractureMatrixLayer;Tmff_diff; Tff_diff;Tinterflow_diff;];
perm = [perm; perm_matrixLayer; perm_fractureMatrixLayer; perm_mff; perm_ff;perm_interflow; ];
flowArea = [flowArea; flowArea_matrixLayer; flowArea_fractureMatrixLayer; flowArea_mff; flowArea_ff;flowArea_interflow;];
%
% deleted_rows = [];
% for i = 1:size(N,1)
% if ismember(N(i,1),invalid_grids) || ismember(N(i,2),invalid_grids)
% deleted_rows = [deleted_rows; i];
% end
% end
% N(deleted_rows,:) = [];
% T(deleted_rows,:) = 0;
% T_convection(deleted_rows,:) = 0;
% T_diff(deleted_rows,:) = 0;
% perm(deleted_rows,:) = 0;
% flowArea(deleted_rows,:) = 0;
nex=size(N,1);
%% CMG或者ECLIPSE进行计算
% [ Data_for_ECLIPSE ] = pEDFM_to_CMG_horizontalFractureWell(dxv,dyv,dzv,kx,ky,kz,pori,Kf,Wf,vf,porf,N,T);
% [ Data_for_ECLIPSE ] = pEDFM_to_CMG_horizontalFractureWell_net_pay(dxv,dyv,dzv,kx,ky,kz,pori,Kf,Wf,vf,porf,N,T);
end
@@ -0,0 +1,18 @@
function f = fluidPVT(Ppr, BG, MUG, Bwi, prw, cw, vwi, cvw, SW, KRG, KRW, PCGL, SWF, KRGF, KRWF, PCGLF, density_g_sc, ifpcgl, rpt, cs_data, csa_data, cb_data, cba_data)
% f = fluidPVT(Bopb, pb, co, Bwi, prw, cw, vwi, cvw, visopb, cvo, SW, KRO, KRW, PCOW, ifpcow, SWF, KROF, KRWF, PCOWF, rpt,Dosi,Dwsi)
f.Bw = @(p) Bw(p, Bwi, prw, cw);
f.Bg = @(p) Bg(p, BG, Ppr);
f.muw = @(p) muw(p, vwi, prw, cvw);
f.mug = @(p) mug(p, MUG, Ppr);
f.krrg = @(sw) krrg(sw, SW, KRG, SWF, KRGF, rpt);
f.krw = @(sw) krw(sw, SW, KRW, SWF, KRWF, rpt);
f.pcgl = @(sw) pcgl(sw, SW, PCGL, SWF, PCGLF, rpt);
f.cs_absorb = @(cs) cs_absorb_f(cs, cs_data, csa_data);
f.cb_absorb = @(cb) cb_absorb_f(cb, cb_data, cba_data);
f.density_g_sc = density_g_sc;
f.ifpcgl = ifpcgl;
% f.Dosi=Dosi;
% f.Dwsi=Dwsi;
@@ -0,0 +1,22 @@
function f = fluidPVT_new(Ppr, BG, MUG, Bwi, prw, cw, vwi, cvw, ifpc, rpt, cs_data, csa_data, cb_data, cba_data, cs_Nc, Nc_nosurf, Nc_surf, kr_nosurf, kr_surf, PC, cs_Nc_fracture, kr_nosurf_fracture, kr_surf_fracture, PC_fracture)
% Ppr, BG, MUG, Bwi, prw, cw, vwi, cvw, ifpcgl, r.rpt, cs_data, csa_data, cb_data, cba_data, cs_Nc, Nc_nosurf, Nc_surf, kr_nosurf, kr_surf, cs_Nc_fracture, kr_nosurf_fracture, kr_surf_fracture, PC_fracture
% f = fluidPVT(Bopb, pb, co, Bwi, prw, cw, vwi, cvw, visopb, cvo, SW, KRO, KRW, PCOW, ifpcow, SWF, KROF, KRWF, PCOWF, rpt,Dosi,Dwsi)
f.Bw = @(p) Bw(p, Bwi, prw, cw);
f.Bg = @(p) Bg(p, BG, Ppr);
f.muw = @(p) muw(p, vwi, prw, cvw);
f.mug = @(p) mug(p, MUG, Ppr);
% f.krrg = @(sw) krrg(sw, SW, KRG, SWF, KRGF, rpt);
% f.krw = @(sw) krw(sw, SW, KRW, SWF, KRWF, rpt);
% f.pcgl = @(sw) pcgl(sw, SW, PCGL, SWF, PCGLF, rpt);
f.cs_absorb = @(cs) cs_absorb_f(cs, cs_data, csa_data);
f.cb_absorb = @(cb) cb_absorb_f(cb, cb_data, cba_data);
f.Nc = @(cs) cs_to_Nc(cs, cs_Nc, cs_Nc_fracture, rpt);
f.krrg = @(sw, Nc) krg(sw, Nc, Nc_nosurf, Nc_surf, kr_nosurf, kr_surf, kr_nosurf_fracture, kr_surf_fracture, rpt);
f.krw = @(sw, Nc) krw(sw, Nc, Nc_nosurf, Nc_surf, kr_nosurf, kr_surf, kr_nosurf_fracture, kr_surf_fracture, rpt);
f.pcgl = @(sw) pc(sw, PC, PC_fracture, rpt);
f.ifpcgl = ifpc;
% f.Dosi=Dosi;
% f.Dwsi=Dwsi;
end
@@ -0,0 +1,15 @@
function frac_information = fractureInformation_input_engineering_vector(f,fellip,flowBarrierFlags)
ff = [f;fellip];
nf = size(ff,1)/5;
frac_information = zeros(3*nf,2);
for i = 1:size(ff,1)/5
startPoint = ff(5*i-4,1:2)+ff(5*i-3,1:2)*ff(5*i-1,1);
endPoint = ff(5*i-4,1:2)+ff(5*i-3,1:2)*ff(5*i-1,2);
frac_information(3*i-2,:) = startPoint;
frac_information(3*i-1,:) = endPoint;
if ismember(i,flowBarrierFlags)
frac_information(3*i-0,:) = [0*1e-3,1e-2];
else
frac_information(3*i-0,:) = [10000*1e-3,1e-2];
end
end
@@ -0,0 +1,49 @@
function r = grid_discretization_DP_model(modelflag, nx, ny, nz, dx, dy, dz, f, frac_information, fellip, nf)
% 裂缝层网格渗渗透率
kx = 50*1e-3 * ones(nx*ny*nz, 1); % 达西,D
ky = 50*1e-3 * ones(nx*ny*nz, 1);%
kz = 50*1e-3 * ones(nx*ny*nz, 1);%
pori = 0.001 * ones(nx*ny*nz, 1);%
prpor = 20; % 参考压力,MPa
cpor = 1.0e-5;% 基质压缩系数,MPa
NTG= 1 * ones(nx*ny*nz, 1);
% 基质层网格渗透率
kx = 0.001*1e-3 * ones(nx*ny*nz, 1); % 达西,D
ky = 0.001*1e-3 * ones(nx*ny*nz, 1);%
kz = 0.001*1e-3 * ones(nx*ny*nz, 1);%
pori = 1 * ones(nx*ny*nz, 1);%
prpor = 20; % 参考压力,MPa
cpor = 1.0e-5;% 基质压缩系数,MPa
% 形状因子
sigma =
% SRV区域定义
% % % base_x=23:78; nx_SRV=length(base_x);
% % % base_y=15:36; ny_SRV=length(base_y);
% % % base_z=1:1;nz_SRV=length(base_z);
% % % SRV=[];
% % % for k=1:nz_SRV
% % % for j=1:ny_SRV
% % % for i=1:nx_SRV
% % % SRV=[SRV;(base_z(k)-1)*nx*ny+(base_y(j)-1)*nx+base_x(i)];
% % % end
% % % end
% % % end
% % % % SRV渗透率赋值
% % % kx(SRV)=0.001*1e-3 * ones(length(SRV), 1);
% % % ky(SRV)=0.001*1e-3 * ones(length(SRV), 1);
% % % kz(SRV)=0.001*1e-3 * ones(length(SRV), 1);
% 裂缝孔渗
Kf = 50000*1e-3*ones(1,nf);% 裂缝渗透率
Wf =1e-2*ones(1,nf);% 裂缝开度
Porf = 0.30*ones(1,nf);% 裂缝孔隙度
prporf = 20;% 裂缝系统参考压力
cporf = 1.0e-5;% 裂缝系统压缩系数
%
Rpt = 2;cf = 1;ca = 1;
%% 结合基质、裂缝的几何及物性信息开展前处理
% r = GridProp_new(modelflag, nx, ny, nz, dx, dy, dz, kx, ky, kz, f, fellip, Kf, Wf, pori, prpor, cpor, Porf, prporf, cporf, cf, ca,co, NTG);
r = GridProp_DP(modelflag, nx, ny, nz, dx, dy, dz, kx, ky, kz, f, frac_information, fellip, Kf, Wf, pori, prpor, cpor, Porf, prporf, cporf, cf, ca,NTG);
density_rock = 2700; % 岩石密度,kg/m^3
r.density_rock = density_rock;
end
@@ -0,0 +1,13 @@
function well1 = handle_well1(well1,r)
%
n1=size(well1,1);
for i=1:n1
perf=well1{i,3};
nperf=well1{i,2};
perf(:,3)=(r.nz+1)*ones(nperf,1)-perf(:,3);
A=repmat([0 1 1],nperf,1);
B=(perf-A)*[1;r.nx;r.nx*r.ny];
B=B'; %
well1{i,3}=B;
end
end
@@ -0,0 +1,36 @@
function Wellc = handle_well1_well2(well1,well2,welloc,r)
%------------------------------------
nwell1=size(well1,1);
nwell2=size(well2,1);
nwell=nwell1+nwell2;
Wellc0=cell(nwell,9);
% if nwell1==0
% Wellc0=well2;
% elseif nwell2==0
% Wellc0=well1;
% else
if nwell1~=0
for i=1:nwell1
for j=1:6
Wellc0{i,j}=well1{i,j};
end
plot3([r.cell_mid_coords(well1{i,3}(1),1);r.cell_mid_coords(well1{i,3}(1),1)],...
[r.cell_mid_coords(well1{i,3}(1),2);r.cell_mid_coords(well1{i,3}(1),2)],...
[r.cell_mid_coords(well1{i,3}(1),3);max(r.cell_mid_coords(:,3))+20],'color','k','LineWidth',2.5);
hold on;
end
end
if nwell2~=0
for i=1:nwell2
for j=1:6
Wellc0{i+nwell1,j}=well2{i,j};
end
plot3(welloc{i,1}(:,1),welloc{i,1}(:,2),welloc{i,1}(:,3),'color','k','LineWidth',2.5);
hold on;
end
end
% end
hold off;
%
Wellc = calcTrans(r, Wellc0);
end
@@ -0,0 +1,54 @@
function [Weladd, pwf] = initalSchedule_2026(p, sw, cs, Wellc, f, well_schedules_k)
nWel = size(Wellc, 1);%
Weladd = 0;
pwf = zeros(1);
BW = f.Bw(p);
muW = f.muw(p);
Nc = f.Nc(cs);
krW = f.krw(sw,Nc);
BG = f.Bg(p);
muG = f.mug(p);
krG = f.krrg(sw,Nc);
Ygt = krG ./ (muG .* BG);%mu代表黏度
Ygj = krG ./ muG;
Ywt = krW ./ (muW .* BW);%mu代表黏度
Ywj = krW ./ muW;
for i = 1 : nWel
if strcmp(well_schedules_k{i,2},'open')
if strcmp(well_schedules_k{i,3},'pro') && strcmp(well_schedules_k{i,4},'const_q') %
Weladd = Weladd + 1;
nper = Wellc{i,2}; %
jperf = zeros(nper,1);
Trans = zeros(nper,1);
Tnp = 0;
Tn = 0;
for j = 1 : nper
jperf(j) = Wellc{i,3}(j);%
Tr = Wellc{i,4}(j);%
Trans(j) = Tr * (Ygt(jperf(j)) + Ywt(jperf(j)));%
Tnp = Tnp + Trans(j)*p(jperf(j));
Tn = Tn + Trans(j);
end
pwf(Weladd) = (Tnp - well_schedules_k{i,5}/86.4) / Tn;%
elseif strcmp(well_schedules_k{i,3},'inj') && strcmp(well_schedules_k{i,4},'const_q') %
Weladd = Weladd + 1;
nper = Wellc{i,2};
jperf = zeros(nper,1);
Trans = zeros(nper,1);
Tnp = 0;
Tn = 0;
for j = 1 : nper
jperf(j) = Wellc{i,3}(j);
Tr = Wellc{i,4}(j);
Trans(j) = Tr / BW(jperf(j)) * (Ygj(jperf(j)) + Ywj(jperf(j)));%
Tnp = Tnp + Trans(j)*p(jperf(j));
Tn = Tn + Trans(j);
end
pwf(Weladd) = (Tnp + well_schedules_k{i,5}/86.4) / Tn;%
else
continue
end
end
end
pwf = pwf';
@@ -0,0 +1,26 @@
function [f,frac_information] = input_fracture_2D(fractureLines,fractureHeights,flowBarrierFlags)
f = zeros((size(fractureLines,1)/2-length(flowBarrierFlags))*5,3);
numberHighFracture = 0;
for i = 1:size(fractureLines,1)/2
if ~ismember(i,flowBarrierFlags)
numberHighFracture = numberHighFracture +1;
f(5*numberHighFracture-4,:) = [fractureLines(2*i-1,:),0];
f(5*numberHighFracture-3,:) = [fractureLines(2*i,:)-fractureLines(2*i-1,:),0];
f(5*numberHighFracture-2,:) = [0,0,fractureHeights(i)];
f(5*numberHighFracture-1,:) = [0,1,0];
f(5*numberHighFracture-0,:) = [0,1,0];
end
end
frac_information = zeros(size(fractureLines,1)*3,2);
for i = 1:size(fractureLines,1)/2
frac_information(3*i-2,:) = [fractureLines(2*i-1,:)];
frac_information(3*i-1,:) = [fractureLines(2*i,:)];
if ismember(i,flowBarrierFlags)
frac_information(3*i-2,:) = frac_information(3*i-2,:);
frac_information(3*i-1,:) = frac_information(3*i-1,:);
frac_information(3*i-0,:) = [0*1e-3,1e-2];
else
frac_information(3*i-0,:) = [10000*1e-3,1e-2];
end
end
end
@@ -0,0 +1,165 @@
function [Times, OutputRs, Wellpara, trun] = mainRS_MB_2026(r, f, os, w, state0)
t_start = clock;
dtmin = w.dtmin;
dtmax = w.dtmax;
Nmax = w.Nmax;
epsave = w.epsave;
epsmax = w.epsmax;
yitap = w.yitap;
yitas = w.yitas;
omega = w.omega;
Wellc = w.Wellc;
time = w.time;
well_schedules = w.well_schedules;
% WelChg = w.WelChg;
% tend = w.tend;
count = 0;
t = 0;
state = state0;
number_state_variables = f.number_state_variables;
OutputRs = cell(2,1);
Wellpara = cell(2,1);
Times = zeros(2,1);
% h0 = waitbar(0,'Please wait...');
for k = 1:size(well_schedules,1)
dt=dtmin(k);
[Weladd, pwf] = initalSchedule_2026(state0.p, state0.sw, state0.cs, Wellc, f, well_schedules{k,1});
% [Weladd, pwf] = initalSchedule(state0.p, state0.sw, Wellc, f);
WelChg = zeros(size(well_schedules{k,1},1),1); %
repi = 0;
Newton_step = 0;
cons_Jacob = 0;
leqs_solve_time = 0;
Newtons_vs_time = [0, 0];
tend = sum(time(1:k),1);
while t < tend
for i = 1 : Nmax
dtc = dt * 86.4;
tic;
[eqs, Awell, qwell, Pvv, Boa, Bwa] = ...
eqsOW_MB_2014(state, state0, dtc, r, f, os, Wellc, Weladd, pwf, WelChg, well_schedules{k,1});
Jacob = Awell;
Ris = qwell;
for iii = 1:number_state_variables
for jjj = 1:number_state_variables
Jacob((iii-1)*r.nc+1 : iii*r.nc,(jjj-1)*r.nc+1 : jjj*r.nc) = Jacob((iii-1)*r.nc+1 : iii*r.nc,(jjj-1)*r.nc+1 : jjj*r.nc) + eqs{iii}.jac{jjj} ;
end
Ris((iii-1)*r.nc+1 : iii*r.nc,1) = Ris((iii-1)*r.nc+1 : iii*r.nc,1) +eqs{iii}.val;
end
% % % Jacob(1 : r.nc,1 : 2 * r.nc) = Jacob(1 : r.nc,1 : 2 * r.nc) + [eqs{1}.jac{1} eqs{1}.jac{2}];
% % % Jacob(r.nc + 1 : 2 * r.nc,1 : 2 * r.nc) = Jacob(r.nc + 1 : 2 * r.nc,1 : 2 * r.nc) + [eqs{2}.jac{1} eqs{2}.jac{2}];
% % % Ris(1 : r.nc) = Ris(1 : r.nc) + eqs{1}.val ;
% % % Ris(r.nc + 1: 2 * r.nc) = Ris(r.nc + 1: 2 * r.nc) + eqs{2}.val ;
%
Dimensionless_Ris = Ris(1: 4 * r.nc)./ [Pvv;Pvv;Pvv;Pvv] .* [Bwa;Boa;Bwa;Bwa] .* dtc;
% Dimensionless_Ris = Ris(1: 4 * r.nc);
cons_Jacob_lo=toc;
cons_Jacob=cons_Jacob+cons_Jacob_lo;
% PVall = sum(Pvv);
% MBw = Bwa*dtc*abs(sum(Ris(1:r.nc))/PVall);
% MBo = Boa*dtc*abs(sum(Ris(r.nc+1:2*r.nc))/PVall);
% CNVw = max(Bwa*dtc*abs(Ris(1:r.nc)./Pvv));
% CNVo = max(Boa*dtc*abs(Ris(r.nc+1:2*r.nc)./Pvv));
% [L,U] = ilu(-Jacob);
% tol = 1e-6;
% maxit = 50;
% [X, ~] = bicgstab(-Jacob,Ris,tol,maxit,L,U);
tic;
% tol = 1e-12;
% maxit = 200;
% [X0,fl0,rr0,it0,rv0] = gmres(-Jacob,Ris,[],tol,maxit);
% [L,U] = ilu(-Jacob,struct('type','ilutp','droptol',1e-6));
% [X1,fl1,rr1,it1,rv1] = gmres(-Jacob,Ris,[],tol,maxit,L,U);
X = -Jacob \ Ris;
leqs_time=toc;
leqs_solve_time=leqs_solve_time+leqs_time;
Newton_step=Newton_step+1;
dp = X(1 : r.nc);
dsw = X(r.nc + 1 : 2*r.nc);
dcs = X(2*r.nc + 1 : 3*r.nc);
dcb = X(3*r.nc + 1 : 4*r.nc);
state.p = state.p + dp;
state.sw = state.sw + dsw;
state.cs = state.cs + dcs;
state.cb = state.cb + dcb;
% deltp=state.p-state0.p;
% deltsw=state.sw-state0.sw;
if Weladd > 0
dpwf = X(4 * r.nc + 1 : end);
pwf = pwf + dpwf;
state.pwf = pwf;
end
% if MBw <= epsave && MBo <= epsave && CNVw <= epsmax && CNVo <=epsmax && max(dsw)<=0.02 && max(dp)<=1
% break
% end
% Ris无因次化
if mean(abs(Dimensionless_Ris)) <= epsave && max(abs(Dimensionless_Ris)) <=epsmax
break
end
% [L,U] = ilu(-Jacob);
% tol = 1e-6;
% maxit = 50;
% [X, ~] = bicgstab(-Jacob,Ris,tol,maxit,L,U);
% raodai=condest(Jacob);
% if condest(Jacob)>50000
% dt = dt / 2;
% else
end
if i == Nmax
repi = repi + 1;
if repi == 5
error('too many iter')
end
if repi == 1
dt = dt / 2;
elseif repi == 2
dt = dt / 3;
else
dt = dt / 10;
end
% dt = max(dt, w.dtmin);
state = state0;
else
repi = 0;
t = t + dt;
count = count + 1;
Times(count) = t;
OutputRs{count} = state;
Newtons_vs_time = [Newtons_vs_time; t, Newton_step];
% qwell=qwell/dtc;%
[Wellpara_t, WelChg, Weladd] = calcWellequation(Weladd, Wellc, WelChg, well_schedules{k,1}, r.nc, qwell, state);
Wellpara{count} = Wellpara_t;
state0 = state;
tm = ADtimestep(yitap, yitas, omega, dp, dsw);
% tm=1;
dt = dt * tm;
if t + dt > tend
dt = tend - t;
end
if dt >= dtmax(k)
dt = dtmax(k);
end
if i ~= Nmax
% waitbar(t / tend);
% disp(t);
fprintf('%.4f/%.4f\n', t, sum(time));
end
if t>300
flag = 1;
end
end
end
end
trun.cons_Jacob=cons_Jacob;
trun.leqs_solve_time=leqs_solve_time;
trun.total_simulation_time = etime(clock,t_start);
trun.Newton_step=Newton_step;
trun.Newtons_vs_time=Newtons_vs_time;
fprintf('');
% close(h0);
@@ -0,0 +1,242 @@
function [f,state0] = multi_component_flow(r)
%%
%%
Ds = 0.76*1e-9; % m2/s
Db = 2.2*1e-9; % m2/s
%% kg/m3, g/kg
c_ca_table = [
0 0 0
0.05 1 0.075
0.1 1.75 0.125
0.2 3 0.2
0.5 4.35 0.325
1 4.55 0.365
];
cs_data = c_ca_table(:,1);
cb_data = c_ca_table(:,1);
csa_data = c_ca_table(:,2)*1e-3; % kg/kg
cba_data = c_ca_table(:,3)*1e-3; % kg/kg
%%
R = 0.008314; % kJ/(mol*K)
Vm = 18.02*1e-6; % m^3/mol
Temperature = 293.15; % K
% salinity_fracturing_fluid = 0.1/100;
% salinity_reservoir_water = 28/100;
xf = 1;
xm = 0.9;
chemistry_cof = R*Temperature/Vm*1e-3/10;
x_total = [xm*ones(r.nmc,1); xf*ones(r.nfc,1)];
chemistry_potential = chemistry_cof*log(x_total);
%%
%
% 便
%
% ,
% dynamic_kr = 1;
cs_Nc = [
0 1.6*1e-6 30
0.1 9.5*1e-6 10
0.2 2.5*1e-5 4
0.5 5.8*1e-5 1.4
1 8.2*1e-5 1
2 8.8*1e-5 0.75
];
Nc_nosurf = min(cs_Nc(:,2));
Nc_surf = max(cs_Nc(:,2));
kr_nosurf = [
0 0 0.64
0.25 0 0.64
0.30 0.072 0.6
0.40 0.14 0.56
0.50 0.26 0.48
0.60 0.4 0.38
0.70 0.56 0.26
0.85 0.88 0
1 0.88 0
];
kr_surf = [
0 0 0.6
0.18 0 0.6
0.25 0.056 0.56
0.30 0.1 0.52
0.40 0.19 0.42
0.50 0.29 0.3
0.60 0.37 0.19
0.75 0.46 0
1 0.46 0
];
PC = [
0 3.8916
0.2 3.8916
0.316 0.5796
0.435 0.3724
0.562 0.2425
0.614 0.0608
0.702 0.0372
0.812 0.0137
0.875 0.0104
0.906 0.009
0.937 0.0075
0.969 0.0059
1 0
];
cs_Nc_fracture = cs_Nc;
kr_nosurf_fracture = kr_nosurf;
kr_surf_fracture = kr_surf;
PC_fracture = PC;
ifpcgl = 0; %
%%
p_grad_threshold = 0.01; % MPa/m
%% ================Langmuir等温吸附模型 VL=0===============
% VE = VL*P/(PL+P)
gas_prop.VL = 0.0; % Langmuir volume, m^3/kg
gas_prop.PL = 3.5; % Langmuir pressure, MPa
% Psc = 1;
% Zsc = 1;
% density_rock = 2000; %
% ===================== Knudsen Kn=0 ====================
gas_prop.Kn = 0; % Knudsen数
c1 =1; c2 =8/9;
gas_prop.Kn_modified_factor = 1+8*c1*gas_prop.Kn+16*c2*gas_prop.Kn^2;
% ===================== ====================
gas_prop.stress_factor_fracture = 0.000; % 1/MPa 0.001
gas_prop.stress_factor_matrix = 0.000; % 1/MPa
gas_prop.stress_factor_ref_pressure = 20; %
% ===================== 西 Forchheimer ====================
gas_prop.beta_non_Darcy_flow = 0; % 1e-8
% ======================================================
density_g_sc = 800;
%
gas_model =1;
if gas_model == 1
prg = 20; % reference pressure, MPa
Bgi = 1; % gas phase volume factor
cg = 5e-4 ;% gas phase compressibility, 1/MPa
vgi = 6; % gas viscosity, cp
cvg = 0;
[Ppr,BG,MUG] = cal_gas_prop(prg,Bgi,cg,vgi,cvg);
end
if gas_model == 2
Ppr = [ 0.1013
2.0946
4.0878
6.0811
8.0743
10.0676
12.0608
14.0540
16.0473
18.0405
20.0338
22.0270
24.0203
26.0135
28.0068
30.0000
];
% BG = 0.01*ones(size(Ppr,1),1);
BG = [ 1.18297
0.0557041
0.0278168
0.0182594
0.0134665
0.0106154
0.00874829
0.00744907
0.00650639
0.0058006
0.0052587
0.0048336
0.00449378
0.00421751
0.0039895
0.00379871
];
% MUG = 0.01*ones(size(Ppr,1),1);
MUG = [0.0127683
0.0130191
0.0133973
0.013872
0.014437
0.015088
0.0158182
0.0166173
0.0174719
0.0183671
0.0192882
0.0202219
0.0211575
0.0220865
0.0230024
0.0239008
];
end
% =======================================================
density_w_sc = 1000;
prw = 20; % reference pressure
Bwi = 1.000; % water phase volume factor
cw = 4.0e-4 ;% water phase compressibility
vwi = 1; % viscosity
cvw = 0;
% ============================================================
% ifpcgl = 0; %
% RPGW=[
% 0.0000 0.0000 1.0000 3.8916
% 0.2000 0.0000 1.0000 3.8916
% 0.3160 0.0002 0.6784 0.5796
% 0.4350 0.0004 0.6215 0.3724
% 0.5620 0.0010 0.5456 0.2425
% 0.6140 0.0020 0.3939 0.0608
% 0.7020 0.0280 0.1399 0.0372
% 0.8120 0.1721 0.0515 0.0137
% 0.8750 0.3395 0.0297 0.0104
% 0.9060 0.4395 0.0226 0.0090
% 0.9370 0.5500 0.0173 0.0075
% 0.9690 0.6702 0.0131 0.0059
% 1.0 1.0000 0.0000 0.0000
% ];
% SW=RPGW(:,1);KRW=RPGW(:,2);KRG=RPGW(:,3);PCGL=RPGW(:,4);
%
% % ============================================================
% PRF=[
% 0.0000 0.0000 1.0000 3.8916
% 0.2000 0.0000 1.0000 3.8916
% 0.3160 0.0002 0.6784 0.5796
% 0.4350 0.0004 0.6215 0.3724
% 0.5620 0.0010 0.5456 0.2425
% 0.6140 0.0020 0.3939 0.0608
% 0.7020 0.0280 0.1399 0.0372
% 0.8120 0.1721 0.0515 0.0137
% 0.8750 0.3395 0.0297 0.0104
% 0.9060 0.4395 0.0226 0.0090
% 0.9370 0.5500 0.0173 0.0075
% 1.0 1.0000 0.0000 0.0000
% ];
% SWF = PRF(:,1);KRWF = PRF(:,2);KRGF = PRF(:,3);PCGLF=PRF(:,4);
%%
% f = fluidPVT(Ppr, BG, MUG, Bwi, prw, cw, vwi, cvw, SW, KRG, KRW, PCGL, SWF, KRGF, KRWF, PCGLF, density_g_sc, ifpcgl, r.rpt, cs_data, csa_data, cb_data, cba_data, cs_Nc, kr_nosurf, kr_surf);
f = fluidPVT_new(Ppr, BG, MUG, Bwi, prw, cw, vwi, cvw, ifpcgl, r.rpt, cs_data, csa_data, cb_data, cba_data, cs_Nc, Nc_nosurf, Nc_surf, kr_nosurf, kr_surf, PC, cs_Nc_fracture, kr_nosurf_fracture, kr_surf_fracture, PC_fracture);
f.Dwsi = density_w_sc;
f.Dgsi = density_g_sc;
f.gas_prop = gas_prop;
f.Ds = Ds;
f.Db = Db;
f.x_total = x_total;
f.chemistry_potential = chemistry_potential;
f.p_grad_threshold = p_grad_threshold;
%% Initial Condition Section
% ======================================================== %
%
P = [20 * ones(r.nmc, 1); 20 * ones(r.nfc, 1)];
% plow=25; % P =plow-1e-6*800*9.8*r.z;
Sw = [0.2 * ones(r.nmc, 1); 0.2 * ones(r.nfc, 1)];
Cs = [0.0 * ones(r.nmc, 1); 0.0 * ones(r.nfc, 1)];
Cb = [0.0 * ones(r.nmc, 1); 0.0 * ones(r.nfc, 1)];
number_state_variables = 4;
f.number_state_variables = number_state_variables;
state0 = initialRS(P, Sw, Cs, Cb);
end
@@ -0,0 +1,18 @@
function ratio = smooth_relu_stable(dp,p_grad_threshold)
% ReLU100%
eps = 1e-8;
s = 200;
dP_abs = (dp.^2 + eps).^(1/2);
x = dP_abs - p_grad_threshold;
y = zeros(length(x),1);
idx1 = x <= 0;
y(idx1) = 0;
% y(idx1) = log(1 + exp(s * x(idx1))) / s;
idx2 = x > 0;
y(idx2) = x(idx2);
% y(idx2) = x(idx2) + log(1 + exp(-s * x(idx2))) / s;
activate = y;
ratio = activate ./ (dP_abs);
end
@@ -0,0 +1,28 @@
function [Times, OutputRs, Wellpara, trun] = solver_NR(r, flow_model, f, os, state0, yitap,yitas,omega,Nmax,epsave,epsmax,dtmin,dtmax,Wellc,time,well_schedules)
w.yitap = yitap;
w.yitas = yitas;
w.omega = omega;
w.Nmax = Nmax;
w.epsave = epsave;
w.epsmax = epsmax;
w.dtmin = dtmin;
w.dtmax = dtmax;
% w.tend = tend;
% w.WelChg = WelChg;
w.Wellc = Wellc;
w.time = time;
w.well_schedules = well_schedules;
%%
if r.modelflag==1 || r.modelflag==4 || r.modelflag==5
if flow_model == 1
[Times, OutputRs, Wellpara, trun] = mainRS_MB_gas_water_flow(r, f, os, w, state0);
end
if flow_model == 2
[Times, OutputRs, Wellpara, trun] = mainRS_MB_oil_water_flow(r, f, os, w, state0);
end
if flow_model == 3
[Times, OutputRs, Wellpara, trun] = mainRS_MB_2026(r, f, os, w, state0);
end
% [Times, OutputRs, Wellpara, trun] = mainRS_MB_2014(r, f, os, w, state0);
end
end