Skip to content
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
3 changes: 2 additions & 1 deletion docs/rips/tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def test_replaceCase(rips_instance, initialize_test):
cases = rips_instance.project.cases()
assert len(cases) == 1

case.replace(new_grid_file=case_path)
with pytest.warns(DeprecationWarning):
case.replace(new_grid_file=case_path)
# Check that the case object has been changed
assert case.name == "BRUGGE_0000"
assert case.id == 0
Expand Down
17 changes: 9 additions & 8 deletions docs/rips/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ def test_create_lgr_well(rips_instance, initialize_test):

time_step = 5
well_path_names = ["Well Path A"]
case.create_lgr_for_completion(
time_step,
well_path_names,
refinement_i=2,
refinement_j=3,
refinement_k=1,
split_type="LGR_PER_WELL",
)
with pytest.warns(DeprecationWarning):
case.create_lgr_for_completion(
time_step,
well_path_names,
refinement_i=2,
refinement_j=3,
refinement_k=1,
split_type="LGR_PER_WELL",
)
assert len(case.grids()) == 3


Expand Down
73 changes: 39 additions & 34 deletions docs/rips/tests/test_completion_export.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import pytest

sys.path.insert(1, os.path.join(sys.path[0], "../../"))

Expand Down Expand Up @@ -105,15 +106,16 @@ def test_export_completion_files_unified(rips_instance, initialize_test):

well_names_to_use = ["Well-1"]

case.export_well_path_completions(
time_step=0, # Use time step 0 instead of 1
well_path_names=well_names_to_use,
file_split="UNIFIED_FILE",
include_perforations=True,
include_fishbones=True,
export_welspec=True,
export_comments=False,
)
with pytest.warns(DeprecationWarning):
case.export_well_path_completions(
time_step=0, # Use time step 0 instead of 1
well_path_names=well_names_to_use,
file_split="UNIFIED_FILE",
include_perforations=True,
include_fishbones=True,
export_welspec=True,
export_comments=False,
)

