From 33dc48ecbe971d3ed4b350a898f2c80d4161447f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ant=C3=A3o?= Date: Tue, 18 Jun 2024 15:29:17 -0300 Subject: [PATCH] Minor fixes in names and comments; PWPA-1960 --- src/alfasim_score/conftest.py | 9 ++++ src/alfasim_score/constants.py | 2 + .../alfacase/_tests/test_convert_materials.py | 1 - .../_tests/test_convert_well_trajectory.py | 1 - .../converter/alfacase/convert_alfacase.py | 2 +- .../converter/alfacase/score_input_reader.py | 53 +++++++++++-------- src/alfasim_score/units.py | 2 +- 7 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/alfasim_score/conftest.py b/src/alfasim_score/conftest.py index e69de29..a610c0a 100644 --- a/src/alfasim_score/conftest.py +++ b/src/alfasim_score/conftest.py @@ -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") diff --git a/src/alfasim_score/constants.py b/src/alfasim_score/constants.py index 2ecd249..606955b 100644 --- a/src/alfasim_score/constants.py +++ b/src/alfasim_score/constants.py @@ -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" diff --git a/src/alfasim_score/converter/alfacase/_tests/test_convert_materials.py b/src/alfasim_score/converter/alfacase/_tests/test_convert_materials.py index 914f0d6..208a800 100644 --- a/src/alfasim_score/converter/alfacase/_tests/test_convert_materials.py +++ b/src/alfasim_score/converter/alfacase/_tests/test_convert_materials.py @@ -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( diff --git a/src/alfasim_score/converter/alfacase/_tests/test_convert_well_trajectory.py b/src/alfasim_score/converter/alfacase/_tests/test_convert_well_trajectory.py index b141d86..b7bc357 100644 --- a/src/alfasim_score/converter/alfacase/_tests/test_convert_well_trajectory.py +++ b/src/alfasim_score/converter/alfacase/_tests/test_convert_well_trajectory.py @@ -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( diff --git a/src/alfasim_score/converter/alfacase/convert_alfacase.py b/src/alfasim_score/converter/alfacase/convert_alfacase.py index b0d2f32..f85ecc2 100644 --- a/src/alfasim_score/converter/alfacase/convert_alfacase.py +++ b/src/alfasim_score/converter/alfacase/convert_alfacase.py @@ -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() ) diff --git a/src/alfasim_score/converter/alfacase/score_input_reader.py b/src/alfasim_score/converter/alfacase/score_input_reader.py index b9dcd21..f7f1ff3 100644 --- a/src/alfasim_score/converter/alfacase/score_input_reader.py +++ b/src/alfasim_score/converter/alfacase/score_input_reader.py @@ -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 @@ -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"] @@ -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"] @@ -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 diff --git a/src/alfasim_score/units.py b/src/alfasim_score/units.py index f574968..58ae070 100644 --- a/src/alfasim_score/units.py +++ b/src/alfasim_score/units.py @@ -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"