Skip to content

Commit

Permalink
Merge pull request #8 from daavid00/developing
Browse files Browse the repository at this point in the history
Adding rotation of sites and 3d general pressure projection
  • Loading branch information
daavid00 authored May 30, 2024
2 parents 51d69ea + 37d0ec4 commit 38565b0
Show file tree
Hide file tree
Showing 16 changed files with 843 additions and 91 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ opm-simulators/
tests/configs/back
tests/configs/compare
tests/configs/output
tests/configs/rotate
examples/output
developing
playground
debugging
vexpreccs
workshop
Expand Down
80 changes: 34 additions & 46 deletions src/expreccs/core/expreccs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,11 @@
import time
import argparse
from expreccs.utils.inputvalues import process_input
from expreccs.utils.runs import simulations, plotting
from expreccs.utils.writefile import (
set_gridmako,
write_folders,
write_files,
write_properties,
)
from expreccs.utils.runs import run_models, plotting
from expreccs.utils.writefile import write_folders, write_properties
from expreccs.utils.mapproperties import mapping_properties
from expreccs.visualization.plotting import plot_results
from expreccs.utils.mapboundaries import (
aquaflux_resdata,
aquaflux_opm,
porv_projections,
porv_regional_segmentation,
temporal_interpolation_flux,
temporal_interpolation_pressure,
)
from expreccs.utils.reg_sit_given_decks import create_deck
from expreccs.utils.backcoupling import (
init_multipliers,
backcoupling,
Expand All @@ -41,6 +29,8 @@ def expreccs():
dic["plot"] = cmdargs["plot"] # Generate some nice plots
dic["co2store"] = cmdargs["use"] # Implementation of co2store
dic["reading"] = cmdargs["reading"] # Resdata or opm python package
dic["rotate"] = int(cmdargs["transform"]) # Rotate the site model
dic["expreccs"] = str(cmdargs["expreccs"]) # Name of regional and site models
dic["compare"] = cmdargs[
"compare"
] # If not empty, then the folder 'compare' is created.
Expand All @@ -55,40 +45,26 @@ def expreccs():
# Make the output folders
write_folders(dic)

# For regional and site given decks, then we create a new deck with the proyected pressures
if dic["expreccs"]:
dic["reg"] = dic["expreccs"].split(",")[0]
dic["sit"] = dic["expreccs"].split(",")[1]
create_deck(dic)
return

# Get the location of wells and faults in the reservoirs
dic = mapping_properties(dic)
write_properties(dic)
init_multipliers(dic)

# Run the models
dic = set_gridmako(dic, dic["z_xy"])
if dic["mode"] in ["all", "reference"]:
write_files(dic, "reference")
simulations(dic, "reference")
if dic["mode"] in ["all", "regional", "noreference"]:
dic = porv_regional_segmentation(dic)
write_files(dic, "regional")
simulations(dic, "regional")
if dic["mode"] in ["all", "site", "noreference"]:
if dic["site_bctype"] in ["flux", "pres", "pres2p"]:
if dic["reading"] == "resdata":
dic = aquaflux_resdata(dic)
else:
dic = aquaflux_opm(dic)
if dic["site_bctype"] in ["pres", "pres2p"]:
dic = temporal_interpolation_pressure(dic)
else:
dic = temporal_interpolation_flux(dic)
elif dic["site_bctype"] == "porvproj":
dic = porv_projections(dic)
write_files(dic, f"site_{dic['site_bctype']}")
simulations(dic, f"site_{dic['site_bctype']}")
dic = run_models(dic)

if dic["mode"] in ["all"]:
backcoupling(dic)

# Generate some useful plots after the studies
if dic["plot"] == "yes":
if dic["plot"] != "no":
plotting(dic, time.monotonic() - start_time)


Expand All @@ -114,8 +90,8 @@ def load_parser():
"--mode",
default="all",
help="Run the whole framework ('all'), only the reference ('reference'), "
"only the site ('site'), only regional and site models ('noreference') "
" or none 'none' ('all' by default).",
"only the site ('site'), only regional and site models ('noreference'), "
"or none 'none' ('all' by default).",
)
parser.add_argument(
"-c",
Expand All @@ -127,7 +103,14 @@ def load_parser():
"-p",
"--plot",
default="no",
help="Create useful figures in the postprocessing folder ('no' by default).",
help="Plot 'all', 'reference', 'regional', 'site', or no ('no' by default).",
)
parser.add_argument(
"-u",
"--use",
default="gaswater",
help="Using 'gasoil' or 'gaswater' co2store implementation ('gaswater' by "
+ "default).",
)
parser.add_argument(
"-r",
Expand All @@ -136,11 +119,16 @@ def load_parser():
help="Using the 'opm' or 'resdata' python package ('opm' by default).",
)
parser.add_argument(
"-u",
"--use",
default="gaswater",
help="Using 'gasoil' or 'gaswater' co2store implementation ('gasoil' by "
+ "default).",
"-t",
"--transform",
default=0,
help="Grades to rotate the site geological model ('0' by default).",
)
parser.add_argument(
"-e",
"--expreccs",
default="",
help="Name of the regional and site folders to project pressures.",
)
return vars(parser.parse_known_args()[0])

