Skip to content

Commit

Permalink
Minor fixes in names and comments;
Browse files Browse the repository at this point in the history
PWPA-1960
  • Loading branch information
Gabriel Antão committed Jun 18, 2024
1 parent a4a53b8 commit 33dc48e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
9 changes: 9 additions & 0 deletions src/alfasim_score/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from pathlib import Path

from alfasim_score.converter.alfacase.score_input_reader import ScoreInputReader


@pytest.fixture
def score_input_example(shared_datadir: Path) -> ScoreInputReader:
return ScoreInputReader(shared_datadir / "score_input_example.json")
2 changes: 2 additions & 0 deletions src/alfasim_score/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
WELLBORE_TOP_NODE = "WELBORE_TOP_NODE"
WELLBORE_BOTTOM_NODE = "WELBORE_BOTTOM_NODE"
ANNULUS_TOP_NODE_NAME = "WELLBORE_ANNULUS_TOP_NODE"

CEMENT_NAME = "cement"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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


def test_convert_materials(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

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


def test_convert_well_trajectory(
Expand Down
2 changes: 1 addition & 1 deletion src/alfasim_score/converter/alfacase/convert_alfacase.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def convert_materials(self) -> List[MaterialDescription]:
"""Convert list of materials from SCORE file"""
material_descriptions = []
material_list = (
[self.score_input.read_cement_material()]
self.score_input.read_cement_material()
+ self.score_input.read_tubing_materials()
+ self.score_input.read_lithology_materials()
)
Expand Down
53 changes: 30 additions & 23 deletions src/alfasim_score/converter/alfacase/score_input_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
from barril.units import Scalar
from pathlib import Path

from alfasim_score.constants import CEMENT_NAME
from alfasim_score.units import DENSITY_UNIT
from alfasim_score.units import FRACTION_UNIT
from alfasim_score.units import LENGTH_UNIT
from alfasim_score.units import SPECIFIT_HEAT_UNIT
from alfasim_score.units import SPECIFIC_HEAT_UNIT
from alfasim_score.units import THERMAL_CONDUCTIVITY_UNIT
from alfasim_score.units import THERMAL_EXPANSION_UNIT
from alfasim_score.units import YOUNG_MODULUS_UNIT
Expand All @@ -30,7 +31,7 @@ def read_well_trajectory(self) -> Tuple[Array, Array]:
return Array(x, LENGTH_UNIT), Array(y, LENGTH_UNIT)

def read_tubing_materials(self) -> List[Dict[str, Union[Scalar, str]]]:
""" "Read the data for the tubings from SCORE input file"""
"""Read the data for the tubings from SCORE input file."""
tubing_data = []
for section in self.input_content["operation"]["tubing_string"]["string_sections"]:
thermal_property = section["pipe"]["grade"]["thermomechanical_property"]
Expand All @@ -41,37 +42,43 @@ def read_tubing_materials(self) -> List[Dict[str, Union[Scalar, str]]]:
"thermal_conductivity": Scalar(
thermal_property["thermal_conductivity"], THERMAL_CONDUCTIVITY_UNIT
),
"specific_heat": Scalar(thermal_property["specific_heat"], SPECIFIT_HEAT_UNIT),
"specific_heat": Scalar(thermal_property["specific_heat"], SPECIFIC_HEAT_UNIT),
"thermal_expansion": Scalar(
thermal_property["thermal_expansion_coefficient"], THERMAL_EXPANSION_UNIT
),
"young_modulus": Scalar(thermal_property["e"], YOUNG_MODULUS_UNIT),
"poisson_coefficient": Scalar(thermal_property["nu"], FRACTION_UNIT),
"poisson_ratio": Scalar(thermal_property["nu"], FRACTION_UNIT),
}
)
return tubing_data

def read_cement_material(self) -> Dict[str, Union[Scalar, str]]:
""" "Read the data for the cement from SCORE input file"""
def read_cement_material(self) -> List[Dict[str, Union[Scalar, str]]]:
"""
Read the data for the cement from SCORE input file.
This method assumes all configured cement properties are the same and that
the first_slurry and second_slurry have the same properties.
"""
properties = self.input_content["well_strings"][0]["cementing"]["first_slurry"][
"thermomechanical_property"
]
return {
"name": "cement",
"density": Scalar(properties["density"], DENSITY_UNIT),
"thermal_conductivity": Scalar(
properties["thermal_conductivity"], THERMAL_CONDUCTIVITY_UNIT
),
"specific_heat": Scalar(properties["specific_heat"], SPECIFIT_HEAT_UNIT),
"thermal_expansion": Scalar(
properties["thermal_expansion_coefficient"], THERMAL_EXPANSION_UNIT
),
"young_modulus": Scalar(properties["e"], YOUNG_MODULUS_UNIT),
"poisson_coefficient": Scalar(properties["nu"], FRACTION_UNIT),
}
return [
{
"name": CEMENT_NAME,
"density": Scalar(properties["density"], DENSITY_UNIT),
"thermal_conductivity": Scalar(
properties["thermal_conductivity"], THERMAL_CONDUCTIVITY_UNIT
),
"specific_heat": Scalar(properties["specific_heat"], SPECIFIC_HEAT_UNIT),
"thermal_expansion": Scalar(
properties["thermal_expansion_coefficient"], THERMAL_EXPANSION_UNIT
),
"young_modulus": Scalar(properties["e"], YOUNG_MODULUS_UNIT),
"poisson_ratio": Scalar(properties["nu"], FRACTION_UNIT),
}
]

def read_lithology_materials(self) -> List[Dict[str, Union[Scalar, str]]]:
""" "Read the data for the lithologies from SCORE input file"""
"""Read the data for the lithologies from SCORE input file."""
lithology_data = []
for lithology in self.input_content["lithologies"]:
properties = lithology["thermomechanical_property"]
Expand All @@ -82,11 +89,11 @@ def read_lithology_materials(self) -> List[Dict[str, Union[Scalar, str]]]:
"thermal_conductivity": Scalar(
properties["thermal_conductivity"], THERMAL_CONDUCTIVITY_UNIT
),
"specific_heat": Scalar(properties["specific_heat"], SPECIFIT_HEAT_UNIT),
# expansion has null value, so just use alfacase default 0.0 for this parameter
"specific_heat": Scalar(properties["specific_heat"], SPECIFIC_HEAT_UNIT),
# expansion in the file has null value and APB assumes 0.0 for this parameter
"thermal_expansion": Scalar(0.0, THERMAL_EXPANSION_UNIT),
"young_modulus": Scalar(properties["e"], YOUNG_MODULUS_UNIT),
"poisson_coefficient": Scalar(properties["nu"], FRACTION_UNIT),
"poisson_ratio": Scalar(properties["nu"], FRACTION_UNIT),
}
)
return lithology_data
2 changes: 1 addition & 1 deletion src/alfasim_score/units.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LENGTH_UNIT = "m"
DENSITY_UNIT = "kg/m3"
SPECIFIT_HEAT_UNIT = "J/kg.K"
SPECIFIC_HEAT_UNIT = "J/kg.K"
THERMAL_CONDUCTIVITY_UNIT = "W/m.K"
THERMAL_EXPANSION_UNIT = "1/K"
YOUNG_MODULUS_UNIT = "psi"
Expand Down

0 comments on commit 33dc48e

Please sign in to comment.