Skip to content

Commit

Permalink
Add regression tests;
Browse files Browse the repository at this point in the history
PWPA-1933
  • Loading branch information
Gabriel Antão committed Jun 20, 2024
1 parent 0b5b557 commit a555dd4
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 18 deletions.
93 changes: 93 additions & 0 deletions src/alfasim_score/converter/alfacase/_tests/test_convert_casing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from typing import Any

import json
import pytest
from pathlib import Path
from pytest_regressions.data_regression import DataRegressionFixture

from alfasim_score.converter.alfacase.convert_alfacase import ScoreAlfacaseConverter
from alfasim_score.converter.alfacase.score_input_reader import ScoreInputReader


def test_convert_casing_list(
data_regression: DataRegressionFixture,
score_input_example: ScoreInputReader,
) -> None:
builder = ScoreAlfacaseConverter(score_input_example)
casings = builder._convert_casing_list()
data_regression.check(
[
{
"name": casing.name,
"hanger_depth": casing.hanger_depth.GetValue(),
"settings_depth": casing.settings_depth.GetValue(),
"hole_diameter": casing.hole_diameter.GetValue(),
"outer_diameter": casing.outer_diameter.GetValue(),
"inner_diameter": casing.inner_diameter.GetValue(),
"inner_roughness": casing.inner_roughness.GetValue(),
"material": casing.material,
"top_of_filler": casing.top_of_filler.GetValue(),
"filler_material": casing.filler_material,
"material_above_filler": casing.material_above_filler,
}
for casing in casings
]
)


def test_convert_tubing_list(
data_regression: DataRegressionFixture,
score_input_example: ScoreInputReader,
) -> None:
builder = ScoreAlfacaseConverter(score_input_example)
tubings = builder._convert_tubing_list()
data_regression.check(
[
{
"name": tubing.name,
"length": tubing.length.GetValue(),
"outer_diameter": tubing.outer_diameter.GetValue(),
"inner_diameter": tubing.inner_diameter.GetValue(),
"inner_roughness": tubing.inner_roughness.GetValue(),
"material": tubing.material,
}
for tubing in tubings
]
)


def test_convert_packer_list(
data_regression: DataRegressionFixture,
score_input_example: ScoreInputReader,
) -> None:
builder = ScoreAlfacaseConverter(score_input_example)
packers = builder._convert_packer_list()
data_regression.check(
[
{
"name": packer.name,
"position": packer.position.GetValue(),
"material_above": packer.material_above,
}
for packer in packers
]
)


