Skip to content

Commit

Permalink
Add reading for tubing and packers;
Browse files Browse the repository at this point in the history
PWPA-1933
  • Loading branch information
Gabriel Antão committed Jun 18, 2024
1 parent 33dc48e commit 0c585f2
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 3 deletions.
47 changes: 47 additions & 0 deletions src/alfasim_score/converter/alfacase/convert_alfacase.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from alfasim_sdk import ProfileDescription
from alfasim_sdk import WellDescription
from alfasim_sdk import XAndYDescription
from alfasim_sdk import CasingDescription, PackerDescription, TubingDescription, CasingSectionDescription, OpenHoleDescription
from barril.units import Scalar

from alfasim_score.constants import ANNULUS_TOP_NODE_NAME
Expand Down Expand Up @@ -59,10 +60,56 @@ def _convert_annulus(self) -> AnnulusDescription:
def _convert_formation(self) -> AnnulusDescription:
return FormationDescription(reference_y_coordinate=Scalar(0.0, "m", "length"))

def _convert_casing_list(self) -> List[CasingSectionDescription]:
return []

def _convert_tubing_list(self) -> List[TubingDescription]:
tubing_sections = []
for i, data in enumerate(self.score_input.read_casings(), start=1):
tubing_sections.append(
TubingDescription(
name=f"TUBING_{i}",
length=Scalar(data["base_md"] - data["top_md"], LENGTH_UNIT, "length"),
outer_diameter=data["outer_diameter"],
inner_diameter=data["inner_diameter"],
# TODO: set right the value for roughness...
inner_roughness=Scalar(0.0, "mm"),
material=data["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():
packers.append(
PackerDescription(
name=data["name"],
position=data["position"],
material_above=data["material_above"],
)
)
return packers

def _convert_open_hole(self) -> List[OpenHoleDescription]:
return []

def _convert_casing_list(self) -> WellDescription:
"""Create the description for the casings."""
return CasingDescription(
casing_sections=self._convert_casing_list(),
tubings=self._convert_tubing_list(),
packers=self._convert_packer_list(),
open_holes=self._convert_open_hole(),
)

def build_well(self) -> WellDescription:
"""Create the description for the well."""
return WellDescription(
name=self.well_name,
profile=self._convert_well_trajectory(),
casing=self._convert_casing(),
annulus=self._convert_annulus(),
formation=self._convert_formation(),
top_node=WELLBORE_TOP_NODE,
Expand Down
47 changes: 44 additions & 3 deletions src/alfasim_score/converter/alfacase/score_input_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from typing import Union

import json
from barril.units import Array
from barril.units import Scalar
from barril.units import Array, Scalar
from pathlib import Path
from typing import Tuple, List, Dict

from alfasim_score.constants import CEMENT_NAME
from alfasim_score.units import DENSITY_UNIT
Expand All @@ -25,7 +25,7 @@ def __init__(self, score_filepath: Path):
self.input_content = json.load(f)

def read_well_trajectory(self) -> Tuple[Array, Array]:
"""Create the arrays with the x and y positions."""
"""Read the arrays with the x and y positions."""
x = [entry["displacement"] for entry in self.input_content["trajectory"]["data"]]
y = [-entry["vertical_depth"] for entry in self.input_content["trajectory"]["data"]]
return Array(x, LENGTH_UNIT), Array(y, LENGTH_UNIT)
Expand Down Expand Up @@ -97,3 +97,44 @@ def read_lithology_materials(self) -> List[Dict[str, Union[Scalar, str]]]:
}
)
return lithology_data

# TODO: implement the casing parser
def read_casings() -> List[Dict[str, Scalar | str]]:
return []

def read_tubing(self) -> List[Dict[str, Scalar | str]]:
""""Read the data for the tubing from SCORE input file"""
casing_data = []
for section in self.input_content["operation"]["tubing_string"]["string_sections"]:
outer_radius = section["pipe"]["od"] / 2.0
thickness = section["pipe"]["wt"]
inner_diameter = 2.0 * (outer_radius - thickness)
casing_data.append(
{
"top_md": Scalar(section["top_md"], LENGTH_UNIT, "length"),
"base_md": Scalar(section["base_md"], LENGTH_UNIT, "length"),
"inner_diameter": Scalar(inner_diameter, DIAMETER_UNIT, "diameter"),
"outer_diameter": Scalar(section["od"], DIAMETER_UNIT, "diameter"),
"material": section["pipe"]["grade"]["name"]
}
)
return casing_data

def read_packers(self) -> List[Dict[str, Scalar | str]]:
""""Read the data for the packers from SCORE input file"""
packer_data = []
for component in self.input_content["operation"]["tubing_string"]["components"]:
if component["component"]["type"] == "PACKER":
packer_data.append(
{
"name": component["name"],
"position": Scalar(component["depth"], LENGTH_UNIT, "length"),
# TODO: get material above from somewhere else
"material_above": "",
}
)
return packer_data

# TODO: implement the open holes parser
def read_open_hole(self) -> List[Dict[str, Scalar | str]]:
return []
6 changes: 6 additions & 0 deletions src/alfasim_score/units.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
LENGTH_UNIT = "m"
DIAMETER_UNIT = "in"
THICKNESS_UNIT = "in"
DENSITY_UNIT = "kg/m3"
SPECIFIC_HEAT_UNIT = "J/kg.K"
THERMAL_CONDUCTIVITY_UNIT = "W/m.K"
THERMAL_EXPANSION_UNIT = "1/K"
YOUNG_MODULUS_UNIT = "psi"
FRACTION_UNIT = "-"

DENSITY_UNIT = ""
THERMAL_CONDUCTIVITY_UNIT = "W/m.K"
SPECIFIT_HEAT_UNIT = "J/kg.K"

0 comments on commit 0c585f2

Please sign in to comment.