Skip to content

Commit 5e54a42

Browse files
authored
Merge pull request #62 from daavid00/memmory
Using rssat to compute M
2 parents 7d230cb + a11b8ac commit 5e54a42

File tree

9 files changed

+36
-21
lines changed

9 files changed

+36
-21
lines changed

examples/finner_grids/spe11a1mm_nldd_tuned.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Set the full path to the flow executable and flags"""
22
mpirun -np 12 flow --nonlinear-solver=nldd --matrix-add-well-contributions=1 --tolerance-mb=1e-7 --linear-solver=cpr_trueimpes --enable-tuning=false --solver-max-time-step-in-days=0.02 --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations --newton-min-iterations=1 --threads-per-process=1 --time-step-control-target-newton-iterations=2 --time-step-control-growth-rate=1.15 --time-step-control-decay-rate=0.85 --newton-max-iterations=6 --min-time-step-before-shutting-problematic-wells-in-days=1e-99 --relaxed-max-pv-fraction=0 --min-strict-cnv-iter=8 --tolerance-cnv-relaxed=1e-2 --tolerance-cnv=1e-3 --local-domains-ordering-measure=residual --time-step-control=newtoniterationcount --use-update-stabilization=0 --enable-drift-compensation=0 --max-local-solve-iterations=50 --linear-solver-max-iter=50
3+
34
"""Set the model parameters"""
45
spe11a master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
56
complete gaswater #Name of the co2 model (immiscible or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])

src/pyopmspe11/core/pyopmspe11.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def pyopmspe11():
4545
os.system(f"mkdir {dic['exe']}/{dic['fol']}/{fil}")
4646
os.chdir(f"{dic['exe']}/{dic['fol']}")
4747

48-
if dic["mode"] in ["all", "deck", "deck_flow", "deck_flow_data"]:
48+
if dic["mode"] == "all" or "deck" in dic["mode"]:
4949
# Initialize the grid
5050
grid(dic)
5151
# For corner-point grids, get the cell centers by executing flow
@@ -60,18 +60,17 @@ def pyopmspe11():
6060
positions(dic)
6161
# Write used opm related files
6262
opm_files(dic)
63-
64-
if dic["mode"] in ["all", "flow", "deck_flow", "flow_data", "deck_flow_data"]:
63+
if dic["mode"] == "all" or "flow" in dic["mode"]:
6564
# Run the simulations
6665
simulations(dic, dic["fol"].upper(), "flow")
6766

68-
if dic["mode"] in ["all", "data", "flow_data", "deck_flow_data", "data_plot"]:
67+
if dic["mode"] == "all" or "data" in dic["mode"]:
6968
# Write the data
7069
if not os.path.exists(f"{dic['exe']}/{dic['fol']}/data"):
7170
os.system(f"mkdir {dic['exe']}/{dic['fol']}/data")
7271
data(dic)
7372

74-
if dic["mode"] in ["all", "plot", "data_plot"]:
73+
if dic["mode"] == "all" or "plot" in dic["mode"]:
7574
# Make some useful plots after the studies
7675
if not os.path.exists(f"{dic['exe']}/{dic['fol']}/figures"):
7776
os.system(f"mkdir {dic['exe']}/{dic['fol']}/figures")
@@ -97,8 +96,9 @@ def load_parser():
9796
help="Run the whole framework ('all'), only create decks ('deck'), "
9897
"only run flow ('flow'), only write benchmark data ('data'), "
9998
"only create plots ('plot'), deck and run ('deck_flow'), "
100-
"data and plot ('data_plot'), run and data ('flow_data'), or deck, "
101-
"run, and data ('deck_flow_data') ('deck_flow' by default).",
99+
"data and plot ('data_plot'), run and data ('flow_data'), deck, "
100+
"run, and data ('deck_flow_data'), or flow, data, and plot "
101+
"('flow_data_plot') ('deck_flow' by default).",
102102
)
103103
parser.add_argument(
104104
"-c",

src/pyopmspe11/templates/co2/spe11a.mako

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ WELLDIMS
4242
${len(dic['wellijk'])} ${dic['noCells'][2]} ${len(dic['wellijk'])} ${len(dic['wellijk'])} /
4343
% endif
4444

45-
UNIFIN
4645
UNIFOUT
4746
----------------------------------------------------------------------------
4847
GRID
@@ -145,7 +144,7 @@ RPTRST
145144
% if dic['model'] == 'immiscible':
146145
'BASIC=2' FLOWS FLORES DEN/
147146
% else:
148-
'BASIC=2' DEN ${'PCGW' if dic["co2store"] == "gaswater" else ''}/
147+
'BASIC=2' DEN ${'PCGW' if dic["co2store"] == "gaswater" else ''} ${'RSWSAT' if dic["version"] == "master" and dic["co2store"] == "gaswater" else ''} ${'RSSAT' if dic["version"] == "master" and dic["co2store"] == "gasoil" else ''}/
149148
% endif
150149

151150
% if dic['model'] == 'complete':
@@ -193,10 +192,10 @@ ${sensor[0]+1} ${sensor[1]+1} ${sensor[2]+1} /
193192
SCHEDULE
194193
----------------------------------------------------------------------------
195194
RPTRST
196-
% if dic['model'] == 'immiscible':
195+
% if dic['model'] == 'immiscible':
197196
'BASIC=2' FLOWS FLORES DEN/
198197
% else:
199-
'BASIC=2' DEN RESIDUAL ${'PCGW' if dic["co2store"] == "gaswater" else ''}/
198+
'BASIC=2' DEN RESIDUAL ${'PCGW' if dic["co2store"] == "gaswater" else ''} ${'RSWSAT' if dic["version"] == "master" and dic["co2store"] == "gaswater" else ''} ${'RSSAT' if dic["version"] == "master" and dic["co2store"] == "gasoil" else ''}/
200199
% endif
201200

202201
% if sum(dic['radius']) > 0:

src/pyopmspe11/templates/co2/spe11b.mako

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ WELLDIMS
4646
${len(dic['wellijk'])} ${dic['noCells'][2]} ${len(dic['wellijk'])} ${len(dic['wellijk'])} /
4747
% endif
4848

49-
UNIFIN
5049
UNIFOUT
5150
----------------------------------------------------------------------------
5251
GRID
@@ -161,7 +160,7 @@ RPTRST
161160
% if dic['model'] == 'immiscible':
162161
'BASIC=2' FLOWS FLORES DEN/
163162
% else:
164-
'BASIC=2' DEN ${'PCGW' if dic["co2store"] == "gaswater" else ''}/
163+
'BASIC=2' DEN ${'PCGW' if dic["co2store"] == "gaswater" else ''} ${'RSWSAT' if dic["version"] == "master" and dic["co2store"] == "gaswater" else ''} ${'RSSAT' if dic["version"] == "master" and dic["co2store"] == "gasoil" else ''}/
165164
% endif
166165

167166
% if dic['model'] == 'complete':
@@ -212,7 +211,7 @@ RPTRST
212211
% if dic['model'] == 'immiscible':
213212
'BASIC=2' FLOWS FLORES DEN/
214213
% else:
215-
'BASIC=2' DEN RESIDUAL ${'PCGW' if dic["co2store"] == "gaswater" else ''}/
214+
'BASIC=2' DEN RESIDUAL ${'PCGW' if dic["co2store"] == "gaswater" else ''} ${'RSWSAT' if dic["version"] == "master" and dic["co2store"] == "gaswater" else ''} ${'RSSAT' if dic["version"] == "master" and dic["co2store"] == "gasoil" else ''}/
216215
% endif
217216

218217
% if dic['model'] == 'complete':

src/pyopmspe11/templates/co2/spe11c.mako

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ WELLDIMS
4646
${len(dic['wellijk'])} ${1+max(dic['wellijkf'][0][1]-dic['wellijk'][0][1], dic['wellijkf'][1][1]-dic['wellijk'][1][1])} ${len(dic['wellijk'])} ${len(dic['wellijk'])} /
4747
% endif
4848

49-
UNIFIN
5049
UNIFOUT
5150
----------------------------------------------------------------------------
5251
GRID
@@ -142,7 +141,7 @@ RPTRST
142141
% if dic['model'] == 'immiscible':
143142
'BASIC=2' FLOWS FLORES DEN/
144143
% else:
145-
'BASIC=2' DEN ${'PCGW' if dic["co2store"] == "gaswater" else ''}/
144+
'BASIC=2' DEN ${'PCGW' if dic["co2store"] == "gaswater" else ''} ${'RSWSAT' if dic["version"] == "master" and dic["co2store"] == "gaswater" else ''} ${'RSSAT' if dic["version"] == "master" and dic["co2store"] == "gasoil" else ''}/
146145
% endif
147146

148147
% if dic['model'] == 'complete':
@@ -193,7 +192,7 @@ RPTRST
193192
% if dic['model'] == 'immiscible':
194193
'BASIC=2' FLOWS FLORES DEN/
195194
% else:
196-
'BASIC=2' DEN RESIDUAL ${'PCGW' if dic["co2store"] == "gaswater" else ''}/
195+
'BASIC=2' DEN RESIDUAL ${'PCGW' if dic["co2store"] == "gaswater" else ''} ${'RSWSAT' if dic["version"] == "master" and dic["co2store"] == "gaswater" else ''} ${'RSSAT' if dic["version"] == "master" and dic["co2store"] == "gasoil" else ''}/
197196
% endif
198197

199198
% if dic['model'] == 'complete':

src/pyopmspe11/visualization/data.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,17 @@ def compute_m_c(dig, dil):
699699
inds = mliq > 0.0
700700
xco2[inds] = np.divide(co2_d[inds], mliq[inds])
701701
dil["xcw"] = xco2
702-
if dil["xcw_max"] != 0:
702+
if dil["xcw_max"] > 0:
703703
dil["xcw"] /= dil["xcw_max"]
704+
if dil["xcw_max"] == -1:
705+
if dig["use"] == "opm":
706+
rssat = np.array(dig["unrst"][f"{dig['r_s'].upper()}SAT", t_n])
707+
else:
708+
rssat = np.array(dig["unrst"][f"{dig['r_s'].upper()}SAT"][t_n])
709+
co2_d_max = (
710+
rssat * rhow * (1.0 - sgas) * dig["porva"] * GAS_DEN_REF / WAT_DEN_REF
711+
)
712+
dil["xcw"] = np.divide(dil["xcw"], np.divide(co2_d_max, co2_d_max + h2o_l))
704713
if dig["case"] != "spe11c":
705714
dil["m_c"].append(
706715
np.sum(
@@ -810,6 +819,14 @@ def max_xcw(dig, dil):
810819
811820
"""
812821
dil["xcw_max"] = 0
822+
if dig["use"] == "opm":
823+
if dig["unrst"].count(f"{dig['r_s'].upper()}SAT", 0):
824+
dil["xcw_max"] = -1
825+
return
826+
else:
827+
if dig["unrst"].has_kw(f"{dig['r_s'].upper()}SAT"):
828+
dil["xcw_max"] = -1
829+
return
813830
for t_n in range(dig["no_skip_rst"], dig["norst"]):
814831
if dig["use"] == "opm":
815832
sgas = abs(np.array(dig["unrst"]["SGAS", t_n]))

