Skip to content

Commit

Permalink
Merge pull request #11 from daavid00/developing
Browse files Browse the repository at this point in the history
Option to remove precomputed values in COMPDAT
  • Loading branch information
daavid00 authored Sep 14, 2024
2 parents 0ecf999 + 216f92b commit 6e81f9d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docs/_sources/introduction.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ where
-z Vector of z-coarsening, see the description for -x ('' by default).
-a Use `min`, `max`, or `mode` to scale the actnum, e.g., min makes the new coarser cell inactive if at least one cell is inactive, while max makes it active it at least one cell is active (`mode` by default).
-n Use `min`, `max`, or `mode` to scale endnum, eqlnum, fipnum, fluxnum, imbnum, miscnum, multnum, pvtnum, rocknum, and satnum (`mode` by default).
-s Use `min`, `max`, or `mean` to scale permx, permy, permz, poro, swatinit, and all mult(-)xyz ('' by default, i.e., using the arithmetic average for permx/permy, harmonic average for permz, and the mean for the rest).
-s Use `min`, `max`, or `mean` to scale permx, permy, permz, poro, swatinit, and all mult(-)xyz ('' by default, i.e., using the arithmetic average for permx/permy, harmonic average for permz, mean for mult(-)xyz, and the pore volume weighted mean for the rest).
-p Add the removed pore volume to the closest coarser cells (`0` by default, `1` to enable).
-r Remove CONFACT and KH from COMPDAT (`1`) and also remove PEQVR (`2`) (ITEM 13, the last entry) to compute the well transmisibility connections internally in OPM Flow using the grid properties (`2` by default; `0` to not remove).
-j Tuning parameter to avoid creation of neighbouring connections in the coarser model where there are discontinuities between cells along the z direction, e.g., around faults ('' by default, i.e., nothing corrected; if need it, try with values of the order of 1).
-m Execute a dry run on the input deck to generate the static properties ('prep'), generate only the coarse files ('deck'), only exectute a dry run on the generated coarse model ('dry'), 'prep_deck', 'deck_dry', or do all ('all') (`prep_deck` by default).
-w Name of the generated deck ('' by default, i.e., the name of the input deck plus _PYCOPM.DATA).
Expand Down
5 changes: 4 additions & 1 deletion docs/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,14 @@ <h2>Roadmap<a class="headerlink" href="#roadmap" title="Link to this heading">
<dd><p>Use <cite>min</cite>, <cite>max</cite>, or <cite>mode</cite> to scale endnum, eqlnum, fipnum, fluxnum, imbnum, miscnum, multnum, pvtnum, rocknum, and satnum (<cite>mode</cite> by default).</p>
</dd>
<dt><kbd><span class="option">-s</span></kbd></dt>
<dd><p>Use <cite>min</cite>, <cite>max</cite>, or <cite>mean</cite> to scale permx, permy, permz, poro, swatinit, and all mult(-)xyz (’’ by default, i.e., using the arithmetic average for permx/permy, harmonic average for permz, and the mean for the rest).</p>
<dd><p>Use <cite>min</cite>, <cite>max</cite>, or <cite>mean</cite> to scale permx, permy, permz, poro, swatinit, and all mult(-)xyz (’’ by default, i.e., using the arithmetic average for permx/permy, harmonic average for permz, mean for mult(-)xyz, and the pore volume weighted mean for the rest).</p>
</dd>
<dt><kbd><span class="option">-p</span></kbd></dt>
<dd><p>Add the removed pore volume to the closest coarser cells (<cite>0</cite> by default, <cite>1</cite> to enable).</p>
</dd>
<dt><kbd><span class="option">-r</span></kbd></dt>
<dd><p>Remove CONFACT and KH from COMPDAT (<cite>1</cite>) and also remove PEQVR (<cite>2</cite>) (ITEM 13, the last entry) to compute the well transmisibility connections internally in OPM Flow using the grid properties (<cite>2</cite> by default; <cite>0</cite> to not remove).</p>
</dd>
<dt><kbd><span class="option">-j</span></kbd></dt>
<dd><p>Tuning parameter to avoid creation of neighbouring connections in the coarser model where there are discontinuities between cells along the z direction, e.g., around faults (’’ by default, i.e., nothing corrected; if need it, try with values of the order of 1).</p>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/text/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ where
-z Vector of z-coarsening, see the description for -x ('' by default).
-a Use `min`, `max`, or `mode` to scale the actnum, e.g., min makes the new coarser cell inactive if at least one cell is inactive, while max makes it active it at least one cell is active (`mode` by default).
-n Use `min`, `max`, or `mode` to scale endnum, eqlnum, fipnum, fluxnum, imbnum, miscnum, multnum, pvtnum, rocknum, and satnum (`mode` by default).
-s Use `min`, `max`, or `mean` to scale permx, permy, permz, poro, swatinit, and all mult(-)xyz ('' by default, i.e., using the arithmetic average for permx/permy, harmonic average for permz, and the mean for the rest).
-s Use `min`, `max`, or `mean` to scale permx, permy, permz, poro, swatinit, and all mult(-)xyz ('' by default, i.e., using the arithmetic average for permx/permy, harmonic average for permz, mean for mult(-)xyz, and the pore volume weighted mean for the rest).
-p Add the removed pore volume to the closest coarser cells (`0` by default, `1` to enable).
-r Remove CONFACT and KH from COMPDAT (`1`) and also remove PEQVR (`2`) (ITEM 13, the last entry) to compute the well transmisibility connections internally in OPM Flow using the grid properties (`2` by default; `0` to not remove).
-j Tuning parameter to avoid creation of neighbouring connections in the coarser model where there are discontinuities between cells along the z direction, e.g., around faults ('' by default, i.e., nothing corrected; if need it, try with values of the order of 1).
-m Execute a dry run on the input deck to generate the static properties ('prep'), generate only the coarse files ('deck'), only exectute a dry run on the generated coarse model ('dry'), 'prep_deck', 'deck_dry', or do all ('all') (`prep_deck` by default).
-w Name of the generated deck ('' by default, i.e., the name of the input deck plus _PYCOPM.DATA).
Expand Down
12 changes: 11 additions & 1 deletion src/pycopm/core/pycopm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def pycopm():
dic["mode"] = cmdargs["mode"].strip() # What to run
dic["label"] = cmdargs["label"].strip() # Prefix to the generted inc files
dic["ijk"] = cmdargs["ijk"].strip() # ijk indices to map to the coarse model
dic["remove"] = int(cmdargs["remove"].strip()) # Remove CONFACT and KH
dic["encoding"] = cmdargs["encoding"].strip()
dic["pvcorr"] = int(cmdargs["pvcorr"])
dic["cijk"] = "yes"
Expand Down Expand Up @@ -177,14 +178,23 @@ def load_parser():
default="",
help="Use 'min', 'max', or 'mean' to scale permx, permy, permz, poro, swatinit, and all "
"mult(-)xyz ('' by default, i.e., using the arithmetic average for permx/permy, harmonic"
" average for permz, and the mean for the rest).",
" average for permz, mean for mult(-)xyz, and the pore volume weighted mean for the "
"rest).",
)
parser.add_argument(
"-p",
"--pvcorr",
default=0,
help="Add the removed pore volume to the closest coarser cells ('0' by default).",
)
parser.add_argument(
"-r",
"--remove",
default="2",
help="Remove CONFACT and KH from COMPDAT (1) and also remove PEQVR (2) (ITEM 13, the "
"last entry) to compute the well transmisibility connections internally in OPM Flow "
"using the grid properties ('2' by default; '0' to not remove).",
)
parser.add_argument(
"-j",
"--jump",
Expand Down
37 changes: 23 additions & 14 deletions src/pycopm/utils/generate_coarser_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_deck(dic):
)
sys.exit()
dic["field"] = "generic"
dic["props"] = ["poro", "permx", "permy", "permz"]
dic["props"] = ["permx", "permy", "permz", "poro"]
dic["base"] = dic["props"] + ["grid"]
dic["regions"] = []
dic["grids"] = []
Expand Down Expand Up @@ -137,16 +137,17 @@ def create_deck(dic):
n
]
if not dic["show"]:
dic["permx"][cell.global_index] = (
dic["ini"].iget_kw("PERMX")[0][n] * d_z[cell.global_index]
)
dic["permy"][cell.global_index] = (
dic["ini"].iget_kw("PERMY")[0][n] * d_z[cell.global_index]
)
if dic["ini"].iget_kw("PERMZ")[0][n] != 0:
dic["permx"][cell.global_index] *= d_z[cell.global_index]
dic["permy"][cell.global_index] *= d_z[cell.global_index]
if dic["permz"][cell.global_index] != 0:
dic["permz"][cell.global_index] = (
d_z[cell.global_index] / dic["ini"].iget_kw("PERMZ")[0][n]
d_z[cell.global_index] / dic["permz"][cell.global_index]
)
dic["poro"][cell.global_index] *= dic["porv"][cell.global_index]
if "swatinit" in dic["props"]:
dic["swatinit"][cell.global_index] *= dic["porv"][
cell.global_index
]
n += 1