def test_convert_open_hole_list(
data_regression: DataRegressionFixture,
score_input_example: ScoreInputReader,
) -> None:
builder = ScoreAlfacaseConverter(score_input_example)
open_holes = builder._convert_open_hole_list()
data_regression.check(
[
{
"name": hole.name,
"length": hole.length.GetValue(),
"diameter": hole.diameter.GetValue(),
"inner_roughness": hole.inner_roughness.GetValue(),
}
for hole in open_holes
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
- filler_material: cement
hanger_depth: 2072.0
hole_diameter: 42.0
inner_diameter: 33.0
inner_roughness: 0.05
material: B
material_above_filler: null
name: CONDUCTOR_DRILLING_1
outer_diameter: 36.0
settings_depth: 2168.0
top_of_filler: 2072.0
- filler_material: cement
hanger_depth: 2072.0
hole_diameter: 20.0
inner_diameter: 16.25
inner_roughness: 0.05
material: X-80
material_above_filler: null
name: SURFACE_CASING_2
outer_diameter: 18.0
settings_depth: 3490.0
top_of_filler: 2072.0
- filler_material: cement
hanger_depth: 2072.0
hole_diameter: 14.75
inner_diameter: 10.711
inner_roughness: 0.05
material: N-80
material_above_filler: null
name: PRODUCTION_CASING_3
outer_diameter: 11.875
settings_depth: 3072.0
top_of_filler: 4905.0
- filler_material: cement
hanger_depth: 3072.0
hole_diameter: 14.75
inner_diameter: 9.156
inner_roughness: 0.05
material: C-110 HC
material_above_filler: null
name: PRODUCTION_CASING_4
outer_diameter: 10.75
settings_depth: 5441.0
top_of_filler: 4905.0
- filler_material: cement
hanger_depth: 5441.0
hole_diameter: 14.75
inner_diameter: 8.684000000000001
inner_roughness: 0.05
material: SDSS/125KSI
material_above_filler: null
name: PRODUCTION_CASING_5
outer_diameter: 10.75
settings_depth: 5607.0
top_of_filler: 4905.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- diameter: 9.5
inner_roughness: 0.1
length: 371.0
name: OPEN_HOLE_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- material_above: null
name: 'Packer (Hidráulico) #1'
position: 5565.18
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
- inner_diameter: 4.67
inner_roughness: 0.05
length: 40.210000000000036
material: SDSS/125KSI
name: TUBING_1
outer_diameter: 5.5
- inner_diameter: 5.791
inner_roughness: 0.05
length: 732.9000000000001
material: SDSS/125KSI
name: TUBING_2
outer_diameter: 6.625
- inner_diameter: 4.67
inner_roughness: 0.05
length: 56.40000000000009
material: SDSS/125KSI
name: TUBING_3
outer_diameter: 5.5
- inner_diameter: 5.791
inner_roughness: 0.05
length: 48.90000000000009
material: SDSS/125KSI
name: TUBING_4
outer_diameter: 6.625
- inner_diameter: 4.67
inner_roughness: 0.05
length: 54.90000000000009
material: SDSS/125KSI
name: TUBING_5
outer_diameter: 5.5
- inner_diameter: 5.791
inner_roughness: 0.05
length: 2400.9
material: SDSS/125KSI
name: TUBING_6
outer_diameter: 6.625
- inner_diameter: 4.67
inner_roughness: 0.05
length: 158.97000000000025
material: SDSS/125KSI
name: TUBING_7
outer_diameter: 5.5
- inner_diameter: 3.92
inner_roughness: 0.05
length: 31.039999999999964
material: SDSS/125KSI
name: TUBING_8
outer_diameter: 4.5
- inner_diameter: 4.67
inner_roughness: 0.05
length: 24.899999999999636
material: SDSS/125KSI
name: TUBING_9
outer_diameter: 5.5
- inner_diameter: 3.92
inner_roughness: 0.05
length: 21.670000000000073
material: SDSS/125KSI
name: TUBING_10
outer_diameter: 4.5
- inner_diameter: 4.67
inner_roughness: 0.05
length: 20.23999999999978
material: SDSS/125KSI
name: TUBING_11
outer_diameter: 5.5
- inner_diameter: 3.92
inner_roughness: 0.05
length: 27.420000000000073
material: SDSS/125KSI
name: TUBING_12
outer_diameter: 4.5
- inner_diameter: 4.67
inner_roughness: 0.05
length: 132.89999999999964
material: SDSS/125KSI
name: TUBING_13
outer_diameter: 5.5
- inner_diameter: 3.92
inner_roughness: 0.05
length: 21.670000000000073
material: SDSS/125KSI
name: TUBING_14
outer_diameter: 4.5
- inner_diameter: 4.67
inner_roughness: 0.05
length: 20.23999999999978
material: SDSS/125KSI
name: TUBING_15
outer_diameter: 5.5
- inner_diameter: 3.92
inner_roughness: 0.05
length: 31.859999999999673
material: SDSS/125KSI
name: TUBING_16
outer_diameter: 4.5
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@
thermal_conductivity: 0.983057
thermal_expansion: 1.0e-06
type: solid
- density: 65.5035
heat_capacity: 460.9
name: B
thermal_conductivity: 45.345257
thermal_expansion: 1.2e-05
type: solid
- density: 65.5035
heat_capacity: 460.9
name: X-80
thermal_conductivity: 45.345257
thermal_expansion: 1.2e-05
type: solid
- density: 65.5035
heat_capacity: 460.9
name: N-80
thermal_conductivity: 45.345257
thermal_expansion: 1.2e-05
type: solid
- density: 65.5035
heat_capacity: 460.9
name: C-110 HC
thermal_conductivity: 45.345257
thermal_expansion: 1.2e-05
type: solid
- density: 65.5035
heat_capacity: 460.9
name: SDSS/125KSI
thermal_conductivity: 45.345257
thermal_expansion: 1.2e-05
type: solid
- density: 65.5035
heat_capacity: 460.9
name: SDSS/125KSI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from typing import Any

import json
import pytest
from pathlib import Path
from pytest_regressions.num_regression import NumericRegressionFixture

from alfasim_score.converter.alfacase.convert_alfacase import ScoreAlfacaseConverter
Expand All @@ -14,11 +9,10 @@ def test_convert_well_trajectory(
score_input_example: ScoreInputReader,
) -> None:
builder = ScoreAlfacaseConverter(score_input_example)
well_description = builder.build_well()

well_trajectory = builder._convert_well_trajectory()
num_regression.check(
{
"x": well_description.profile.x_and_y.x.GetValues("m"),
"y": well_description.profile.x_and_y.y.GetValues("m"),
"x": well_trajectory.x_and_y.x.GetValues(),
"y": well_trajectory.x_and_y.y.GetValues(),
}
)
13 changes: 8 additions & 5 deletions src/alfasim_score/converter/alfacase/convert_alfacase.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def filter_duplicated_materials(
) -> List[MaterialDescription]:
"""Remove the duplicated materials parsed by the reader"""
# TODO: implement it to filter the duplicated materials
# TODO: remember to get all cements (???)
return material_list


Expand All @@ -50,7 +51,7 @@ def _convert_well_trajectory(self) -> ProfileDescription:
def convert_materials(self) -> List[MaterialDescription]:
"""Convert list of materials from SCORE file"""
material_descriptions = []
material_list = filter_duplicated_materials(
material_list = (
self.score_input.read_cement_material()
+ self.score_input.read_casing_materials()
+ self.score_input.read_tubing_materials()
Expand Down Expand Up @@ -81,7 +82,8 @@ def _convert_formation(self) -> AnnulusDescription:
def _convert_casing_list(self) -> List[CasingSectionDescription]:
"""Create the description for the casings."""
casing_sections = []
for i, data in enumerate(self.score_input.read_casings(), start=1):
i = 1
for data in self.score_input.read_casings():
for section in data["sections"]:
casing_sections.append(
CasingSectionDescription(
Expand All @@ -95,9 +97,10 @@ def _convert_casing_list(self) -> List[CasingSectionDescription]:
material=section["material"],
top_of_filler=data["top_of_cement"],
filler_material=CEMENT_NAME,
material_above_filler=data["material_above"],
material_above_filler=data["material_above_filler"],
)
)
i += 1
return casing_sections

def _convert_tubing_list(self) -> List[TubingDescription]:
Expand Down Expand Up @@ -133,11 +136,11 @@ def _convert_open_hole_list(self) -> List[OpenHoleDescription]:
"""Create the description for the open hole."""
open_hole = []
start_position = Scalar(
max([data["shoe_md"] for data in self.score_input.read_casings()]),
max([data["shoe_md"].GetValue() for data in self.score_input.read_casings()]),
LENGTH_UNIT,
"length",
)
for i, data in enumerate(self.score_input.read_tubing(), start=1):
for i, data in enumerate(self.score_input.read_open_hole(), start=1):
open_hole.append(
OpenHoleDescription(
name=f"OPEN_HOLE_{i}",
Expand Down
2 changes: 1 addition & 1 deletion src/alfasim_score/converter/alfacase/score_input_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def read_casings(self) -> List[Dict[str, Any]]:
"material_above_filler": None,
"hole_diameter": Scalar(item["hole_size"], DIAMETER_UNIT, "diameter"),
# TODO: check if these diameters should be used here
# "inner_diameter":,
# "inner_diameter": ???,
# "outer_diameter": Scalar(item["od"], DIAMETER_UNIT, "diameter"),
"sections": [
{
Expand Down
3 changes: 0 additions & 3 deletions src/alfasim_score/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@
YOUNG_MODULUS_UNIT = "psi"
FRACTION_UNIT = "-"
ROUGHNESS_UNIT = "mm"
DENSITY_UNIT = ""
THERMAL_CONDUCTIVITY_UNIT = "W/m.K"
SPECIFIT_HEAT_UNIT = "J/kg.K"

0 comments on commit a555dd4

Please sign in to comment.