Skip to content

Commit ac9eb0b

Browse files
authored
Merge pull request #66 from daavid00/spe11cMassMap
Fix to reporting spatial maps spe11c
2 parents bab48d4 + 77b4c96 commit ac9eb0b

File tree

1 file changed

+46
-10
lines changed
  • src/pyopmspe11/visualization

1 file changed

+46
-10
lines changed

src/pyopmspe11/visualization/data.py

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -968,11 +968,23 @@ def handle_yaxis_mapping_extensive(dig, dil):
968968
simycent = [0.0] * dig["gxyz"][1]
969969
with open(f"{dig['path']}/deck/ycenters.txt", "r", encoding="utf8") as file:
970970
for j, row in enumerate(csv.reader(file)):
971-
simycent[j] = float(row[0])
971+
simycent[j] = float(f"{float(row[0]):.1f}")
972+
simyvert = [0]
973+
for ycent in simycent:
974+
simyvert.append(simyvert[-1] + 2 * (ycent - simyvert[-1]))
972975
indy = np.array(
973976
[pd.Series(np.abs(dil["refycent"] - y_c)).argmin() for y_c in simycent]
974977
)
975-
weights = [1.0 / (np.sum(indy == val)) for val in indy]
978+
weights = []
979+
ind = 0
980+
for i, (y_i, y_f) in enumerate(zip(simyvert[:-1], simyvert[1:])):
981+
if dil["refyvert"][ind] <= y_i and y_f <= dil["refyvert"][ind + 1]:
982+
weights.append([1.0])
983+
else:
984+
weights.append([])
985+
weights[-1].append((dil["refyvert"][ind + 1] - y_i) / (y_f - y_i))
986+
weights[-1].append((y_f - dil["refyvert"][ind + 1]) / (y_f - y_i))
987+
ind += 1
976988
wei_inds = [[] for _ in range(dig["nocellst"])]
977989
for indz in range(dig["gxyz"][2]):
978990
i_i = dig["gxyz"][0] * (dig["gxyz"][2] - indz - 1)
@@ -984,7 +996,7 @@ def handle_yaxis_mapping_extensive(dig, dil):
984996
+ int(np.floor(col[0] / dig["nxyz"][0]))
985997
* dig["nxyz"][0]
986998
* (dig["nxyz"][1] - 1),
987-
col[1] * weights[0],
999+
col[1] * weights[0][0],
9881000
]
9891001
for col in row
9901002
]
@@ -996,11 +1008,34 @@ def handle_yaxis_mapping_extensive(dig, dil):
9961008
iii + dig["gxyz"][0] * (j + 1) : iii + dig["gxyz"][0] * (j + 2)
9971009
] = [
9981010
[
999-
[col[0] + (iy * dig["nxyz"][0]), col[1] * weights[j + 1]]
1011+
[col[0] + (iy * dig["nxyz"][0]), col[1] * weights[j + 1][0]]
10001012
for col in row
10011013
]
10021014
for row in maps
10031015
]
1016+
for weight in weights[j + 1][1:]:
1017+
for i, val in enumerate(
1018+
wei_inds[
1019+
iii + dig["gxyz"][0] * (j + 1) : iii + dig["gxyz"][0] * (j + 2)
1020+
]
1021+
):
1022+
if wei_inds[
1023+
iii + dig["gxyz"][0] * (j + 1) : iii + dig["gxyz"][0] * (j + 2)
1024+
][i]:
1025+
wei_inds[
1026+
iii
1027+
+ dig["gxyz"][0] * (j + 1) : iii
1028+
+ dig["gxyz"][0] * (j + 2)
1029+
][i].append(
1030+
[
1031+
(
1032+
val[0][0] + dig["nxyz"][0]
1033+
if val[0][0] + dig["nxyz"][0] < dig["nocellsr"]
1034+
else val[0][0]
1035+
),
1036+
weight,
1037+
]
1038+
)
10041039
dil["cell_ind"] = wei_inds
10051040

10061041

@@ -1377,13 +1412,13 @@ def generate_arrays(dig, dil, names, t_n):
13771412
co2_d = rss * rhow * (1.0 - sgas) * dig["porva"] * GAS_DEN_REF / WAT_DEN_REF
13781413
h2o_l = (1 - sgas) * rhow * dig["porva"]
13791414
dil["pressure_array"][dig["actind"]] = 1e5 * pres
1380-
dil["sgas_array"][dig["actind"]] = sgas
1381-
dil["gden_array"][dig["actind"]] = rhog * (sgas > 0.0)
1415+
dil["sgas_array"][dig["actind"]] = sgas * (sgas > 0.02)
1416+
dil["gden_array"][dig["actind"]] = rhog * (sgas > 0.02)
13821417
dil["wden_array"][dig["actind"]] = rhow
13831418
dil["tco2_array"][dig["actind"]] = co2_d + co2_g
13841419
compute_xco2(dig, dil, co2_d, h2o_l)
13851420
h2o_v = rvv * rhog * sgas * dig["porva"] * WAT_DEN_REF / GAS_DEN_REF
1386-
compute_xh20(dig, dil, h2o_v, co2_g)
1421+
compute_xh20(dig, dil, h2o_v, co2_g, sgas)
13871422

13881423

13891424
def compute_xco2(dig, dil, co2_d, h2o_l):
@@ -1407,15 +1442,16 @@ def compute_xco2(dig, dil, co2_d, h2o_l):
14071442
dil["xco2_array"][dig["actind"]] = xco2
14081443

14091444

1410-
def compute_xh20(dig, dil, h2o_v, co2_g):
1445+
def compute_xh20(dig, dil, h2o_v, co2_g, sgas):
14111446
"""
14121447
Compute the mass fraction of water in vapour
14131448
14141449
Args:
14151450
dig (dict): Global dictionary\n
14161451
dil (dict): Local dictionary\n
14171452
h2o_v (array): Floats with the mass of vaporized water\n
1418-
co2_g (array): Floats with the mass of gaseous co2
1453+
co2_g (array): Floats with the mass of gaseous co2\n
1454+
sgas (array): Floats with the gas saturation
14191455
14201456
Returns:
14211457
dil (dict): Modified local dictionary
@@ -1425,7 +1461,7 @@ def compute_xh20(dig, dil, h2o_v, co2_g):
14251461
xh20 = 0.0 * h2o_v
14261462
inds = mgas > 0.0
14271463
xh20[inds] = np.divide(h2o_v[inds], mgas[inds])
1428-
dil["xh20_array"][dig["actind"]] = xh20
1464+
dil["xh20_array"][dig["actind"]] = xh20 * (sgas > 0.02)
14291465

14301466

14311467
def map_to_report_grid(dig, dil, names):

0 commit comments

Comments
 (0)