Skip to content

Commit

Permalink
Put well start position as an attribute of class;
Browse files Browse the repository at this point in the history
Change some names in loops to improve code readability;

PWPA-1982
  • Loading branch information
Gabriel Antão committed Jul 1, 2024
1 parent fa6f1a3 commit fa97d10
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions src/alfasim_score/converter/alfacase/convert_alfacase.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class ScoreAlfacaseConverter:
def __init__(self, score_reader: ScoreInputReader):
self.score_input = score_reader
self.general_data = score_reader.read_general_data()
self.well_start_position = self.general_data["water_depth"] + self.general_data["air_gap"]

def _get_well_start_position(self) -> Scalar:
"""Get the start position in TVD for the well start position"""
return self.general_data["water_depth"] + self.general_data["air_gap"]
def _get_position_in_well(self, position: Scalar) -> Scalar:
"""Get the position relative to the well start position"""
return position - self.well_start_position

def _convert_well_trajectory(self) -> ProfileDescription:
"""
Expand All @@ -84,15 +85,15 @@ def convert_materials(self) -> List[MaterialDescription]:
+ self.score_input.read_packer_fluid()
)

for data in material_list:
for material in material_list:
material_descriptions.append(
MaterialDescription(
name=data["name"],
material_type=MaterialType(data["type"]),
density=data["density"],
thermal_conductivity=data["thermal_conductivity"],
heat_capacity=data["specific_heat"],
expansion=data["thermal_expansion"],
name=material["name"],
material_type=MaterialType(material["type"]),
density=material["density"],
thermal_conductivity=material["thermal_conductivity"],
heat_capacity=material["specific_heat"],
expansion=material["thermal_expansion"],
)
)
return filter_duplicated_materials(material_descriptions)
Expand All @@ -107,10 +108,12 @@ def _convert_formation(self) -> FormationDescription:
layers = [
FormationLayerDescription(
name=f"formation_{i}",
start=convert_quota_to_tvd(data["top_elevation"], self.general_data["air_gap"]),
material=data["material"],
start=convert_quota_to_tvd(
formation["top_elevation"], self.general_data["air_gap"]
),
material=formation["material"],
)
for i, data in enumerate(self.score_input.read_formations(), start=1)
for i, formation in enumerate(self.score_input.read_formations(), start=1)
]
return FormationDescription(
reference_y_coordinate=Scalar(0.0, "m", "length"), layers=layers
Expand All @@ -119,20 +122,19 @@ def _convert_formation(self) -> FormationDescription:
def _convert_casing_list(self) -> List[CasingSectionDescription]:
"""Create the description for the casings."""
casing_sections = []
well_start_position = self._get_well_start_position()
for data in self.score_input.read_casings():
for i, section in enumerate(data["sections"], 1):
for casing in self.score_input.read_casings():
for i, section in enumerate(casing["sections"], 1):
casing_sections.append(
CasingSectionDescription(
name=f"{data['function'].value}_{data['type'].value}_{i}",
hanger_depth=section["top_md"] - well_start_position,
settings_depth=section["base_md"] - well_start_position,
hole_diameter=data["hole_diameter"],
name=f"{casing['function'].value}_{casing['type'].value}_{i}",
hanger_depth=self._get_position_in_well(section["top_md"]),
settings_depth=self._get_position_in_well(section["base_md"]),
hole_diameter=casing["hole_diameter"],
outer_diameter=section["outer_diameter"],
inner_diameter=section["inner_diameter"],
inner_roughness=CASING_DEFAULT_ROUGHNESS,
material=section["material"],
top_of_filler=data["top_of_cement"] - well_start_position,
top_of_filler=self._get_position_in_well(casing["top_of_cement"]),
filler_material=CEMENT_NAME,
# TODO PWPA-1970: review this fluid default with fluid actually used by SCORE file
material_above_filler=FLUID_DEFAULT_NAME,
Expand All @@ -144,27 +146,27 @@ def _convert_casing_list(self) -> List[CasingSectionDescription]:
def _convert_tubing_list(self) -> List[TubingDescription]:
"""Create the description for the tubing list."""
tubing_sections = []
for i, data in enumerate(self.score_input.read_tubing(), start=1):
for i, tubing in enumerate(self.score_input.read_tubing(), start=1):
tubing_sections.append(
TubingDescription(
name=f"TUBING_{i}",
length=data["base_md"] - data["top_md"],
outer_diameter=data["outer_diameter"],
inner_diameter=data["inner_diameter"],
length=tubing["base_md"] - tubing["top_md"],
outer_diameter=tubing["outer_diameter"],
inner_diameter=tubing["inner_diameter"],
inner_roughness=TUBING_DEFAULT_ROUGHNESS,
material=data["material"],
material=tubing["material"],
)
)
return tubing_sections

def _convert_packer_list(self) -> List[PackerDescription]:
"""Create the description for the packers."""
packers = []
for data in self.score_input.read_packers():
for packer in self.score_input.read_packers():
packers.append(
PackerDescription(
name=data["name"],
position=data["position"],
name=packer["name"],
position=self._get_position_in_well(packer["position"]),
# TODO PWPA-1970: review this fluid default with fluid actually used by SCORE file
material_above=FLUID_DEFAULT_NAME,
)
Expand All @@ -173,23 +175,23 @@ def _convert_packer_list(self) -> List[PackerDescription]:

def _convert_open_hole_list(self) -> List[OpenHoleDescription]:
"""Create the description for the open hole."""
open_hole = []
open_hole_list = []
start_position = Scalar(
max([data["shoe_md"].GetValue() for data in self.score_input.read_casings()]),
max([casing["shoe_md"].GetValue() for casing in self.score_input.read_casings()]),
LENGTH_UNIT,
"length",
)
for i, data in enumerate(self.score_input.read_open_hole(), start=1):
open_hole.append(
for i, open_hole in enumerate(self.score_input.read_open_hole(), start=1):
open_hole_list.append(
OpenHoleDescription(
name=f"OPEN_HOLE_{i}",
length=data["final_md"] - start_position,
diameter=data["hole_diameter"],
length=open_hole["final_md"] - start_position,
diameter=open_hole["hole_diameter"],
inner_roughness=ROCK_DEFAULT_ROUGHNESS,
)
)
start_position = data["final_md"]
return open_hole
start_position = open_hole["final_md"]
return open_hole_list

def _convert_casings(self) -> CasingDescription:
"""Create the description for the casings."""
Expand Down

0 comments on commit fa97d10

Please sign in to comment.