Skip to content

Commit

Permalink
Merge pull request #52 from daavid00/documentation
Browse files Browse the repository at this point in the history
Bringing back y-cord in dense data for spe11c
  • Loading branch information
daavid00 authored May 28, 2024
2 parents b95289a + 467170b commit ee61829
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 33 deletions.
99 changes: 75 additions & 24 deletions src/pyopmspe11/visualization/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,33 +1045,58 @@ def write_dense_data_performance_spatial(dig, dil, i):
name_t = f"{round(dig['dense_t'][i]/3600)}h"
else:
name_t = f"{round(dig['dense_t'][i]/SECONDS_IN_YEAR)}y"
text = [
"# x [m], z [m], cvol [m^3], arat [-], CO2 max_norm_res [-], "
+ "H2O max_norm_res [-], CO2 mb_error [-], H2O mb_error [-], "
+ "post_est [-]"
]
if dig["case"] != "spe11c":
text = [
"# x [m], z [m], cvol [m^3], arat [-], CO2 max_norm_res [-], "
+ "H2O max_norm_res [-], CO2 mb_error [-], H2O mb_error [-], "
+ "post_est [-]"
]
else:
text = [
"# x [m], y [m], z [m], cvol [m^3], arat [-], CO2 max_norm_res [-], "
+ "H2O max_norm_res [-], CO2 mb_error [-], H2O mb_error [-], "
+ "post_est [-]"
]
idz = 0
for zcord in dil["refzcent"]:
idxy = 0
for _ in dil["refycent"]:
for ycord in dil["refycent"]:
for xcord in dil["refxcent"]:
idc = -dig["nxyz"][0] * dig["nxyz"][1] * (dig["nxyz"][2] - idz) + idxy
if np.isnan(dil["cvol_refg"][idc]):
text.append(
f"{xcord:.3e}, {zcord:.3e}, n/a, n/a, n/a, n/a, n/a, "
+ "n/a, n/a"
)
if dig["case"] != "spe11c":
if np.isnan(dil["cvol_refg"][idc]):
text.append(
f"{xcord:.3e}, {zcord:.3e}, n/a, n/a, n/a, n/a, n/a, "
+ "n/a, n/a"
)
else:
text.append(
f"{xcord:.3e}, {zcord:.3e}, "
+ f"{dil['cvol_refg'][idc] :.3e}, "
+ f"{dil['arat_refg'][idc] :.3e}, "
+ f"{dil['co2mn_refg'][idc] :.3e}, "
+ f"{dil['h2omn_refg'][idc] :.3e}, "
+ f"{dil['co2mb_refg'][idc] :.3e}, "
+ f"{dil['h2omb_refg'][idc] :.3e}, "
+ "n/a"
)
else:
text.append(
f"{xcord:.3e}, {zcord:.3e}, "
+ f"{dil['cvol_refg'][idc] :.3e}, "
+ f"{dil['arat_refg'][idc] :.3e}, "
+ f"{dil['co2mn_refg'][idc] :.3e}, "
+ f"{dil['h2omn_refg'][idc] :.3e}, "
+ f"{dil['co2mb_refg'][idc] :.3e}, "
+ f"{dil['h2omb_refg'][idc] :.3e}, "
+ "n/a"
)
if np.isnan(dil["cvol_refg"][idc]):
text.append(
f"{xcord:.3e}, {ycord:.3e}, {zcord:.3e}, n/a, n/a, n/a, "
+ "n/a, n/a, n/a, n/a"
)
else:
text.append(
f"{xcord:.3e}, {ycord:.3e}, {zcord:.3e}, "
+ f"{dil['cvol_refg'][idc] :.3e}, "
+ f"{dil['arat_refg'][idc] :.3e}, "
+ f"{dil['co2mn_refg'][idc] :.3e}, "
+ f"{dil['h2omn_refg'][idc] :.3e}, "
+ f"{dil['co2mb_refg'][idc] :.3e}, "
+ f"{dil['h2omb_refg'][idc] :.3e}, "
+ "n/a"
)
idxy += 1
idz += 1
with open(
Expand Down Expand Up @@ -1171,7 +1196,7 @@ def write_dense_data(dig, dil, i):
idz = 0
for zcord in dil["refzcent"]:
idxy = 0
for _ in dil["refycent"]:
for ycord in dil["refycent"]:
for xcord in dil["refxcent"]:
idc = -dig["nxyz"][0] * dig["nxyz"][1] * (dig["nxyz"][2] - idz) + idxy
if np.isnan(dil["tco2_refg"][idc]):
Expand All @@ -1195,7 +1220,7 @@ def write_dense_data(dig, dil, i):
+ f"{dil['wden_refg'][idc] :.3e}, "
+ f"{co2}"
)
else:
elif dig["case"] == "spe11b":
if np.isnan(dil["pressure_refg"][idc]):
text.append(
f"{xcord:.3e}, {zcord:.3e}, "
Expand All @@ -1213,6 +1238,24 @@ def write_dense_data(dig, dil, i):
+ f"{co2}, "
+ f"{dil['temp_refg'][idc] :.3e}"
)
else:
if np.isnan(dil["pressure_refg"][idc]):
text.append(
f"{xcord:.3e}, {ycord:.3e}, {zcord:.3e}, "
+ f"n/a, n/a, n/a, n/a, n/a, n/a, {co2}, n/a"
)
else:
text.append(
f"{xcord:.3e}, {ycord:.3e}, {zcord:.3e}, "
+ f"{dil['pressure_refg'][idc] :.3e}, "
+ f"{dil['sgas_refg'][idc] :.3e}, "
+ f"{dil['xco2_refg'][idc] :.3e}, "
+ f"{dil['xh20_refg'][idc] :.3e}, "
+ f"{dil['gden_refg'][idc] :.3e}, "
+ f"{dil['wden_refg'][idc] :.3e}, "
+ f"{co2}, "
+ f"{dil['temp_refg'][idc] :.3e}"
)
idxy += 1
idz += 1
with open(
Expand All @@ -1231,14 +1274,22 @@ def get_header(dig, i):
+ "phase mass density gas [kg/m3], phase mass density water [kg/m3], "
+ "total mass CO2 [kg]"
]
else:
elif dig["case"] == "spe11b":
name_t = f"{round(dig['dense_t'][i]/SECONDS_IN_YEAR)}y"
text = [
"# x [m], z [m], pressure [Pa], gas saturation [-], "
+ "mass fraction of CO2 in liquid [-], mass fraction of H20 in vapor [-], "
+ "phase mass density gas [kg/m3], phase mass density water [kg/m3], "
+ "total mass CO2 [kg], temperature [C]"
]
else:
name_t = f"{round(dig['dense_t'][i]/SECONDS_IN_YEAR)}y"
text = [
"# x [m], y [m], z [m], pressure [Pa], gas saturation [-], "
+ "mass fraction of CO2 in liquid [-], mass fraction of H20 in vapor [-], "
+ "phase mass density gas [kg/m3], phase mass density water [kg/m3], "
+ "total mass CO2 [kg], temperature [C]"
]
return name_t, text


