Skip to content

Commit

Permalink
WIP plot capillary pressure upscaling results in terms of Leverett J-…
Browse files Browse the repository at this point in the history
…function heterogeneity
  • Loading branch information
djmaxus committed Oct 8, 2024
1 parent 5e349e5 commit bdc66c9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 39 deletions.
63 changes: 26 additions & 37 deletions plot_result.m
Original file line number Diff line number Diff line change
@@ -1,51 +1,38 @@
function plot_result(rock, mask, strata_trapped, params, kr_scale)
arguments
rock
mask
strata_trapped
params
rock
mask
strata_trapped
params
kr_scale = "log"
end

curves_plot(mask, strata_trapped, params, kr_scale);

base_cap = strata_trapped;
base_cap.permeability = rock.perm;
for i = 1:length(base_cap.saturation)
base_cap.capillary_pressure(mask,i) = params.cap_pressure.func(base_cap.saturation(i),rock.poro(mask),rock.perm(mask,:));
end

tiles_pc = tiledlayout(figure(),'flow',TileSpacing='compact',Padding='tight');

pc_base = nexttile(tiles_pc);
y_lim_base = stat_plot(pc_base,'Base','',base_cap.saturation,[],base_cap.capillary_pressure(mask,:)./barsa());
pc_base.YScale='log';
leverett_j_upscaled = params.cap_pressure.inv_lj(strata_trapped.capillary_pressure(mask,:),rock.poro(mask),strata_trapped.permeability(mask,:));

[y_lim_strat, pc_strat] = stat_plot(nexttile(tiles_pc),'StrataTrapped','',strata_trapped.saturation,[],strata_trapped.capillary_pressure(mask,:)./barsa());
pc_strat.YScale='log';
[y_lim_pc, ax_pc] = stat_plot(axes(figure),'Leverett J-function','',strata_trapped.saturation,...
@(sw)params.cap_pressure.leverett_j.func(sw), leverett_j_upscaled,true);

y_lim_concat = [y_lim_base;y_lim_strat];
y_lim_both = [min(y_lim_concat(:,1)),max(y_lim_concat(:,2))];
ax_pc.YScale='log';
% ylim(ax_pc,y_lim_pc);

ylim(pc_base,y_lim_both);
ylim(pc_strat,y_lim_both);
xlabel(ax_pc,'Wetting phase saturation');
ylabel(ax_pc,'[-]');

xlabel(tiles_pc,'Wetting phase saturation');
ylabel(tiles_pc,'Capillary pressure, bar');
curves_plot(mask, strata_trapped, params, kr_scale);

end


function curves_plot(mask, strata_trapped, params,scale)
arguments
mask
strata_trapped
params
mask
strata_trapped
params
scale = "log"
end
sub_data = @(data,mask,direction) squeeze(data(mask,direction,:));

tiles_krw = tiledlayout(figure(),3,2,TileSpacing='compact',Padding='tight');
tiles_krw = tiledlayout(figure(),3,2,TileSpacing='tight',Padding='tight');

stat_plot(nexttile(tiles_krw),'Water, along X-axis','',strata_trapped.saturation,@(sw)params.krw.func(sw),sub_data(strata_trapped.rel_perm_wat,mask,1));
yscale(scale);
Expand All @@ -57,7 +44,7 @@ function curves_plot(mask, strata_trapped, params,scale)
stat_plot(nexttile(tiles_krw),'Gas, along Y-axis','',strata_trapped.saturation,@(sw) params.krg.func(1-sw),sub_data(strata_trapped.rel_perm_gas,mask,2));
yscale(scale);

stat_plot(nexttile(tiles_krw),'Water, along Z-axis','',strata_trapped.saturation,@(sw)params.krw.func(sw),sub_data(strata_trapped.rel_perm_wat,mask,3));
stat_plot(nexttile(tiles_krw),'Water, along Z-axis','',strata_trapped.saturation,@(sw)params.krw.func(sw),sub_data(strata_trapped.rel_perm_wat,mask,3),true);
yscale(scale);
stat_plot(nexttile(tiles_krw),'Gas, along Z-axis','',strata_trapped.saturation,@(sw) params.krg.func(1-sw),sub_data(strata_trapped.rel_perm_gas,mask,3));
yscale(scale);
Expand All @@ -67,14 +54,15 @@ function curves_plot(mask, strata_trapped, params,scale)
end


function [y_lim, ax] = stat_plot(ax, name, y_label, x_data, base_func, data,color)
function [y_lim, ax] = stat_plot(ax, name, y_label, x_data, base_func, data,show_legend,color)
arguments
ax
name char
y_label char
x_data (1,:) double
base_func
data (:,:) double
show_legend (1,1) logical = false
color = 'blue'
end

Expand All @@ -95,12 +83,14 @@ function curves_plot(mask, strata_trapped, params,scale)
ylabel(ax,y_label);
ax.YLimitMethod="tight";

legends = {'Median','Quantiles 0.01 and 0.99',''};
if ~isempty(base_func)
legends{end+1} = 'Intrinsic curve';
end
if show_legend
legends = {'Median','Quantiles 0.01 and 0.99',''};
if ~isempty(base_func)
legends{end+1} = 'Intrinsic curve';
end

legend(ax,legends,'Location','best');
legend(ax,legends,'Location','best','BackgroundAlpha',0.5);
end

try
[yu,yl,ym] = ax.Children(:).YData;
Expand All @@ -110,4 +100,3 @@ function curves_plot(mask, strata_trapped, params,scale)
y_lim = [nan,nan];
end
end

14 changes: 12 additions & 2 deletions src/CapPressure.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,28 @@
pc = obj.mult * obj.leverett_j.func(sw) * sqrt(poro./perm);
end

function sw = inv(obj,pc,poro,perm)
function lj = inv_lj(obj,pc,poro,perm)
arguments
obj (1,1) CapPressure
pc (1,1) double
pc double
poro double {mustBeNonnegative}
perm double {mustBeNonnegative}
end

perm = obj.transform_perm(poro,perm);

lj = pc ./ obj.mult .* sqrt(perm./poro);
end

function sw = inv(obj,pc,poro,perm)
arguments
obj (1,1) CapPressure
pc (1,1) double
poro double {mustBeNonnegative}
perm double {mustBeNonnegative}
end

lj = obj.inv_lj(pc,poro,perm);
lj = min(lj,obj.leverett_j.data(1,2));
lj = max(lj,obj.leverett_j.data(end,2));

Expand Down

0 comments on commit bdc66c9

Please sign in to comment.