# Coarsening
Expand Down Expand Up @@ -229,24 +230,26 @@ def map_properties(dic, actnum, d_z, z_t, z_b, z_b_t):
else:
rmv = 0 * dz_c + 1
dic["actnum_c"] = [int(val) for val in clust]
c_c = pd.Series(dic["porv"]).groupby(dic["con"]).sum()
dic["porv_c"] = [f"{val}" for val in c_c]
p_vs = pd.Series(dic["porv"]).groupby(dic["con"]).sum()
dic["porv_c"] = [f"{val}" for val in p_vs]
for name in dic["props"]:
if not dic["show"]:
c_c = pd.Series(dic[name]).groupby(dic["con"]).sum()
if name in ["permx", "permy"]:
c_c = pd.Series(dic[name]).groupby(dic["con"]).sum()
dic[f"{name}_c"] = [
f"{val/h_t}" if h_t * val > 0 else "0"
for val, h_t in zip(c_c, h_tot)
]
elif name == "permz":
c_c = pd.Series(dic[name]).groupby(dic["con"]).sum()
dic["permz_c"] = [
f"{h_t/val}" if h_t * val > 0 else "0"
for val, h_t in zip(c_c, h_tot)
]
elif name in ["poro", "swatinit"]:
dic[f"{name}_c"] = [
f"{val/p_v}" if p_v > 0 else "0" for val, p_v in zip(c_c, p_vs)
]
else:
c_c = pd.Series(dic[name]).groupby(dic["con"]).sum()
dic[f"{name}_c"] = [
f"{val/fre}" if fre > 0 else "0" for val, fre in zip(c_c, freq)
]
Expand Down Expand Up @@ -877,6 +880,12 @@ def handle_segmented_wells(dic, nrwo):
edit[2] = str(dic["jc"][int(edit[2])])
edit[3] = str(dic["kc"][int(edit[3])])
edit[4] = str(dic["kc"][int(edit[4])])
if dic["remove"] > 0 and len(edit) > 7:
edit[7] = "1*"
if dic["remove"] > 0 and len(edit) > 9:
edit[9] = "1*"
if dic["remove"] > 1 and len(edit) > 12:
edit[-2] = ""
dic["lol"].append(" ".join(edit))
return True
if dic["compsegs"]:
Expand Down

0 comments on commit 6e81f9d

Please sign in to comment.