Expand Down
26 changes: 17 additions & 9 deletions src/pyopmspe11/visualization/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ def plot_results(dic):
dic["where"] = f"{dic['exe']}/{dic['folders'][0]}/figures"
if dic["case"] == "spe11a":
dic["tlabel"] = "h"
dic["dims"] = 2
dic["tscale"] = 3600.0
else:
dic["tlabel"] = "y"
dic["dims"] = 2
dic["tscale"] = SECONDS_IN_YEAR
if dic["case"] == "spe11c":
dic["dims"] = 3
if dic["generate"] in [
"all",
"performance",
Expand Down Expand Up @@ -298,14 +302,17 @@ def generate_grid(dic):
skip_header=1,
)
dic["length"] = csv[-1][0] + csv[0][0]
dic["height"] = csv[-1][1] + csv[0][1]
dic["width"] = csv[-1][dic["dims"] - 2] + csv[0][dic["dims"] - 2]
dic["height"] = csv[-1][dic["dims"] - 1] + csv[0][dic["dims"] - 1]
dic["xmx"] = np.linspace(
0, dic["length"], round(dic["length"] / (2.0 * csv[0][0])) + 1
)
dic["ymy"] = np.linspace(
0, dic["width"], round(dic["width"] / (2.0 * csv[0][dic["dims"] - 2])) + 1
)
dic["zmz"] = np.linspace(
0, dic["height"], round(dic["height"] / (2.0 * csv[0][1])) + 1
0, dic["height"], round(dic["height"] / (2.0 * csv[0][dic["dims"] - 1])) + 1
)
dic["ny"] = int(len(csv) / ((len(dic["xmx"]) - 1) * (len(dic["zmz"]) - 1)))
dic["xmsh"], dic["zmsh"] = np.meshgrid(dic["xmx"], dic["zmz"][::-1])
if dic["generate"] in ["all", "dense_performance-spatial"]:
dic["kinds"] = ["", "_performance"]
Expand Down Expand Up @@ -391,7 +398,7 @@ def dense_data(dic):
delimiter=",",
skip_header=1,
)
quan = np.array([csv[i][2 + k] for i in range(csv.shape[0])])
quan = np.array([csv[i][dic["dims"] + k] for i in range(csv.shape[0])])
dic["minc"], dic["maxc"] = (
quan[~np.isnan(quan)].min(),
quan[~np.isnan(quan)].max(),
Expand All @@ -403,7 +410,7 @@ def dense_data(dic):
delimiter=",",
skip_header=1,
)
quan = np.array([csv[i][2 + k] for i in range(csv.shape[0])])
quan = np.array([csv[i][dic["dims"] + k] for i in range(csv.shape[0])])
dic["min"].append(quan[~np.isnan(quan)].min())
dic["max"].append(quan[~np.isnan(quan)].max())
if quantity == "tco2":
Expand All @@ -418,12 +425,13 @@ def dense_data(dic):
]
else:
dic["plot"][-1][-1 - i, :] = quan[
(i * dic["ny"] * (len(dic["xmx"]) - 1))
+ mt.floor(dic["ny"] / 2)
(i * (len(dic["ymy"]) - 1) * (len(dic["xmx"]) - 1))
+ mt.floor((len(dic["ymy"]) - 1) / 2)
* (len(dic["xmx"]) - 1) : (
(len(dic["xmx"]) - 1)
+ i * dic["ny"] * (len(dic["xmx"]) - 1)
+ mt.floor(dic["ny"] / 2) * (len(dic["xmx"]) - 1)
+ i * (len(dic["ymy"]) - 1) * (len(dic["xmx"]) - 1)
+ mt.floor((len(dic["ymy"]) - 1) / 2)
* (len(dic["xmx"]) - 1)
)
]
for j, time in enumerate(dic["ptimes"]):
Expand Down

0 comments on commit ee61829

Please sign in to comment.