Expand Down
6 changes: 6 additions & 0 deletions src/expreccs/templates/common/grid.mako
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ ${dic[f'{reservoir}_noCells'][0]} ${dic[f'{reservoir}_noCells'][1]} ${dic[f'{res
/

COORD
% if reservoir in ["reference", "regional"]:
% for j in range(dic[f'{reservoir}_noCells'][1] + 1):
% for i in range(dic[f'{reservoir}_noCells'][0] + 1):
${f"{dic[f'{reservoir}_xmx'][i] : E}"} ${f"{dic[f'{reservoir}_ymy'][j] : E}"} 0 ${f"{dic[f'{reservoir}_xmx'][i] : E}"} ${f"{dic[f'{reservoir}_ymy'][j] : E}"} ${f"{dic[f'{reservoir}_dims'][2] : E}"}
% endfor
% endfor
% else:
% for xcor,ycor in zip(dic['site_xc'],dic['site_yc']):
${f"{xcor : E}"} ${f"{ycor : E}"} 0 ${f"{xcor : E}"} ${f"{ycor : E}"} ${f"{dic[f'{reservoir}_dims'][2] : E}"}
% endfor
% endif
/

ZCORN
Expand Down
99 changes: 98 additions & 1 deletion src/expreccs/utils/mapproperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,43 @@ def mapping_properties(dic):
).argmin()
dic = positions_reference(dic)
dic = positions_regional(dic)
dic = positions_site(dic)
dic = rotate_grid(dic)
if dic["rotate"] > 0:
dic = positions_rotation(dic)
else:
dic = positions_site(dic)
return dic


def rotate_grid(dic):
"""Rotate the grid site if requiered"""
dic["site_xc"], dic["site_yc"] = [], []
for j in range(dic["site_noCells"][1] + 1):
for i in range(dic["site_noCells"][0] + 1):
dic["site_xc"].append(
1.5 * dic["site_dims"][0]
+ (dic["site_xmx"][i] - 1.5 * dic["site_dims"][0])
* np.cos(dic["rotate"] * np.pi / 180)
- (dic["site_ymy"][j] - 1.5 * dic["site_dims"][1])
* np.sin(dic["rotate"] * np.pi / 180)
)
dic["site_yc"].append(
1.5 * dic["site_dims"][1]
+ (dic["site_ymy"][j] - 1.5 * dic["site_dims"][1])
* np.cos(dic["rotate"] * np.pi / 180)
+ (dic["site_xmx"][i] - 1.5 * dic["site_dims"][0])
* np.sin(dic["rotate"] * np.pi / 180)
)
dic["site_xc"] = np.array(dic["site_xc"])
dic["site_yc"] = np.array(dic["site_yc"])
np.save(
f"{dic['exe']}/{dic['fol']}/output/site_{dic['site_bctype']}/d2x",
dic["site_xc"],
)
np.save(
f"{dic['exe']}/{dic['fol']}/output/site_{dic['site_bctype']}/d2y",
dic["site_yc"],
)
return dic


Expand Down Expand Up @@ -171,6 +207,67 @@ def positions_regional(dic):
return dic


def positions_rotation(dic):
"""Find the locations after the rotation"""
dic["site_fipnum"] = [1] * (
dic["site_noCells"][0] * dic["site_noCells"][1] * dic["site_noCells"][2]
)
dic["site_wellijk"] = []
dic["site_sensor"] = [0, 0, 0]
dic["site_fault"] = [[0, 0, 0], [0, 0, 0]]
for j, _ in enumerate(dic["wellCoord"]):
if dic["wellCoord"][j][0] in pd.Interval(
dic["site_location"][0], dic["site_location"][3]
) and dic["wellCoord"][j][1] in pd.Interval(
dic["site_location"][1], dic["site_location"][4]
):
dic["site_wellijk"].append([])
w_ij = pd.Series(
abs(dic["wellCoord"][j][0] - dic["site_xc"])
+ abs(dic["wellCoord"][j][1] - dic["site_yc"])
).argmin()
w_j = np.floor(w_ij / dic["site_noCells"][0])
w_i = 1 + dic["site_noCells"][0] - w_ij + (w_j) * dic["site_noCells"][0]
dic["site_wellijk"][j].append(int(w_i) + 2)
dic["site_wellijk"][j].append(int(w_j))
for _, (well_coord, cord) in enumerate(
zip(dic["wellCoord"][j], ["zmz", "zmz"])
):
midpoints = dic[f"site_{cord}_mid"]
dic["site_wellijk"][j].append(
pd.Series(abs(well_coord - midpoints)).argmin() + 1
)
for k, cord in enumerate(["xmx", "ymy", "zmz"]):
midpoints = dic[f"site_{cord}_mid"]
dic["site_fault"][0][k] = pd.Series(
abs(dic["fault_site"][0][k] - midpoints)
).argmin()
dic["site_fault"][1][k] = pd.Series(
abs(dic["fault_site"][1][k] - midpoints)
).argmin()
dic["site_sensor"][k] = pd.Series(
abs(dic["sensor_location"][k] - midpoints)
).argmin()
sensor_ind = (
dic["site_sensor"][0]
+ dic["site_sensor"][1] * dic["site_noCells"][0]
+ dic["site_sensor"][2] * dic["site_noCells"][0] * dic["site_noCells"][1]
)
np.save(
f"{dic['exe']}/{dic['fol']}/output/site_{dic['site_bctype']}/sensor",
sensor_ind,
)
np.save(
f"{dic['exe']}/{dic['fol']}/output/site_{dic['site_bctype']}/sensor_location",
dic["sensor_location"],
)
np.save(
f"{dic['exe']}/{dic['fol']}/output/site_{dic['site_bctype']}/sensorijk",
dic["site_sensor"],
)
return dic


def positions_site(dic):
"""
Function to locate well and fault positions in the site reservoir.
Expand Down
Loading

0 comments on commit 38565b0

Please sign in to comment.