Skip to content

Commit

Permalink
Add function to convert material data;
Browse files Browse the repository at this point in the history
PWPA-1960
  • Loading branch information
Gabriel Antão committed Jun 17, 2024
1 parent e2e7593 commit 6ec0ba6
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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
from alfasim_score.converter.fixtures import score_input_example


def test_convert_materials(
data_regression: DataRegressionFixture,
score_input_example: ScoreInputReader,
) -> None:
builder = ScoreAlfacaseConverter(score_input_example)
materials = builder.convert_materials()
data_regression.check(
[
{
"name": material.name,
"type": material.material_type.value,
"density": material.density.GetValue(),
"thermal_conductivity": material.thermal_conductivity.GetValue(),
"heat_capacity": material.heat_capacity.GetValue(),
"thermal_expansion": material.expansion.GetValue(),
}
for material in materials
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
- density: 15.7743
heat_capacity: 837.9
name: cement
thermal_conductivity: 0.983057
thermal_expansion: 1.0e-06
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
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
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
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
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
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
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
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
thermal_conductivity: 45.345257
thermal_expansion: 1.2e-05
type: solid
- density: 1.0
heat_capacity: 5.0
name: Folhelho
thermal_conductivity: 50.0
thermal_expansion: 0.0
type: solid
21 changes: 20 additions & 1 deletion src/alfasim_score/converter/alfacase/convert_alfacase.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import List

from alfasim_sdk import AnnulusDescription
from alfasim_sdk import FormationDescription
from alfasim_sdk import ProfileDescription
from alfasim_sdk import WellDescription
from alfasim_sdk import XAndYDescription
from alfasim_sdk import XAndYDescription, MaterialDescription, MaterialType
from barril.units import Scalar

from alfasim_score.constants import ANNULUS_TOP_NODE_NAME
Expand All @@ -26,6 +28,23 @@ def _convert_well_trajectory(self) -> ProfileDescription:
x, y = self.score_input.read_well_trajectory()
return ProfileDescription(x_and_y=XAndYDescription(x=x, y=y))

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_tubing_materials() + self.score_input.read_lithology_materials()
for data in material_list:
material_descriptions.append(
MaterialDescription(
name=data["name"],
material_type=MaterialType.Solid,
density=data["density"],
thermal_conductivity=data["thermal_conductivity"],
heat_capacity=data["specific_heat"],
expansion=data["thermal_expansion"],
)
)
return material_descriptions

# TODO PWPA-1937: implement this method
def _convert_annulus(self) -> AnnulusDescription:
return AnnulusDescription(has_annulus_flow=False, top_node=ANNULUS_TOP_NODE_NAME)
Expand Down
53 changes: 51 additions & 2 deletions src/alfasim_score/converter/alfacase/score_input_reader.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import json
from barril.units import Array
from pathlib import Path
from typing import Tuple
from typing import Tuple, List, Dict, Union

from alfasim_score.units import LENGTH_UNIT
from alfasim_score.units import LENGTH_UNIT, DENSITY_UNIT, SPECIFIT_HEAT_UNIT, THERMAL_CONDUCTIVITY_UNIT, THERMAL_EXPANSION_UNIT, YOUNG_MODULUS_UNIT, FRACTION_UNIT
from barril.units import Scalar


class ScoreInputReader:
Expand All @@ -17,3 +18,51 @@ def read_well_trajectory(self) -> Tuple[Array, Array]:
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)

def read_tubing_materials(self) -> List[Dict[str, Union[Scalar, str]]]:
""""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"]
tubing_data.append(
{
"name": section["pipe"]["grade"]["name"],
"density": Scalar(thermal_property["density"], DENSITY_UNIT),
"thermal_conductivity": Scalar(thermal_property["thermal_conductivity"], THERMAL_CONDUCTIVITY_UNIT),
"specific_heat": Scalar(thermal_property["specific_heat"], SPECIFIT_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),
}
)
return tubing_data

def read_cement_material(self) -> Dict[str, Union[Scalar, str]]:
""""Read the data for the cement from SCORE input file"""
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),
}

def read_lithology_materials(self) -> List[Dict[str, Union[Scalar, str]]]:
""""Read the data for the lithologies from SCORE input file"""
lithology_data = []
for lithology in self.input_content["lithologies"]:
properties = lithology["thermomechanical_property"]
lithology_data.append({
"name": lithology["display_name"],
"density": Scalar(properties["density"], DENSITY_UNIT),
"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 default 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),
})
return lithology_data

0 comments on commit 6ec0ba6

Please sign in to comment.