Skip to content

Commit

Permalink
Add node list to the alfacase;
Browse files Browse the repository at this point in the history
Move enums to common.py;
Add curve to the prepare_for_regression function;

PWPA-1977
  • Loading branch information
Gabriel Antão committed Jun 28, 2024
1 parent 4293494 commit 95e3761
Show file tree
Hide file tree
Showing 8 changed files with 424 additions and 22 deletions.
29 changes: 29 additions & 0 deletions src/alfasim_score/common.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
from typing import Any
from typing import Dict

from barril.curve.curve import Curve
from barril.units import Array
from barril.units import Scalar
from enum import Enum


class WellItemType(str, Enum):
DRILLING = "DRILLING"
CASING = "CASING"
NONE = "NONE"


class WellItemFunction(str, Enum):
CONDUCTOR = "CONDUCTOR"
SURFACE = "SURFACE"
PRODUCTION = "PRODUCTION"
OPEN = "OPEN"


# TODO: need more examples of SCORE files to know the label for method
# the method is in the file tree in the path operation/data/method
class LiftMethod(str, Enum):
# NATURAL_FLOW = "???"
GAS_LIFT = "GASLIFT"
# BCS_PUMP = "???"


def prepare_for_regression(values: Dict[str, Any]) -> Dict[str, Any]:
""" "Prepare Scalar and Array to the be used in regression test"""
regression_values = {}
Expand All @@ -20,6 +42,13 @@ def prepare_for_regression(values: Dict[str, Any]) -> Dict[str, Any]:
"values": value.values,
"unit": value.unit,
}
elif isinstance(value, Curve):
regression_values[key] = {
"image_values": value.image.values,
"image_unit": value.image.unit,
"domain_values": value.domain.values,
"domain_unit": value.domain.unit,
}
elif isinstance(value, Enum):
regression_values[key] = value.value
else:
Expand Down
21 changes: 18 additions & 3 deletions src/alfasim_score/constants.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from barril.units import Scalar

from alfasim_score.units import MASS_FLOW_RATE_UNIT
from alfasim_score.units import PRESSURE
from alfasim_score.units import ROUGHNESS_UNIT
from alfasim_score.units import STD_VOLUMETRIC_FLOW_RATE_UNIT
from alfasim_score.units import TEMPERATURE

WELLBORE_NAME = "WELLBORE"
WELLBORE_TOP_NODE = "WELBORE_TOP_NODE"
WELLBORE_BOTTOM_NODE = "WELBORE_BOTTOM_NODE"
WELLBORE_TOP_NODE_NAME = "WELBORE_TOP_NODE"
WELLBORE_BOTTOM_NODE_NAME = "WELBORE_BOTTOM_NODE"
ANNULUS_TOP_NODE_NAME = "WELLBORE_ANNULUS_TOP_NODE"

GAS_LIFT_MASS_NODE_NAME = "GAS_LIFT_MASS_NODE"
CEMENT_NAME = "cement"

ROCK_DEFAULT_ROUGHNESS = Scalar(0.1, ROUGHNESS_UNIT)
Expand All @@ -15,3 +19,14 @@

# This default fluid name for packer and fluid above filler
FLUID_DEFAULT_NAME = "fluid_default"