# Compare exported files with reference data
reference_folder = (
Expand Down Expand Up @@ -145,14 +147,15 @@ def test_export_completion_files_split_by_well(rips_instance, initialize_test):
# Use Well-1 for all tests
test_wells = ["Well-1"]

case.export_well_path_completions(
time_step=0, # Use time step 0 instead of 1
well_path_names=test_wells,
file_split="SPLIT_ON_WELL",
include_perforations=True,
include_fishbones=False, # This matches the reference generation script
export_comments=False,
)
with pytest.warns(DeprecationWarning):
case.export_well_path_completions(
time_step=0, # Use time step 0 instead of 1
well_path_names=test_wells,
file_split="SPLIT_ON_WELL",
include_perforations=True,
include_fishbones=False, # This matches the reference generation script
export_comments=False,
)

# Compare exported files with reference data
reference_folder = case_root_path + "/completion_export_reference/split_by_well"
Expand Down Expand Up @@ -195,15 +198,16 @@ def test_export_completion_well_entering_lgr_twice(rips_instance, initialize_tes
os.remove(os.path.join(export_folder, old_file))

rips_instance.set_export_folder(export_type="COMPLETIONS", path=export_folder)
case.export_well_path_completions(
time_step=0,
well_path_names=["LgrWell"],
file_split="UNIFIED_FILE",
include_perforations=True,
include_fishbones=False,
export_welspec=True,
export_comments=False,
)
with pytest.warns(DeprecationWarning):
case.export_well_path_completions(
time_step=0,
well_path_names=["LgrWell"],
file_split="UNIFIED_FILE",
include_perforations=True,
include_fishbones=False,
export_welspec=True,
export_comments=False,
)

lgr_files = [
f for f in os.listdir(export_folder) if f.endswith("_LGR") and "_MSW_" not in f
Expand Down Expand Up @@ -244,14 +248,15 @@ def test_export_completion_dual_porosity_model(rips_instance, initialize_test):
# Use Well-1 for all tests
test_wells = ["PH", "PV"]

case.export_well_path_completions(
time_step=0, # Use time step 0 instead of 1
well_path_names=test_wells,
file_split="SPLIT_ON_WELL",
include_perforations=True,
include_fishbones=False, # This matches the reference generation script
export_comments=False,
)
with pytest.warns(DeprecationWarning):
case.export_well_path_completions(
time_step=0, # Use time step 0 instead of 1
well_path_names=test_wells,
file_split="SPLIT_ON_WELL",
include_perforations=True,
include_fishbones=False, # This matches the reference generation script
export_comments=False,
)

# Compare exported files with reference data
reference_folder = case_root_path + "/completion_export_reference"
Expand Down
62 changes: 61 additions & 1 deletion docs/rips/tests/test_msw_completion_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def test_msw_export(rips_instance, initialize_test):
rips_instance.set_export_folder(export_type="COMPLETIONS", path=export_folder)

# Export MSW data
case.export_msw(well_path=well_y1.name)
with pytest.warns(DeprecationWarning):
case.export_msw(well_path=well_y1.name)

# Note: The actual file creation validation would require checking
# the export folder, which may be platform-dependent and require
Expand Down Expand Up @@ -262,3 +263,62 @@ def test_msw_settings_read(rips_instance, initialize_test):
assert completion_settings.allow_well_cross_flow, (
"Allow well cross flow should be True"
)


def _export_msw_files(case, well_paths, export_function):
with tempfile.TemporaryDirectory(prefix="rips") as folder:
export_function(case, well_paths, folder)
files = {}
for name in os.listdir(folder):
if name.endswith("_MSW"):
with open(os.path.join(folder, name)) as f:
# Drop comment lines, they contain a timestamp
files[name] = [
line
for line in f.read().splitlines()
if not line.startswith("--")
]
return files


def _export_completions(case, well_paths, folder):
case.export_completions(
well_paths=well_paths,
time_step=0,
export_folder=folder,
file_split=rips.CompletionExportSplit.SPLIT_ON_WELL,
include_msw=True,
export_comments=False,
)


def _export_msw_completions(case, well_paths, folder):
case.export_msw_completions(
well_paths=well_paths,
export_folder=folder,
file_split=rips.CompletionExportSplit.SPLIT_ON_WELL,
)


@pytest.mark.parametrize(
"export_function", [_export_completions, _export_msw_completions]
)
def test_msw_export_main_and_lateral_exports_top_level_well(
rips_instance, initialize_test, export_function
):
"""Issue #13485: passing both a main well and its lateral must export the
main well (including all laterals), not only the lateral."""
project_path = dataroot.PATH + "/msw-export/project-files/perf_lateral.rsp"
project = rips_instance.project.open(path=project_path)
case = project.cases()[0]

well_y1 = project.well_path_by_name("Well-1 Y1")
well_y2 = project.well_path_by_name("Well-1 Y2")
assert well_y1 is not None and well_y2 is not None

reference = _export_msw_files(case, [well_y1], export_function)
assert len(reference) == 1

for well_paths in ([well_y1, well_y2], [well_y2, well_y1], [well_y2]):
exported = _export_msw_files(case, well_paths, export_function)
assert exported == reference
2 changes: 1 addition & 1 deletion docs/rips/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_scale_fracture_template_and_set_containment(rips_instance, initialize_t
assert after_scale.width_scale_factor == 1.5
assert after_scale.conductivity_factor == 4.5

with pytest.raises(rips.RipsError):
with pytest.raises(rips.RipsError), pytest.warns(DeprecationWarning):
project.scale_fracture_template(
template_id=999, half_length=1, height=1, d_factor=1, conductivity=1
)
Expand Down
3 changes: 2 additions & 1 deletion docs/rips/tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def test_exportPropertyInView(rips_instance, initialize_test):
rips_instance.set_export_folder(export_type="PROPERTIES", path=tmpdirname)
case = rips_instance.project.cases()[0]
view = case.views()[0]
view.export_property()
with pytest.warns(DeprecationWarning):
view.export_property()
expected_file_name = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
full_path = tmpdirname + "/" + expected_file_name
assert os.path.exists(full_path)
Expand Down
11 changes: 6 additions & 5 deletions docs/rips/tests/test_wells_path_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ def test_10k(rips_instance, initialize_test):
rips_instance.set_export_folder(export_type="COMPLETIONS", path=export_folder)

case = project.cases()[0]
case.export_well_path_completions(
time_step=1,
well_path_names=["Well-1"],
file_split="UNIFIED_FILE",
)
with pytest.warns(DeprecationWarning):
case.export_well_path_completions(
time_step=1,
well_path_names=["Well-1"],
file_split="UNIFIED_FILE",
)


def test_export_completions(rips_instance, initialize_test):
Expand Down