Skip to content

Commit 8e255be

Browse files
committed
fix: 🐛 numerical stability of upscale_permeability
1 parent 98cd4f8 commit 8e255be

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/upscale_permeability.m

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@
1919
y=y0+2;
2020
z=z0+2;
2121

22-
L_sub = [Lx,Ly,Lz];
23-
V_sub = prod(L_sub);
22+
L_sub = [Lx, Ly, Lz];
2423
L = L_sub.*[x0,y0,z0];
25-
V = prod(L);
2624
Nr_ext = [x,y,z];
2725

2826
cond = zeros(x*y*z,3);
2927

3028
dirs=1:3;
29+
mult_common = 1 / prod([x0,y0,z0]);
3130

3231
for dir=dirs
33-
area_to_dist = V_sub/L_sub(dir)^2;
32+
area_to_dist = 1./L_sub(dir).^2;
3433
perm_dir = zeros(x,y,z);
3534
perm_dir(2:end-1,2:end-1,2:end-1) = permeabilities(:,:,:,dir);
3635
cond(:,dir) = perm_dir(:) .* area_to_dist ./ Muw;
@@ -136,9 +135,7 @@
136135

137136
Pin = X1(end);
138137

139-
dist_to_area = L(dir)^2 / V;
140-
141-
Kabs(dir) = Q * Muw * dist_to_area / (Pin-Pout);
138+
Kabs(dir) = Q * Muw / (Pin-Pout) * L(dir).^2 * mult_common;
142139

143140
if isnan(Kabs(dir))
144141
warning('unexpected NaN detected');

0 commit comments

Comments
 (0)