tests/configs/spe11a_data_format.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
flow --tolerance-mb=1e-7 --linear-solver=cprw --newton-min-iterations=1 --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations
33

44
"""Set the model parameters"""
5-
spe11a master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
5+
spe11a release #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
66
complete gaswater #Name of the co2 model (immiscible or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
77
cartesian #Type of grid (cartesian, tensor, or corner-point)
88
2.8 0.01 1.2 #Length, width, and depth [m]

tests/configs/spe11b_data_format.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
flow --tolerance-mb=1e-7 --linear-solver=cprw --newton-min-iterations=1 --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations
33

44
"""Set the model parameters"""
5-
spe11b master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
5+
spe11b release #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
66
complete gaswater #Name of the co2 model (immiscible or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
77
cartesian #Type of grid (cartesian, tensor, or corner-point)
88
8400 1 1200 #Length, width, and depth [m]

tests/configs/spe11c_data_format.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
flow --tolerance-mb=1e-7 --linear-solver=cprw --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations --newton-min-iterations=1
33

44
"""Set the model parameters"""
5-
spe11c master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
5+
spe11c release #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
66
complete gaswater #Name of the co2 model (immiscible or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
77
corner-point #Type of grid (cartesian, tensor, or corner-point)
88
8400 5000 1200 #Length, width, and depth [m]

0 commit comments

Comments
 (0)