Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node list to the SCORE to alfacase converter #5

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 PWPA-1983: 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 = "???"
# BCS_PUMP = "???"
GAS_LIFT = "GASLIFT"


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
16 changes: 13 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,9 @@

# 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)
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: 288.6
unit: K
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: 100000.0
unit: Pa
temperature:
value: 288.6
unit: K
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: 288.6
unit: K
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
Loading