Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Well trajectory: fix mixed normal and mlt trajectories #43

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/everest_models/jobs/fm_well_trajectory/resinsight.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def create_well_logs(
eclipse_model: Path,
project_path: Path,
date: Optional[datetime.date],
has_mlt: bool,
) -> None:
case = project.cases()[0]

Expand All @@ -189,11 +188,9 @@ def create_well_logs(
# the form "name Y#", e.g., "INJ Y1", where the index Y# indicates the
# number of the branch, and Y1 is the main trajectory. We need to split
# and take the first part to get the original well name:
perforation = next(
item
for item in perforations
if item.well == (well_path.name.split()[0] if has_mlt else well_path.name)
)
well_name_base = well_path.name.partition(" Y")[0].strip()

perforation = next(item for item in perforations if item.well == well_name_base)

if perforation.dynamic:
restart = eclipse_model.with_suffix(".UNRST")
Expand Down Expand Up @@ -290,20 +287,22 @@ def make_perforations(
well_name: str,
perforations: Iterable[PerforationConfig],
wells: Iterable[WellConfig],
has_mlt: bool,
path: Path,
):
# If we created multi-lateral wells, the well path names are stored in the
# form "name Y#", e.g., "INJ Y1", where the index Y# indicates the number of
# the branch, and Y1 is the main trajectory. We need to split and take the
# first part to get the original well name:
well_name_base = well_name.split()[0] if has_mlt else well_name
well_name_base = well_name.partition(" Y")[0].strip()

perf_depths, well_depth = _select_perforations(
perforation=next(item for item in perforations if item.well == well_name_base),
df=_read_las_file(next(path.glob(f"{well_name.replace(' ', '_')}*.las"))),
)
well = next(item for item in wells if item.name == well_name_base)

export_filename: Optional[Path] = None

if well_depth is not None:
well_path = project.well_path_by_name(well_name)
total_perf_length = 0
Expand Down Expand Up @@ -339,9 +338,10 @@ def make_perforations(
custom_file_name=str(export_filename),
)

_generate_welspecs(
well.name, well.phase, well.group, export_filename, perf_depths, path
)
if export_filename is not None:
_generate_welspecs(
well.name, well.phase, well.group, export_filename, perf_depths, path
)

project.update()
return None if well_depth is None else well
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ def well_trajectory_resinsight(
# Create multi-lateral trajectories based on the trajectories we
# made before:
for well_config in config.wells:
create_branches(
well_config,
well_paths[well_config.name],
mlt_guide_points[well_config.name],
resinsight.project,
)
if well_config.name in mlt_guide_points:
create_branches(
well_config,
well_paths[well_config.name],
mlt_guide_points[well_config.name],
resinsight.project,
)
_save_paths(
project_path,
resinsight.project,
Expand All @@ -125,7 +126,6 @@ def well_trajectory_resinsight(
eclipse_model,
project_path,
config.connections.date,
bool(mlt_guide_points),
)
wells = itertools.filterfalse(
lambda x: x is None,
Expand All @@ -135,7 +135,6 @@ def well_trajectory_resinsight(
well_path.name,
config.connections.perforations,
config.wells,
bool(mlt_guide_points),
project_path,
)
for well_path in resinsight.project.well_paths()
Expand Down
23 changes: 22 additions & 1 deletion tests/jobs/well_trajectory/test_well_trajectory_resinsight.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import filecmp
import json
import logging
from pathlib import Path

Expand Down Expand Up @@ -47,7 +48,7 @@ def test_well_trajectory_resinsight_main_entry_point_lint(


@pytest.mark.resinsight
def test_well_trajectory_resinsight_main_entry_point(
def test_well_trajectory_resinsight_main_entry_point_no_mlt(
well_trajectory_arguments, copy_testdata_tmpdir
):
copy_testdata_tmpdir(Path(TEST_DATA) / "resinsight_mlt")
Expand All @@ -74,3 +75,23 @@ def test_well_trajectory_resinsight_main_entry_point_mlt(
output = expected.relative_to("expected_mlt")
assert output.is_file()
assert filecmp.cmp(expected, output, shallow=False)


@pytest.mark.resinsight
def test_well_trajectory_resinsight_main_entry_point_mixed(
well_trajectory_arguments, copy_testdata_tmpdir
):
copy_testdata_tmpdir(Path(TEST_DATA) / "resinsight_mlt")
for path in Path.cwd().glob("mlt_*.json"):
with path.open(encoding="utf-8") as fp:
guide_points = json.load(fp)
del guide_points["PROD"]
with path.open("w", encoding="utf-8") as fp:
json.dump(guide_points, fp)
main_entry_point(well_trajectory_arguments)

for expected in Path("expected_mixed").glob("**/*"):
if expected.is_file():
output = expected.relative_to("expected_mixed")
assert output.is_file()
assert filecmp.cmp(expected, output, shallow=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- WELL GROUP BHP PHASE DRAIN INFLOW OPEN CROSS PVT HYDS FIP
-- NAME NAME I J DEPTH FLUID AREA EQUANS SHUT FLOW TABLE DENS REGN
WELSPECS
INJ G1 5 4 1* GAS 0.0 STD STOP YES 0 SEG 0 /
/
-- WELL OPEN SAT CONN WELL KH SKIN D DIR
-- NAME I J K1 K2 SHUT TAB FACT DIA FACT FACT FACT PEN
COMPDAT
INJ 5 4 1 1 OPEN 1* 7.462625E+01 0.30000 1.000757E+04 0.00000 1* 'Z' /
INJ 5 4 2 2 OPEN 1* 1.118596E+01 0.30000 1.500165E+03 0.00000 1* 'Z' /
INJ 5 4 3 3 OPEN 1* 7.456390E+01 0.30000 9.999988E+03 0.00000 1* 'Z' /
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- WELL GROUP BHP PHASE DRAIN INFLOW OPEN CROSS PVT HYDS FIP
-- NAME NAME I J DEPTH FLUID AREA EQUANS SHUT FLOW TABLE DENS REGN
WELSPECS
INJ G1 5 4 1* GAS 0.0 STD STOP YES 0 SEG 0 /
/
-- WELL OPEN SAT CONN WELL KH SKIN D DIR
-- NAME I J K1 K2 SHUT TAB FACT DIA FACT FACT FACT PEN
COMPDAT
INJ 5 4 1 1 OPEN 1* 1.277521E+02 0.30000 1.659327E+04 0.00000 1* 'Z' /
INJ 5 4 2 2 OPEN 1* 2.128067E+01 0.30000 2.755196E+03 0.00000 1* 'Z' /
INJ 4 4 3 3 OPEN 1* 1.468611E+02 0.30000 1.899792E+04 0.00000 1* 'Z' /
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- WELL GROUP BHP PHASE DRAIN INFLOW OPEN CROSS PVT HYDS FIP
-- NAME NAME I J DEPTH FLUID AREA EQUANS SHUT FLOW TABLE DENS REGN
WELSPECS
INJ G1 5 4 1* GAS 0.0 STD STOP YES 0 SEG 0 /
/
-- WELL OPEN SAT CONN WELL KH SKIN D DIR
-- NAME I J K1 K2 SHUT TAB FACT DIA FACT FACT FACT PEN
COMPDAT
INJ 5 4 1 1 OPEN 1* 1.030456E+02 0.30000 1.350647E+04 0.00000 1* 'Z' /
INJ 5 4 2 2 OPEN 1* 1.644333E+01 0.30000 2.130649E+03 0.00000 1* 'Z' /
INJ 5 5 2 2 OPEN 1* 6.318966E+00 0.30000 8.121229E+02 0.00000 1* 'Z' /
INJ 5 5 3 3 OPEN 1* 5.243721E+02 0.30000 6.701535E+04 0.00000 1* 'Z' /
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- WELL GROUP BHP PHASE DRAIN INFLOW OPEN CROSS PVT HYDS FIP
-- NAME NAME I J DEPTH FLUID AREA EQUANS SHUT FLOW TABLE DENS REGN
WELSPECS
PROD G1 6 7 1* OIL 0.0 STD STOP YES 0 SEG 0 /
/
-- WELL OPEN SAT CONN WELL KH SKIN D DIR
-- NAME I J K1 K2 SHUT TAB FACT DIA FACT FACT FACT PEN
COMPDAT
PROD 6 7 1 1 OPEN 1* 7.462625E+01 0.30000 1.000757E+04 0.00000 1* 'Z' /
PROD 6 7 2 2 OPEN 1* 1.118596E+01 0.30000 1.500165E+03 0.00000 1* 'Z' /
PROD 6 7 3 3 OPEN 1* 7.456390E+01 0.30000 9.999988E+03 0.00000 1* 'Z' /
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"INJ": [
[
5000.0,
5000.0,
4080.0,
4079.98,
4079.96
],
[
5000.0,
5000.0,
3920.0,
3920.0,
3920.0
],
[
0.0,
50.0,
8225.0,
8375.0,
8525.0
]
],
"PROD": [
[
5000.0,
5000.0,
5920.0,
5920.02,
5920.04
],
[
5000.0,
5000.0,
6080.0,
6080.0,
6080.0
],
[
0.0,
50.0,
8225.0,
8375.0,
8525.0
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"INJ": {
"1": 8350.0,
"2": 8350.0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"INJ": {
"1": [
[
4079.86,
3839.9300000000003,
3600.0
],
[
3919.83,
3759.915,
3600.0
],
[
8226.64,
8465.328,
8525.0
]
],
"2": [
[
4079.86,
4039.9300000000003,
4000.0
],
[
3919.83,
4559.915,
5200.0
],
[
8226.64,
8465.328,
8525.0
]
]
}
}
Loading
Loading