# nodes data
BASE_PVT_TABLE_NAME = "base"
GAS_LIFT_PVT_TABLE_NAME = "gas_lift"
NULL_VOLUMETRIC_FLOW_RATE = Scalar(0.0, STD_VOLUMETRIC_FLOW_RATE_UNIT)
NULL_MASS_FLOW_RATE = Scalar(0.0, MASS_FLOW_RATE_UNIT)
WELL_TOP_NODE_DEFAULT_TEMPERATURE = Scalar(40.0, TEMPERATURE)
WELL_TOP_NODE_DEFAULT_PRESSURE = Scalar(9.0, PRESSURE)
WELL_BOTTOM_NODE_DEFAULT_TEMPERATURE = Scalar(60.0, TEMPERATURE)
WELL_BOTTOM_NODE_DEFAULT_PRESSURE = Scalar(10.0, PRESSURE)
GAS_LIFT_TEMPERATURE = Scalar(40.0, TEMPERATURE)
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,270 @@ outputs:
value: 0.1
unit: s
pipes: []
nodes: []
nodes:
- name: WELBORE_TOP_NODE
node_type: mass_source_boundary
pvt_model: base
pressure_properties:
pressure:
value: 100000.0
unit: Pa
temperature:
value: 288.6
unit: K
tracer_mass_fraction:
values: []
unit: '-'
split_type: mass_inflow_split_type_constant_volume_fraction
gas_liquid_ratio:
value: 0.0
unit: sm3/sm3
gas_oil_ratio:
value: 0.0
unit: sm3/sm3
water_cut:
value: 0.0
unit: '-'
mass_source_properties:
tracer_mass_fraction:
values: []
unit: '-'
temperature:
value: 40.0
unit: degC
source_type: mass_source_type_all_volumetric_flow_rates
volumetric_flow_rates_std:
gas:
value: 0.0
unit: sm3/d
oil:
value: 0.0
unit: sm3/d
water:
value: 0.0
unit: sm3/d
total_mass_flow_rate:
value: 1.0
unit: kg/s
water_cut:
value: 0.0
unit: '-'
gas_oil_ratio:
value: 0.0
unit: sm3/sm3
separator_properties:
environment_temperature:
value: 25.0
unit: degC
geometry: vertical_cylinder
length:
value: 1.0
unit: m
overall_heat_transfer_coefficient:
value: 0.0
unit: W/m2.K
diameter:
value: 1.0
unit: m
initial_phase_volume_fractions:
gas:
value: 0.5
unit: '-'
oil:
value: 0.5
unit: '-'
gas_separation_efficiency:
value: 1.0
unit: '-'
liquid_separation_efficiency:
value: 1.0
unit: '-'
controller_properties:
type: pid
gain: 0.0001
setpoint: 0.0
integral_time:
value: 10.0
unit: s
derivative_time:
value: 1.0
unit: s
output_signal_properties:
min_value: -1e+50
max_value: 1e+50
max_rate_of_change: 1e+50
- name: WELBORE_BOTTOM_NODE
node_type: pressure_boundary
pvt_model: base
pressure_properties:
pressure:
value: 10.0
unit: kgf/cm2
temperature:
value: 60.0
unit: degC
tracer_mass_fraction:
values: []
unit: '-'
split_type: mass_inflow_split_type_pvt
gas_liquid_ratio:
value: 0.0
unit: sm3/sm3
gas_oil_ratio:
value: 0.0
unit: sm3/sm3
water_cut:
value: 0.0
unit: '-'
mass_source_properties:
tracer_mass_fraction:
values: []
unit: '-'
temperature:
value: 288.6
unit: K
source_type: mass_source_type_mass_flow_rates
total_mass_flow_rate:
value: 1.0
unit: kg/s
water_cut:
value: 0.0
unit: '-'
gas_oil_ratio:
value: 0.0
unit: sm3/sm3
separator_properties:
environment_temperature:
value: 25.0
unit: degC
geometry: vertical_cylinder
length:
value: 1.0
unit: m
overall_heat_transfer_coefficient:
value: 0.0
unit: W/m2.K
diameter:
value: 1.0
unit: m
initial_phase_volume_fractions:
gas:
value: 0.5
unit: '-'
oil:
value: 0.5
unit: '-'
gas_separation_efficiency:
value: 1.0
unit: '-'
liquid_separation_efficiency:
value: 1.0
unit: '-'
controller_properties:
type: pid
gain: 0.0001
setpoint: 0.0
integral_time:
value: 10.0
unit: s
derivative_time:
value: 1.0
unit: s
output_signal_properties:
min_value: -1e+50
max_value: 1e+50
max_rate_of_change: 1e+50
- name: GAS_LIFT_MASS_NODE
node_type: mass_source_boundary
pvt_model: gas_lift
pressure_properties:
pressure:
value: 100000.0
unit: Pa
temperature:
value: 288.6
unit: K
tracer_mass_fraction:
values: []
unit: '-'
split_type: mass_inflow_split_type_constant_volume_fraction
gas_liquid_ratio:
value: 0.0
unit: sm3/sm3
gas_oil_ratio:
value: 0.0
unit: sm3/sm3
water_cut:
value: 0.0
unit: '-'
mass_source_properties:
tracer_mass_fraction:
values: []
unit: '-'
temperature:
value: 40.0
unit: degC
source_type: mass_source_type_all_volumetric_flow_rates
volumetric_flow_rates_std:
gas:
value: 0.0
unit: sm3/d
oil:
value: 0.0
unit: sm3/d
water:
value: 0.0
unit: sm3/d
total_mass_flow_rate:
value: 1.0
unit: kg/s
water_cut:
value: 0.0
unit: '-'
gas_oil_ratio:
value: 0.0
unit: sm3/sm3
separator_properties:
environment_temperature:
value: 25.0
unit: degC
geometry: vertical_cylinder
length:
value: 1.0
unit: m
overall_heat_transfer_coefficient:
value: 0.0
unit: W/m2.K
diameter:
value: 1.0
unit: m
initial_phase_volume_fractions:
gas:
value: 0.5
unit: '-'
oil:
value: 0.5
unit: '-'
gas_separation_efficiency:
value: 1.0
unit: '-'
liquid_separation_efficiency:
value: 1.0
unit: '-'
controller_properties:
type: pid
gain: 0.0001
setpoint: 0.0
integral_time:
value: 10.0
unit: s
derivative_time:
value: 1.0
unit: s
output_signal_properties:
min_value: -1e+50
max_value: 1e+50
max_rate_of_change: 1e+50
wells:
- name: WELLBORE
profile:
Expand Down
21 changes: 21 additions & 0 deletions src/alfasim_score/converter/alfacase/_tests/test_convert_nodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import attr
from alfasim_sdk import NodeCellType
from pytest_regressions.data_regression import DataRegressionFixture

from alfasim_score.common import prepare_for_regression
from alfasim_score.converter.alfacase.convert_alfacase import ScoreAlfacaseConverter
from alfasim_score.converter.alfacase.score_input_reader import ScoreInputReader


def test_convert_nodes(
data_regression: DataRegressionFixture,
score_input_example: ScoreInputReader,
) -> None:
builder = ScoreAlfacaseConverter(score_input_example)
nodes = builder.build_nodes()
data_regression.check(
[
{"name": node.name, "type": node.node_type.value, "pvt_model": node.pvt_model}
for node in nodes
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- name: WELBORE_TOP_NODE
pvt_model: base
type: mass_source_boundary
- name: WELBORE_BOTTOM_NODE
pvt_model: base
type: pressure_boundary
- name: GAS_LIFT_MASS_NODE
pvt_model: gas_lift
type: mass_source_boundary
Loading

0 comments on commit 95e3761

Please sign in to comment.